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
public abstract class BaseService { | |
protected void create(GenericTablePojo tableObject) { | |
GenericRecord g = buildRecordObject(tableObject); | |
g.store(); | |
} | |
protected void update(GenericTablePojo tableObject) { | |
GenericRecord g = buildGenericRecord(tableObject); | |
g.store(); |
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
import java.util.*; | |
class Main { | |
public static void main(String[] args) { | |
int[] nums1 = new int[] { | |
1, 2, 1 | |
}; | |
int[] nums2 = new int[] { | |
1, 0 | |
}; |
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
<div class="table-responsive"> | |
<table class="table table-bordered table-striped"> | |
<thead> | |
<tr> | |
<th>Commit ID</th> | |
<th>Message</th> | |
<th>Author</th> | |
<th>Commit Timestamp</th> | |
</tr> | |
</thead> |
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
play.api.http.HttpErrorHandlerExceptions$$anon$1: Execution exception[[BatchUpdateException: Batch entry 606 insert into "commit" ("git_id","message","author","email","author_timestamp","repository","created_at","updated_at") values ('32f824a6767071eb6991eec3bfc591eddda6a2f2','logback config','d***','D***','2015-02-23 14:34:08.000000 -07:00:00','dna****','2015-09-17 14:54:03.978000 -06:00:00','2015-09-17 14:54:03.978000 -06:00:00') was aborted. Call getNextException to see the cause.]] |
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
with table_stats as ( | |
select psut.relname, | |
psut.n_live_tup, | |
1.0 * psut.idx_scan / greatest(1, psut.seq_scan + psut.idx_scan) as index_use_ratio | |
from pg_stat_user_tables psut | |
order by psut.n_live_tup desc | |
), | |
table_io as ( | |
select psiut.relname, | |
sum(psiut.heap_blks_read) as table_page_read, |
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
def commitsFor(project: String, page: Option[Int] = None, limit: Option[Int] = None) = { //: Future[List[scala.collection.immutable.Map[String, List[Commit]]]] = { | |
// grab repos for a project name. need to make this async. | |
// need to return project from API if no projects exist, then queue up a db population | |
// need to account for nonexistent projects as well | |
Logger.info("DAL commitsFor " + project) | |
// make me non-blocking | |
val projectId = Await.result(db.run(Projects.filter(_.name === project).map(_.id).result), 2 seconds).headOption | |
val repoQuery = Repositories.filter(_.project === projectId).map(_.name) |
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
"retrieve the correct page when specified" in new WithApplication | |
with RepositoryTable | |
with CommitTable | |
with ProjectTable | |
with WithDatabaseConfig | |
with DBCleanup | |
with DBFixtures { | |
import driver.api._ | |
//create an instance of the table | |
val Projects = TableQuery[Projects] |
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
def crawlProjectRepos(project: String) = { | |
Logger.info("crawling " + project + " by API") | |
// a list of Futures containing a Tuple2 of a repository name and a Future[WSResponse] | |
val repoList = reposFor(project).map { repo => | |
(repo, callApi(buildCommitUrl(project, repo))) | |
} | |
Logger.debug("REPOS FOR" + reposFor(project)) | |
Future.traverse(repoList) ( | |
repoCommits => |
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
def crawlProjectRepos(project: String) = { | |
Logger.info("crawling " + project + " by API") | |
// a list of Futures containing a Tuple2 of a repository name and a Future[WSResponse] | |
val repoList = reposFor(project).map { repo => | |
(repo, callApi(buildCommitUrl(project, repo))) | |
} | |
Future.traverse(repoList) ( | |
repoCommits => | |
repoCommits._2.filter(_.status==200).map { res => |
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
case class RepositoryCommitResponse(repository: String, response: Future[WSResponse]) | |
val repos = reposFor(project) // just a list of strings: List("repo1", "repo2", "repo3") | |
val futureRepoList = repos.map { repo => Future{RepositoryCommitResponse(repo, callApi(buildCommitUrl(project, repo)))} } | |
Logger.info("FUTURE REPO LIST " + futureRepoList) | |
val goodRepos = Future.sequence(futureRepoList) map { fr => | |
fr.map(_.response.filter(_.status==200)) | |
} | |
for ( r <- goodRepos ) { | |
for (rr <- r) { |