(refs #4)Add 'News Feed' to the index page.

This commit is contained in:
takezoe
2013-07-07 14:05:01 +09:00
parent 6005282d9f
commit 96dac65e31
5 changed files with 81 additions and 59 deletions

View File

@@ -2,12 +2,16 @@ package app
import service._
class IndexController extends IndexControllerBase with RepositoryService with AccountService with SystemSettingsService
class IndexController extends IndexControllerBase
with RepositoryService with AccountService with SystemSettingsService with ActivityService
trait IndexControllerBase extends ControllerBase { self: RepositoryService with SystemSettingsService =>
trait IndexControllerBase extends ControllerBase { self: RepositoryService
with SystemSettingsService with ActivityService =>
get("/"){
html.index(getAccessibleRepositories(context.loginAccount, baseUrl), loadSystemSettings(),
html.index(getRecentActivities(),
getAccessibleRepositories(context.loginAccount, baseUrl),
loadSystemSettings(),
context.loginAccount.map{ account => getRepositoryNamesOfUser(account.userName) }.getOrElse(Nil))
}

View File

@@ -21,6 +21,16 @@ trait ActivityService {
.take(30)
.list
}
def getRecentActivities(): List[Activity] =
Query(Activities)
.innerJoin(Repositories).on((t1, t2) => t1.byRepository(t2.userName, t2.repositoryName))
.filter { case (t1, t2) => t2.isPrivate is false.bind }
.sortBy { case (t1, t2) => t1.activityId desc }
.map { case (t1, t2) => t1 }
.take(30)
.list
def recordCreateRepositoryActivity(userName: String, repositoryName: String, activityUserName: String): Unit =
Activities.autoInc insert(userName, repositoryName, activityUserName,