@@ -11,6 +11,7 @@ import (
1111 "net/http"
1212 "path"
1313 "sort"
14+ "strconv"
1415 "strings"
1516 "time"
1617
@@ -65,15 +66,9 @@ func getShuffledOfficialProjects(c *RequestContext) ([]templates.Project, error)
6566
6667 defer c .Perf .StartBlock ("PROJECT" , "Grouping and sorting" ).End ()
6768
68- var handmadeHero hmndata.ProjectAndStuff
6969 var featuredProjects []hmndata.ProjectAndStuff
7070 var restProjects []hmndata.ProjectAndStuff
7171 for _ , p := range official {
72- if p .Project .Slug == "hero" {
73- // NOTE(asaf): Handmade Hero gets special treatment. Must always be first in the list.
74- handmadeHero = p
75- continue
76- }
7772 if p .Project .Featured {
7873 featuredProjects = append (featuredProjects , p )
7974 } else {
@@ -82,17 +77,13 @@ func getShuffledOfficialProjects(c *RequestContext) ([]templates.Project, error)
8277 }
8378
8479 sort .Slice (featuredProjects , func (i , j int ) bool {
85- return featuredProjects [i ].Project .AllLastUpdated . After ( featuredProjects [j ].Project .AllLastUpdated )
80+ return featuredProjects [i ].Project .SortScore > featuredProjects [j ].Project .SortScore
8681 })
8782 sort .Slice (restProjects , func (i , j int ) bool {
8883 return restProjects [i ].Project .AllLastUpdated .After (restProjects [j ].Project .AllLastUpdated )
8984 })
9085
91- projects := make ([]templates.Project , 0 , 1 + len (featuredProjects )+ len (restProjects ))
92- if handmadeHero .Project .ID != 0 {
93- // NOTE(asaf): As mentioned above, inserting HMH first.
94- projects = append (projects , templates .ProjectAndStuffToTemplate (& handmadeHero ))
95- }
86+ projects := make ([]templates.Project , 0 , len (featuredProjects )+ len (restProjects ))
9687 for _ , p := range featuredProjects {
9788 projects = append (projects , templates .ProjectAndStuffToTemplate (& p ))
9889 }
@@ -662,6 +653,7 @@ type ProjectPayload struct {
662653 Tag string
663654 JamParticipationSlugs []string
664655 JamHidden bool
656+ SortScore int
665657
666658 Slug string
667659 SlugAliases string // comma-separated
@@ -749,6 +741,9 @@ func ParseProjectEditForm(c *RequestContext) ProjectEditFormResult {
749741 jamParticipationSlugs := c .Req .Form ["jam_participation" ]
750742 jamHidden := c .Req .Form .Has ("jam_hidden" )
751743
744+ sortScoreStr := c .Req .Form .Get ("sort_score" )
745+ sortScore , _ := strconv .Atoi (sortScoreStr )
746+
752747 res .Payload = ProjectPayload {
753748 Name : projectName ,
754749 Blurb : shortDesc ,
@@ -767,6 +762,7 @@ func ParseProjectEditForm(c *RequestContext) ProjectEditFormResult {
767762 SlugAliases : slugAliases ,
768763 Personal : ! official ,
769764 Featured : featured ,
765+ SortScore : sortScore ,
770766 }
771767
772768 return res
@@ -860,7 +856,8 @@ func updateProject(ctx context.Context, tx pgx.Tx, user *models.User, payload *P
860856 personal = $4,
861857 hidden = $5,
862858 slug_aliases = $6,
863- jam_hidden = $7
859+ jam_hidden = $7,
860+ sort_score = $8
864861 WHERE
865862 id = $1
866863 ` ,
@@ -871,6 +868,7 @@ func updateProject(ctx context.Context, tx pgx.Tx, user *models.User, payload *P
871868 payload .Hidden ,
872869 slugAliases ,
873870 payload .JamHidden ,
871+ payload .SortScore ,
874872 )
875873 if err != nil {
876874 return oops .New (err , "Failed to update project with admin fields" )
0 commit comments