mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-07 05:55:51 +01:00
Refactor database schema.
This commit is contained in:
2
sbt.bat
2
sbt.bat
@@ -1,2 +1,2 @@
|
||||
set SCRIPT_DIR=%~dp0
|
||||
java -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256m -Xmx512M -Xss2M -jar "%SCRIPT_DIR%\sbt-launch-0.12.3.jar" %*
|
||||
java -Dhttp.proxyHost=proxy.intellilink.co.jp -Dhttp.proxyPort=8080 -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256m -Xmx512M -Xss2M -jar "%SCRIPT_DIR%\sbt-launch-0.12.3.jar" %*
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
CREATE TABLE ACCOUNT(
|
||||
USER_ID IDENTITY NOT NULL,
|
||||
USER_NAME VARCHAR(100) NOT NULL,
|
||||
MAIL_ADDRESS VARCHAR(100) NOT NULL,
|
||||
PASSWORD VARCHAR(20) NOT NULL,
|
||||
@@ -10,11 +9,10 @@ CREATE TABLE ACCOUNT(
|
||||
LAST_LOGIN_DATE TIMESTAMP
|
||||
);
|
||||
|
||||
CREATE TABLE PROJECT(
|
||||
PROJECT_ID IDENTITY NOT NULL,
|
||||
PROJECT_NAME VARCHAR(100) NOT NULL,
|
||||
USER_ID INT NOT NULL,
|
||||
PROJECT_TYPE INT DEFAULT 0 NOT NULL,
|
||||
CREATE TABLE REPOSITORY(
|
||||
REPOSITORY_NAME VARCHAR(100) NOT NULL,
|
||||
USER_NAME VARCHAR(100) NOT NULL,
|
||||
REPOSITORY_TYPE INT DEFAULT 0 NOT NULL,
|
||||
DESCRIPTION TEXT,
|
||||
DEFAULT_BRANCH VARCHAR(100),
|
||||
REGISTERED_DATE TIMESTAMP NOT NULL,
|
||||
@@ -22,21 +20,93 @@ CREATE TABLE PROJECT(
|
||||
LAST_ACTIVITY_DATE TIMESTAMP NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE PROJECT_ACCOUNT(
|
||||
PROJECT_ID INT NOT NULL,
|
||||
USER_ID INT NOT NULL
|
||||
CREATE TABLE REPOSITORY_ACCOUNT(
|
||||
REPOSITORY_NAME VARCHAR(100) NOT NULL,
|
||||
USER_NAME VARCHAR(100) NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE ISSUE(
|
||||
USER_NAME VARCHAR(100) NOT NULL,
|
||||
REPOSITORY_NAME VARCHAR(100) NOT NULL,
|
||||
ISSUE_ID INT NOT NULL,
|
||||
OPENED_USER_NAME VARCHAR(100) NOT NULL,
|
||||
MILESTONE_ID INT NOT NULL,
|
||||
TITLE TEXT NOT NULL,
|
||||
CONTENT TEXT NOT NULL,
|
||||
REGISTERED_DATE TIMESTAMP NOT NULL,
|
||||
UPDATED_DATE TIMESTAMP NOT NULL
|
||||
);
|
||||
|
||||
--ALTER TABLE ACCOUNT ADD CONSTRAINT IDX_ACCOUNT_PK PRIMARY KEY (USER_ID);
|
||||
CREATE TABLE ISSUE_ID(
|
||||
USER_NAME VARCHAR(100) NOT NULL,
|
||||
REPOSITORY_NAME VARCHAR(100) NOT NULL,
|
||||
ISSUE_ID INT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE ISSUE_COMMENT(
|
||||
USER_NAME VARCHAR(100) NOT NULL,
|
||||
REPOSITORY_NAME VARCHAR(100) NOT NULL,
|
||||
ISSUE_ID INT NOT NULL,
|
||||
COMMENT_ID INT AUTO_INCREMENT,
|
||||
COMMENTED_USER_NAME VARCHAR(100) NOT NULL,
|
||||
CONTENT TEXT NOT NULL,
|
||||
REGISTERED_DATE TIMESTAMP NOT NULL,
|
||||
UPDATED_DATE TIMESTAMP NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE LABEL(
|
||||
USER_NAME VARCHAR(100) NOT NULL,
|
||||
REPOSITORY_NAME VARCHAR(100) NOT NULL,
|
||||
LABEL_ID INT AUTO_INCREMENT,
|
||||
LABEL VARCHAR(100) NOT NULL,
|
||||
COLOR CHAR(6) NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE ISSUE_LABEL(
|
||||
USER_NAME VARCHAR(100) NOT NULL,
|
||||
REPOSITORY_NAME VARCHAR(100) NOT NULL,
|
||||
ISSUE_ID INT NOT NULL,
|
||||
LABEL_ID INT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE MILESTONE(
|
||||
USER_NAME VARCHAR(100) NOT NULL,
|
||||
REPOSITORY_NAME INT NOT NULL,
|
||||
MILESTONE_ID INT AUTO_INCREMENT,
|
||||
MILESTONE_NAME VARCHAR(100) NOT NULL
|
||||
);
|
||||
|
||||
ALTER TABLE ACCOUNT ADD CONSTRAINT IDX_ACCOUNT_PK PRIMARY KEY (USER_NAME);
|
||||
ALTER TABLE ACCOUNT ADD CONSTRAINT IDX_ACCOUNT_1 UNIQUE (MAIL_ADDRESS);
|
||||
|
||||
--ALTER TABLE PROJECT ADD CONSTRAINT IDX_PROJECT_PK PRIMARY KEY (PROJECT_ID);
|
||||
ALTER TABLE PROJECT ADD CONSTRAINT IDX_PROJECT_1 UNIQUE (PROJECT_NAME, USER_ID);
|
||||
ALTER TABLE REPOSITORY ADD CONSTRAINT IDX_REPOSITORY_PK PRIMARY KEY (REPOSITORY_NAME, USER_NAME);
|
||||
ALTER TABLE REPOSITORY ADD CONSTRAINT IDX_REPOSITORY_FK0 FOREIGN KEY (USER_NAME) REFERENCES ACCOUNT (USER_NAME);
|
||||
|
||||
ALTER TABLE PROJECT_ACCOUNT ADD CONSTRAINT IDX_PROJECT_ACCOUNT_PK PRIMARY KEY (PROJECT_ID, USER_ID);
|
||||
ALTER TABLE PROJECT_ACCOUNT ADD CONSTRAINT IDX_PROJECT_ACCOUNT_FK0 FOREIGN KEY (PROJECT_ID) REFERENCES PROJECT (PROJECT_ID);
|
||||
ALTER TABLE PROJECT_ACCOUNT ADD CONSTRAINT IDX_PROJECT_ACCOUNT_FK1 FOREIGN KEY (USER_ID) REFERENCES ACCOUNT (USER_ID);
|
||||
ALTER TABLE REPOSITORY_ACCOUNT ADD CONSTRAINT IDX_REPOSITORY_ACCOUNT_PK PRIMARY KEY (REPOSITORY_NAME, USER_NAME);
|
||||
ALTER TABLE REPOSITORY_ACCOUNT ADD CONSTRAINT IDX_REPOSITORY_ACCOUNT_FK0 FOREIGN KEY (REPOSITORY_NAME) REFERENCES REPOSITORY (REPOSITORY_NAME);
|
||||
ALTER TABLE REPOSITORY_ACCOUNT ADD CONSTRAINT IDX_REPOSITORY_ACCOUNT_FK1 FOREIGN KEY (USER_NAME) REFERENCES ACCOUNT (USER_NAME);
|
||||
|
||||
ALTER TABLE ISSUE ADD CONSTRAINT IDX_ISSUE_PK PRIMARY KEY (ISSUE_ID, USER_NAME, REPOSITORY_NAME);
|
||||
ALTER TABLE ISSUE ADD CONSTRAINT IDX_ISSUE_FK0 FOREIGN KEY (USER_NAME, REPOSITORY_NAME) REFERENCES REPOSITORY (USER_NAME, REPOSITORY_NAME);
|
||||
ALTER TABLE ISSUE ADD CONSTRAINT IDX_ISSUE_FK1 FOREIGN KEY (OPENED_USER_NAME) REFERENCES ACCOUNT (USER_NAME);
|
||||
ALTER TABLE ISSUE ADD CONSTRAINT IDX_ISSUE_FK2 FOREIGN KEY (MILESTONE_ID) REFERENCES MILESTONE (MILESTONE_ID);
|
||||
|
||||
ALTER TABLE ISSUE_ID ADD CONSTRAINT IDX_ISSUE_ID_PK PRIMARY KEY (USER_NAME, REPOSITORY_NAME);
|
||||
ALTER TABLE ISSUE_ID ADD CONSTRAINT IDX_ISSUE_ID_FK1 FOREIGN KEY (USER_NAME, REPOSITORY_NAME) REFERENCES REPOSITORY (USER_NAME, REPOSITORY_NAME);
|
||||
|
||||
ALTER TABLE ISSUE_COMMENT ADD CONSTRAINT IDX_ISSUE_COMMENT_PK PRIMARY KEY (COMMENT_ID);
|
||||
ALTER TABLE ISSUE_COMMENT ADD CONSTRAINT IDX_ISSUE_COMMENT_1 UNIQUE (USER_NAME, REPOSITORY_NAME, ISSUE_ID, COMMENT_ID);
|
||||
ALTER TABLE ISSUE_COMMENT ADD CONSTRAINT IDX_ISSUE_COMMENT_FK0 FOREIGN KEY (USER_NAME, REPOSITORY_NAME, ISSUE_ID) REFERENCES ISSUE (USER_NAME, REPOSITORY_NAME, ISSUE_ID);
|
||||
|
||||
ALTER TABLE LABEL ADD CONSTRAINT IDX_LABEL_PK PRIMARY KEY (USER_NAME, REPOSITORY_NAME, LABEL_ID);
|
||||
ALTER TABLE LABEL ADD CONSTRAINT IDX_LABEL_1 UNIQUE (USER_NAME, REPOSITORY_NAME, LABEL);
|
||||
ALTER TABLE LABEL ADD CONSTRAINT IDX_LABEL_FK0 FOREIGN KEY (USER_NAME, REPOSITORY_NAME) REFERENCES REPOSITORY (USER_NAME, REPOSITORY_NAME);
|
||||
|
||||
ALTER TABLE ISSUE_LABEL ADD CONSTRAINT IDX_ISSUE_LABEL_PK PRIMARY KEY (USER_NAME, REPOSITORY_NAME, ISSUE_ID, LABEL_ID);
|
||||
ALTER TABLE ISSUE_LABEL ADD CONSTRAINT IDX_ISSUE_LABEL_FK0 FOREIGN KEY (USER_NAME, REPOSITORY_NAME, ISSUE_ID) REFERENCES ISSUE (USER_NAME, REPOSITORY_NAME, ISSUE_ID);
|
||||
|
||||
ALTER TABLE MILESTONE ADD CONSTRAINT IDX_MILESTONE_PK PRIMARY KEY (USER_NAME, REPOSITORY_NAME, MILESTONE_ID);
|
||||
ALTER TABLE MILESTONE ADD CONSTRAINT IDX_MILESTONE_FK0 FOREIGN KEY (USER_NAME, REPOSITORY_NAME) REFERENCES REPOSITORY (USER_NAME, REPOSITORY_NAME);
|
||||
|
||||
INSERT INTO ACCOUNT (
|
||||
USER_NAME,
|
||||
|
||||
@@ -3,8 +3,7 @@ package model
|
||||
import scala.slick.driver.H2Driver.simple._
|
||||
|
||||
object Accounts extends Table[Account]("ACCOUNT") {
|
||||
def userId = column[Long]("USER_ID", O AutoInc)
|
||||
def userName = column[String]("USER_NAME")
|
||||
def userName = column[String]("USER_NAME", O PrimaryKey)
|
||||
def mailAddress = column[String]("MAIL_ADDRESS")
|
||||
def password = column[String]("PASSWORD")
|
||||
def userType = column[Int]("USER_TYPE")
|
||||
@@ -12,12 +11,11 @@ object Accounts extends Table[Account]("ACCOUNT") {
|
||||
def registeredDate = column[java.sql.Date]("REGISTERED_DATE") // TODO convert java.util.Date later
|
||||
def updatedDate = column[java.sql.Date]("UPDATED_DATE")
|
||||
def lastLoginDate = column[java.sql.Date]("LAST_LOGIN_DATE")
|
||||
def * = userId.? ~ userName ~ mailAddress ~ password ~ userType ~ url.? ~ registeredDate ~ updatedDate ~ lastLoginDate.? <> (Account, Account.unapply _)
|
||||
def ins = userName ~ mailAddress ~ password ~ userType ~ url.? ~ registeredDate ~ updatedDate ~ lastLoginDate.? <> ({ t => Account(None, t._1, t._2, t._3, t._4, t._5, t._6, t._7, t._8)}, { (o: Account) => Some((o.userName, o.mailAddress, o.password, o.userType, o.url, o.registeredDate, o.updatedDate, o.lastLoginDate))})
|
||||
def * = userName ~ mailAddress ~ password ~ userType ~ url.? ~ registeredDate ~ updatedDate ~ lastLoginDate.? <> (Account, Account.unapply _)
|
||||
// def ins = userName ~ mailAddress ~ password ~ userType ~ url.? ~ registeredDate ~ updatedDate ~ lastLoginDate.? <> ({ t => Account(None, t._1, t._2, t._3, t._4, t._5, t._6, t._7, t._8)}, { (o: Account) => Some((o.userName, o.mailAddress, o.password, o.userType, o.url, o.registeredDate, o.updatedDate, o.lastLoginDate))})
|
||||
}
|
||||
|
||||
case class Account(
|
||||
userId: Option[Long],
|
||||
userName: String,
|
||||
mailAddress: String,
|
||||
password: String,
|
||||
@@ -32,8 +30,8 @@ class AccountDao {
|
||||
import Database.threadLocalSession
|
||||
|
||||
// def insert(o: Account): Account = Accounts.ins returning Accounts.* insert o
|
||||
def insert(o: Account): Long = Accounts.ins returning Accounts.userId insert o
|
||||
def insert(o: Account): Long = Accounts.* insert o
|
||||
|
||||
def select(key: Long): Option[Account] = Query(Accounts) filter(_.userId is key.bind) firstOption
|
||||
def select(key: String): Option[Account] = Query(Accounts) filter(_.userName is key.bind) firstOption
|
||||
|
||||
}
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
package model
|
||||
|
||||
import scala.slick.driver.H2Driver.simple._
|
||||
|
||||
object Projects extends Table[Project]("PROJECT") {
|
||||
def projectId = column[Long]("PROJECT_ID", O AutoInc)
|
||||
def projectName= column[String]("PROJECT_NAME")
|
||||
def userId = column[Long]("USER_ID")
|
||||
def projectType = column[Int]("PROJECT_TYPE") // TODO should be sealed?
|
||||
def description = column[String]("DESCRIPTION")
|
||||
def defaultBranch = column[String]("DEFAULT_BRANCH")
|
||||
def registeredDate = column[java.sql.Date]("REGISTERED_DATE") // TODO convert java.util.Date later
|
||||
def updatedDate = column[java.sql.Date]("UPDATED_DATE")
|
||||
def lastActivityDate = column[java.sql.Date]("LAST_ACTIVITY_DATE")
|
||||
def * = projectId.? ~ projectName ~ userId ~ projectType ~ description.? ~ defaultBranch ~ registeredDate ~ updatedDate ~ lastActivityDate <> (Project, Project.unapply _)
|
||||
def ins = projectName ~ userId ~ projectType ~ description.? ~ defaultBranch ~ registeredDate ~ updatedDate ~ lastActivityDate <> ({ t => Project(None, t._1, t._2, t._3, t._4, t._5, t._6, t._7, t._8)}, { (o: Project) => Some((o.projectName, o.userId, o.projectType, o.description, o.defaultBranch, o.registeredDate, o.updatedDate, o.lastActivityDate))})
|
||||
}
|
||||
|
||||
case class Project(
|
||||
projectId: Option[Long],
|
||||
projectName: String,
|
||||
userId: Long,
|
||||
projectType: Int,
|
||||
description: Option[String],
|
||||
defaultBranch: String,
|
||||
registeredDate: java.sql.Date,
|
||||
updatedDate: java.sql.Date,
|
||||
lastActivityDate: java.sql.Date
|
||||
)
|
||||
27
src/main/scala/model/Repository.scala
Normal file
27
src/main/scala/model/Repository.scala
Normal file
@@ -0,0 +1,27 @@
|
||||
package model
|
||||
|
||||
import scala.slick.driver.H2Driver.simple._
|
||||
|
||||
object Repositories extends Table[Repository]("REPOSITORY") {
|
||||
def repositoryName= column[String]("REPOSITORY_NAME", O PrimaryKey)
|
||||
def userName = column[String]("USER_NAME", O PrimaryKey)
|
||||
def repositoryType = column[Int]("REPOSITORY_TYPE") // TODO should be sealed?
|
||||
def description = column[String]("DESCRIPTION")
|
||||
def defaultBranch = column[String]("DEFAULT_BRANCH")
|
||||
def registeredDate = column[java.sql.Date]("REGISTERED_DATE") // TODO convert java.util.Date later
|
||||
def updatedDate = column[java.sql.Date]("UPDATED_DATE")
|
||||
def lastActivityDate = column[java.sql.Date]("LAST_ACTIVITY_DATE")
|
||||
def * = repositoryName ~ userName ~ repositoryType ~ description.? ~ defaultBranch ~ registeredDate ~ updatedDate ~ lastActivityDate <> (Repository, Repository.unapply _)
|
||||
// def ins = repositoryName ~ userName ~ repositoryType ~ description.? ~ defaultBranch ~ registeredDate ~ updatedDate ~ lastActivityDate <> ({ t => Project(None, t._1, t._2, t._3, t._4, t._5, t._6, t._7, t._8)}, { (o: Project) => Some((o.projectName, o.userId, o.projectType, o.description, o.defaultBranch, o.registeredDate, o.updatedDate, o.lastActivityDate))})
|
||||
}
|
||||
|
||||
case class Repository(
|
||||
repositoryName: String,
|
||||
userName: String,
|
||||
repositoryType: Int,
|
||||
description: Option[String],
|
||||
defaultBranch: String,
|
||||
registeredDate: java.sql.Date,
|
||||
updatedDate: java.sql.Date,
|
||||
lastActivityDate: java.sql.Date
|
||||
)
|
||||
@@ -6,10 +6,6 @@ import Database.threadLocalSession
|
||||
|
||||
trait AccountService {
|
||||
|
||||
def getAccountByUserId(userId: Long): Option[Account] =
|
||||
Query(Accounts) filter(_.userId is userId.bind) firstOption
|
||||
|
||||
|
||||
def getAccountByUserName(userName: String): Option[Account] =
|
||||
Query(Accounts) filter(_.userName is userName.bind) firstOption
|
||||
|
||||
|
||||
@@ -15,22 +15,21 @@ trait ProjectService { self: AccountService =>
|
||||
* The project is created as public repository at first. Users can modify the project type at the repository settings
|
||||
* page after the project creation to configure the project as the private repository.
|
||||
*
|
||||
* @param projectName the project name
|
||||
* @param repositoryName the repository name
|
||||
* @param userName the user name of the project owner
|
||||
* @param description the project description
|
||||
* @return the created project id
|
||||
*/
|
||||
def createProject(projectName: String, userName: String, description: Option[String]): Long = {
|
||||
def createProject(repositoryName: String, userName: String, description: Option[String]): Long = {
|
||||
// TODO create a git repository also here?
|
||||
|
||||
val currentDate = new java.sql.Date(System.currentTimeMillis)
|
||||
|
||||
Projects.ins returning Projects.projectId insert
|
||||
Project(
|
||||
projectId = None,
|
||||
projectName = projectName,
|
||||
userId = getUserId(userName),
|
||||
projectType = Public,
|
||||
Repositories.* insert
|
||||
Repository(
|
||||
repositoryName = repositoryName,
|
||||
userName = userName,
|
||||
repositoryType = Public,
|
||||
description = description,
|
||||
defaultBranch = "master",
|
||||
registeredDate = currentDate,
|
||||
@@ -39,49 +38,72 @@ trait ProjectService { self: AccountService =>
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the specified user's project list.
|
||||
* Returns the specified user's repository informations.
|
||||
*
|
||||
* @param userName the user name
|
||||
* @return the project list which is sorted in descending order of lastActivityDate.
|
||||
* @param servletContext the servlet context
|
||||
* @return the repository informations which is sorted in descending order of lastActivityDate.
|
||||
*/
|
||||
def getRepositoriesOfUser(userName: String, servletContext: ServletContext): List[RepositoryInfo] = {
|
||||
(Query(Projects) filter(_.userId is getUserId(userName).bind) sortBy(_.lastActivityDate desc) list) map { project =>
|
||||
val repositoryInfo = JGitUtil.getRepositoryInfo(userName, project.projectName, servletContext)
|
||||
RepositoryInfo(repositoryInfo.owner, repositoryInfo.name, repositoryInfo.url, project, repositoryInfo.branchList, repositoryInfo.tags)
|
||||
(Query(Repositories) filter(_.userName is userName.bind) sortBy(_.lastActivityDate desc) list) map { repository =>
|
||||
val repositoryInfo = JGitUtil.getRepositoryInfo(repository.userName, repository.repositoryName, servletContext)
|
||||
RepositoryInfo(repositoryInfo.owner, repositoryInfo.name, repositoryInfo.url, repository, repositoryInfo.branchList, repositoryInfo.tags)
|
||||
}
|
||||
}
|
||||
|
||||
def getRepository(userName: String, projectName: String, servletContext: ServletContext): Option[RepositoryInfo] = {
|
||||
(Query(Projects) filter { project =>
|
||||
(project.userId is getUserId(userName).bind) && (project.projectName is projectName.bind)
|
||||
} firstOption) map { project =>
|
||||
val repositoryInfo = JGitUtil.getRepositoryInfo(userName, project.projectName, servletContext)
|
||||
RepositoryInfo(repositoryInfo.owner, repositoryInfo.name, repositoryInfo.url, project, repositoryInfo.branchList, repositoryInfo.tags)
|
||||
/**
|
||||
* Returns the specified repository information.
|
||||
*
|
||||
* @param userName the user name
|
||||
* @param repositoryName the repository name
|
||||
* @param servletContext the servlet context
|
||||
* @return the repository information
|
||||
*/
|
||||
def getRepository(userName: String, repositoryName: String, servletContext: ServletContext): Option[RepositoryInfo] = {
|
||||
(Query(Repositories) filter { repository =>
|
||||
(repository.userName is userName.bind) && (repository.repositoryName is repositoryName.bind)
|
||||
} firstOption) map { repository =>
|
||||
val repositoryInfo = JGitUtil.getRepositoryInfo(repository.userName, repository.repositoryName, servletContext)
|
||||
RepositoryInfo(repositoryInfo.owner, repositoryInfo.name, repositoryInfo.url, repository, repositoryInfo.branchList, repositoryInfo.tags)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the accessible repository informations for the specified account user.
|
||||
*
|
||||
* @param account the account
|
||||
* @param servletContext the servlet context
|
||||
* @return the repository informations which is sorted in descending order of lastActivityDate.
|
||||
*/
|
||||
def getAccessibleRepositories(account: Option[Account], servletContext: ServletContext): List[RepositoryInfo] = {
|
||||
account match {
|
||||
case Some(x) => {
|
||||
(Query(Projects) sortBy(_.lastActivityDate desc) list) map { project =>
|
||||
(Query(Repositories) sortBy(_.lastActivityDate desc) list) map { repository =>
|
||||
// TODO ユーザ名はジョインして取得する?
|
||||
val repositoryInfo = JGitUtil.getRepositoryInfo(getUserName(project.userId), project.projectName, servletContext)
|
||||
RepositoryInfo(repositoryInfo.owner, repositoryInfo.name, repositoryInfo.url, project, repositoryInfo.branchList, repositoryInfo.tags)
|
||||
val repositoryInfo = JGitUtil.getRepositoryInfo(repository.userName, repository.repositoryName, servletContext)
|
||||
RepositoryInfo(repositoryInfo.owner, repositoryInfo.name, repositoryInfo.url, repository, repositoryInfo.branchList, repositoryInfo.tags)
|
||||
}
|
||||
}
|
||||
case None => {
|
||||
(Query(Projects) filter(_.projectType is Public.bind) sortBy(_.lastActivityDate desc) list) map { project =>
|
||||
(Query(Repositories) filter(_.repositoryType is Public.bind) sortBy(_.lastActivityDate desc) list) map { repository =>
|
||||
// TODO ユーザ名はジョインして取得する?
|
||||
val repositoryInfo = JGitUtil.getRepositoryInfo(getUserName(project.userId), project.projectName, servletContext)
|
||||
RepositoryInfo(repositoryInfo.owner, repositoryInfo.name, repositoryInfo.url, project, repositoryInfo.branchList, repositoryInfo.tags)
|
||||
val repositoryInfo = JGitUtil.getRepositoryInfo(repository.userName, repository.repositoryName, servletContext)
|
||||
RepositoryInfo(repositoryInfo.owner, repositoryInfo.name, repositoryInfo.url, repository, repositoryInfo.branchList, repositoryInfo.tags)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the last activity date of the project.
|
||||
*/
|
||||
def updateLastActivityDate(userName: String, projectName: String): Unit = {
|
||||
|
||||
}
|
||||
|
||||
private def getUserName(userId: Long): String = getAccountByUserId(userId).get.userName
|
||||
|
||||
private def getUserId(userName: String): Long = getAccountByUserName(userName).get.userId.get
|
||||
// private def getUserName(userId: Long): String = getAccountByUserId(userId).get.userName
|
||||
//
|
||||
// private def getUserId(userName: String): Long = getAccountByUserName(userName).get.userId.get
|
||||
|
||||
}
|
||||
|
||||
@@ -90,5 +112,5 @@ object ProjectService {
|
||||
val Public = 0
|
||||
val Private = 1
|
||||
|
||||
case class RepositoryInfo(owner: String, name: String, url: String, project: Project, branchList: List[String], tags: List[util.JGitUtil.TagInfo])
|
||||
case class RepositoryInfo(owner: String, name: String, url: String, repository: Repository, branchList: List[String], tags: List[util.JGitUtil.TagInfo])
|
||||
}
|
||||
@@ -9,8 +9,8 @@
|
||||
/
|
||||
<a href="@path/@repository.owner/@repository.name">@repository.name</a>
|
||||
</div>
|
||||
<div>@repository.project.description</div>
|
||||
<div><span class="description small">Last updated: @repository.project.lastActivityDate</span></div>
|
||||
<div>@repository.repository.description</div>
|
||||
<div><span class="description small">Last updated: @repository.repository.lastActivityDate</span></div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
@@ -26,8 +26,8 @@
|
||||
@repositories.map { repository =>
|
||||
<div class="block">
|
||||
<div class="block-header-2"><a href="@path/@repository.owner/@repository.name">@repository.name</a></div>
|
||||
<div>@repository.project.description</div>
|
||||
<div><span class="description small">Last updated: @repository.project.lastActivityDate</span></div>
|
||||
<div>@repository.repository.description</div>
|
||||
<div><span class="description small">Last updated: @repository.repository.lastActivityDate</span></div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user