This repository has been archived by the owner on Dec 10, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
122 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package controllers | ||
|
||
import play.api.mvc.{Action, Controller} | ||
import play.api.libs.json.Json | ||
import play.api.libs.concurrent.Execution.Implicits._ | ||
import hedgehog.models.{GithubOrg, Repo, GithubUser} | ||
import hedgehog.clients.github.RepositoriesFetcher | ||
|
||
|
||
/** | ||
* Copyright (c) Nikita Kovaliov, maizy.ru, 2014 | ||
* See LICENSE.txt for details. | ||
*/ | ||
object Github extends Controller { | ||
|
||
def forceUpdate = Action { | ||
// val config = hedgehog.Config.playAppInstance | ||
// RepositoriesFetcher.playAppInstance.reload(config.sources.accountsSettings).map { | ||
// Ok(Json.obj("success" -> false)) | ||
// } | ||
Ok("1") | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package hedgehog.clients.github | ||
|
||
import scala.concurrent.{Future, Promise} | ||
import hedgehog.models.{AccountSettings, Repo} | ||
|
||
|
||
/** | ||
* Copyright (c) Nikita Kovaliov, maizy.ru, 2014 | ||
* See LICENSE.txt for details. | ||
*/ | ||
class Client(val config: Config, implicit val context: scala.concurrent.ExecutionContext) { | ||
|
||
def getRepos(accountSettings: AccountSettings): Future[Seq[Repo]] = { | ||
val finish = Promise[Seq[Repo]]() | ||
finish success List(new Repo("a", accountSettings.account), | ||
new Repo("b", accountSettings.account)) | ||
|
||
finish.future | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package hedgehog.clients.github | ||
|
||
import scala.concurrent.{Future, Promise} | ||
import scala.collection.mutable | ||
import com.github.nscala_time.time.Imports.DateTime | ||
import hedgehog.models.{AccountSettings, Repo} | ||
|
||
|
||
/** | ||
* Copyright (c) Nikita Kovaliov, maizy.ru, 2014 | ||
* See LICENSE.txt for details. | ||
*/ | ||
class RepositoriesFetcher(client: Client) { | ||
val repositories: mutable.Map[String, Option[Seq[Repo]]] = mutable.Map.empty | ||
val lastFetched: mutable.Map[String, Option[DateTime]] = mutable.Map.empty | ||
|
||
implicit val context = client.context | ||
|
||
def getRepos(accountsSettings: Seq[AccountSettings]): Future[Seq[Repo]] = { | ||
//TODO: cache | ||
fetch(accountsSettings) | ||
} | ||
|
||
private def fetch(accountsSettings: Seq[AccountSettings]): Future[Seq[Repo]] = { | ||
val requests = Future.sequence{ | ||
accountsSettings.map(client.getRepos) | ||
} | ||
val future = requests map { | ||
case r => r.flatten | ||
} | ||
future | ||
} | ||
|
||
def reload(accountSettings: Seq[AccountSettings]): Future[Seq[(AccountSettings, Boolean)]] = { | ||
//val p = Promise[Seq[(AccountSettings, Boolean)]] | ||
Future { | ||
List() | ||
} | ||
} | ||
} | ||
|
||
|
||
object RepositoriesFetcher { | ||
lazy val playAppInstance: RepositoriesFetcher = new RepositoriesFetcher(hedgehog.Config.playAppInstance.githubClient) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters