Sort personal projects by recency instead of randomly
This commit is contained in:
parent
b41fb365cf
commit
8f560de2b6
|
@ -114,9 +114,11 @@ func ProjectIndex(c *RequestContext) ResponseData {
|
||||||
return c.ErrorResponse(http.StatusInternalServerError, oops.New(err, "failed to fetch personal projects"))
|
return c.ErrorResponse(http.StatusInternalServerError, oops.New(err, "failed to fetch personal projects"))
|
||||||
}
|
}
|
||||||
|
|
||||||
randSeed := now.YearDay()
|
sort.Slice(projects, func(i, j int) bool {
|
||||||
random := rand.New(rand.NewSource(int64(randSeed)))
|
p1 := projects[i].Project
|
||||||
random.Shuffle(len(projects), func(i, j int) { projects[i], projects[j] = projects[j], projects[i] })
|
p2 := projects[j].Project
|
||||||
|
return p2.AllLastUpdated.Before(p1.AllLastUpdated) // sort backwards - recent first
|
||||||
|
})
|
||||||
|
|
||||||
for i, p := range projects {
|
for i, p := range projects {
|
||||||
if i >= maxPersonalProjects {
|
if i >= maxPersonalProjects {
|
||||||
|
|
Loading…
Reference in New Issue