diff --git a/appview/accountmigration/accountmigration.go b/appview/accountmigration/accountmigration.go index 71b2edc1..561536e3 100644 --- a/appview/accountmigration/accountmigration.go +++ b/appview/accountmigration/accountmigration.go @@ -9,6 +9,7 @@ import ( "slices" "strconv" "strings" + "time" "github.com/bluesky-social/indigo/atproto/syntax" "github.com/go-chi/chi/v5" @@ -101,16 +102,18 @@ func (s *AccountMigration) migratePage(w http.ResponseWriter, r *http.Request) { } type githubUserRepo struct { - Name string `json:"name"` - CloneUrl string `json:"clone_url"` - DefaultBranch string `json:"default_branch"` - Description string `json:"description"` - Homepage string `json:"homepage"` - Topics []string `json:"topics"` - Fork bool `json:"fork"` - Private bool `json:"private"` - Archived bool `json:"archived"` - Disabled bool `json:"disabled"` + Name string `json:"name"` + CloneUrl string `json:"clone_url"` + Stars int `json:"stargazers_count"` + PushedAt time.Time `json:"pushed_at"` + DefaultBranch string `json:"default_branch"` + Description string `json:"description"` + Homepage string `json:"homepage"` + Topics []string `json:"topics"` + Fork bool `json:"fork"` + Private bool `json:"private"` + Archived bool `json:"archived"` + Disabled bool `json:"disabled"` } func (s *AccountMigration) listGitHubRepos(w http.ResponseWriter, r *http.Request) { @@ -180,10 +183,20 @@ func (s *AccountMigration) listGitHubRepos(w http.ResponseWriter, r *http.Reques Description: ghrepo.Description, Website: ghrepo.Homepage, Topics: ghrepo.Topics, + Stars: ghrepo.Stars, + PushedAt: ghrepo.PushedAt, Selected: !migrated, }) } + // sort by stars desc, then most recently pushed + slices.SortFunc(importRepos, func(a, b pages.RepoImportParams) int { + if a.Stars != b.Stars { + return b.Stars - a.Stars + } + return b.PushedAt.Compare(a.PushedAt) + }) + if err := s.pages.AccountMigrateRepoListFragment(w, pages.AccountMigrateRepoListParams{ Repos: importRepos, Knots: knots, diff --git a/appview/pages/pages.go b/appview/pages/pages.go index 1bf235d0..8a0fd5ac 100644 --- a/appview/pages/pages.go +++ b/appview/pages/pages.go @@ -2076,7 +2076,10 @@ type RepoImportParams struct { Website string Topics []string - Selected bool + // metadata used on bulk-import view + Stars int + PushedAt time.Time // last push; used for sorting, not rendered yet + Selected bool // repos that has been already migrateded will be deselected } func (p *Pages) AccountMigrateFromGitHub(w io.Writer, params AccountMigrateFromGitHubParams) error { diff --git a/appview/pages/templates/account/migrate/fragments/repoList.html b/appview/pages/templates/account/migrate/fragments/repoList.html index ec8d0987..efe2a17c 100644 --- a/appview/pages/templates/account/migrate/fragments/repoList.html +++ b/appview/pages/templates/account/migrate/fragments/repoList.html @@ -14,6 +14,12 @@ {{ $repo.Name }} + {{ if gt .Stars 0 }} +
+ {{ i "star" "size-3 fill-current" }} + {{ scaleFmt .Stars }} +
+ {{ end }}