Insert project info into database before actual git repository creation.

This commit is contained in:
takezoe
2013-06-02 14:37:52 +09:00
parent 6512b673f6
commit f6a7aca4c2

View File

@@ -21,11 +21,12 @@ trait ProjectService { self: AccountService =>
// TODO create a git repository also here? // TODO create a git repository also here?
val currentDate = new java.sql.Date(System.currentTimeMillis) val currentDate = new java.sql.Date(System.currentTimeMillis)
Projects.ins returning Projects.projectId insert Projects.ins returning Projects.projectId insert
Project( Project(
projectId = None, projectId = None,
projectName = projectName, projectName = projectName,
userId = getAccountByUserName(userName).get.userId.get, userId = getUserId(userName),
projectType = 0 /* 0:public, 1:private */, projectType = 0 /* 0:public, 1:private */,
description = description, description = description,
defaultBranch = "master", defaultBranch = "master",
@@ -34,4 +35,16 @@ trait ProjectService { self: AccountService =>
lastActivityDate = currentDate) lastActivityDate = currentDate)
} }
/**
* Returns the specified user's project list.
*
* @param userName the user name
* @return the project list which is sorted in descending order of lastActivityDate.
*/
def getProjects(userName: String): List[Project] = {
Query(Projects) filter(_.userId is getUserId(userName).bind) sortBy(_.lastActivityDate desc) list
}
private def getUserId(userName: String): Long = getAccountByUserName(userName).get.userId.get
} }