some initial work on #1234
This commit is contained in:
parent
4f7199b5ff
commit
fa8c657005
2 changed files with 26 additions and 46 deletions
|
@ -17,64 +17,44 @@ import (
|
||||||
|
|
||||||
func ShowIndex(c *gin.Context) {
|
func ShowIndex(c *gin.Context) {
|
||||||
db := context.Database(c)
|
db := context.Database(c)
|
||||||
|
remote := context.Remote(c)
|
||||||
user := session.User(c)
|
user := session.User(c)
|
||||||
if user == nil {
|
if user == nil {
|
||||||
c.HTML(200, "login.html", gin.H{})
|
c.Redirect(http.StatusSeeOther, "/login")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
repos, err := model.GetRepoList(db, user)
|
var err error
|
||||||
|
var repos []*model.RepoLite
|
||||||
|
|
||||||
|
// get the repository list from the cache
|
||||||
|
reposv, ok := c.Get("repos")
|
||||||
|
if ok {
|
||||||
|
repos = reposv.([]*model.RepoLite)
|
||||||
|
} else {
|
||||||
|
repos, err = remote.Repos(user)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("Failure to get remote repositories for %s. %s.",
|
||||||
|
user.Login, err)
|
||||||
|
} else {
|
||||||
|
c.Set("repos", repos)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// for each repository in the remote system we get
|
||||||
|
// the intersection of those repostiories in Drone
|
||||||
|
repos_, err := model.GetRepoListOf(db, repos)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Errorf("Failure to get repository list for %s. %s.",
|
||||||
|
user.Login, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
c.HTML(200, "repos.html", gin.H{
|
c.HTML(200, "repos.html", gin.H{
|
||||||
"User": user,
|
"User": user,
|
||||||
"Repos": repos,
|
"Repos": repos_,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// func ShowIndex(c *gin.Context) {
|
|
||||||
// db := context.Database(c)
|
|
||||||
// remote := context.Remote(c)
|
|
||||||
// user := session.User(c)
|
|
||||||
// if user == nil {
|
|
||||||
// c.Redirect(http.StatusSeeOther, "/login")
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
|
|
||||||
// var err error
|
|
||||||
// var repos []*model.RepoLite
|
|
||||||
|
|
||||||
// // get the repository list from the cache
|
|
||||||
// reposv, ok := c.Get("repos")
|
|
||||||
// if ok {
|
|
||||||
// repos = reposv.([]*model.RepoLite)
|
|
||||||
// } else {
|
|
||||||
// println("GETTING REMOTE REPOS")
|
|
||||||
// repos, err = remote.Repos(user)
|
|
||||||
// if err != nil {
|
|
||||||
// log.Errorf("Failure to get remote repositories for %s. %s.",
|
|
||||||
// user.Login, err)
|
|
||||||
// } else {
|
|
||||||
// c.Set("repos", repos)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // for each repository in the remote system we get
|
|
||||||
// // the intersection of those repostiories in Drone
|
|
||||||
// repos_, err := model.GetRepoListOf(db, repos)
|
|
||||||
// if err != nil {
|
|
||||||
// log.Errorf("Failure to get repository list for %s. %s.",
|
|
||||||
// user.Login, err)
|
|
||||||
// }
|
|
||||||
|
|
||||||
// c.HTML(200, "repos.html", gin.H{
|
|
||||||
// "User": user,
|
|
||||||
// "Repos": repos_,
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
|
|
||||||
func ShowLogin(c *gin.Context) {
|
func ShowLogin(c *gin.Context) {
|
||||||
c.HTML(200, "login.html", gin.H{"Error": c.Query("error")})
|
c.HTML(200, "login.html", gin.H{"Error": c.Query("error")})
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ func GetRepoListOf(db meddler.DB, listof []*RepoLite) ([]*Repo, error) {
|
||||||
qs[i] = "?"
|
qs[i] = "?"
|
||||||
in[i] = repo.FullName
|
in[i] = repo.FullName
|
||||||
}
|
}
|
||||||
var stmt = "SELECT * FROM repos WHERE repo_full_name IN (" + strings.Join(qs, ",") + ")"
|
var stmt = "SELECT * FROM repos WHERE repo_full_name IN (" + strings.Join(qs, ",") + ") ORDER BY repo_name"
|
||||||
var err = meddler.QueryAll(db, &repos, database.Rebind(stmt), in...)
|
var err = meddler.QueryAll(db, &repos, database.Rebind(stmt), in...)
|
||||||
return repos, err
|
return repos, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue