Add list-public-repositories API (#2529)

This commit is contained in:
onukura
2020-08-29 15:32:00 +09:00
committed by GitHub
parent a143683d7f
commit b81ce41d51
2 changed files with 22 additions and 3 deletions

View File

@@ -54,11 +54,15 @@ trait ApiRepositoryControllerBase extends ControllerBase {
})
}
/*
/**
* iv. List all public repositories
* https://developer.github.com/v3/repos/#list-all-public-repositories
* Not implemented
* https://developer.github.com/v3/repos/#list-public-repositories
*/
get("/api/v3/repositories") {
JsonFormat(getPublicRepositories().map { r =>
ApiRepository(r, getAccountByUserName(r.owner).get)
})
}
/*
* v. Create

View File

@@ -380,6 +380,21 @@ trait RepositoryService {
.list
}
/**
* Returns the all public repositories.
*
* @return the repository information list
*/
def getPublicRepositories(withoutPhysicalInfo: Boolean = false)(implicit s: Session): List[RepositoryInfo] = {
Repositories
.filter { t1 =>
t1.isPrivate === false.bind
}
.sortBy(_.lastActivityDate desc)
.list
.map(createRepositoryInfo(_, withoutPhysicalInfo))
}
/**
* Returns the list of repositories which are owned by the specified user.
* This list includes group repositories if the specified user is a member of the group.