Monorepo for Tangled
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

appview/db/repos: calculate the fork count of a repo #3

open opened by willdot.net targeting master from show-repo-fork-counts

Signed-off-by: Will did:plc:dadhhalkfcq3gucaq25hjqon

Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:dadhhalkfcq3gucaq25hjqon/sh.tangled.repo.pull/3mlghsm3vyp22
+40
Diff #5
+39
appview/db/repos.go
··· 301 301 return nil, fmt.Errorf("failed to execute pulls-count query: %w", err) 302 302 } 303 303 304 + // get forks 305 + forksInClause := strings.TrimSuffix(strings.Repeat("?, ", len(repoMap)), ", ") 306 + forkArgs := make([]any, len(repoMap)) 307 + i = 0 308 + for _, r := range repoMap { 309 + forkArgs[i] = r.RepoDid 310 + i++ 311 + } 312 + 313 + forksCountQuery := fmt.Sprintf( 314 + `select source, count(1) from repos where source in (%s) group by source`, 315 + forksInClause, 316 + ) 317 + 318 + rows, err = e.Query(forksCountQuery, forkArgs...) 319 + if err != nil { 320 + return nil, fmt.Errorf("failed to execute fork-count query: %w", err) 321 + } 322 + defer rows.Close() 323 + 324 + for rows.Next() { 325 + var repodid string 326 + var count int 327 + if err := rows.Scan(&repodid, &count); err != nil { 328 + log.Println("err", "err", err) 329 + continue 330 + } 331 + 332 + for _, r := range repoMap { 333 + if r.RepoDid == repodid { 334 + r.RepoStats.ForkCount = count 335 + break 336 + } 337 + } 338 + } 339 + if err = rows.Err(); err != nil { 340 + return nil, fmt.Errorf("failed to execute fork-count query: %w", err) 341 + } 342 + 304 343 var repos []models.Repo 305 344 for _, r := range repoMap { 306 345 repos = append(repos, *r)
+1
appview/models/repo.go
··· 97 97 StarCount int 98 98 IssueCount IssueCount 99 99 PullCount PullCount 100 + ForkCount int 100 101 } 101 102 102 103 type IssueCount struct {

History

6 rounds 0 comments
sign up or login to add to the discussion
1 commit
expand
appview/db/repos: calculate the fork count of a repo
merge conflicts detected
expand
  • appview/db/repos.go:301
  • appview/models/repo.go:97
expand 0 comments
1 commit
expand
appview/db/repos: calculate the fork count of a repo
expand 0 comments
1 commit
expand
appview/db/repos: calculate the fork count of a repo
expand 0 comments
1 commit
expand
appview/db/repos: calculate the fork count of a repo
expand 0 comments
1 commit
expand
appview/db/repos: calculate the fork count of a repo
expand 0 comments
1 commit
expand
appview/db/repos: calculate the fork count of a repo
expand 0 comments