Signed-off-by: Will did:plc:dadhhalkfcq3gucaq25hjqon
+75
Diff
round #0
+39
appview/db/repos.go
+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
+1
appview/models/repo.go
+35
appview/pages/templates/repo/forks.html
+35
appview/pages/templates/repo/forks.html
···
1
+
{{ define "title" }}forks ยท {{ .RepoInfo.FullName }}{{ end }}
2
+
{{ define "repoContent" }}
3
+
<div class="flex flex-col gap-4">
4
+
<h2 class="text-sm uppercase font-bold">Forked by</h2>
5
+
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4">
6
+
{{ range .Forks }}
7
+
{{ $handle := resolve .Did }}
8
+
{{ $name := .Name}}
9
+
<div class="border border-gray-200 dark:border-gray-700 rounded p-4">
10
+
<div class="flex items-center gap-3">
11
+
{{ template "user/fragments/picLink" (list .Did "size-10") }}
12
+
<div class="flex-1 min-w-0">
13
+
<a href="/{{ $handle }}" class="block truncate">{{ $handle }}</a>
14
+
<a href="/{{ $handle }}/{{ $name }}" class="block truncate">{{ $name }}</a>
15
+
<p class="text-sm text-gray-500 dark:text-gray-400">
16
+
forked {{ .Created | relTimeFmt }}
17
+
</p>
18
+
</div>
19
+
</div>
20
+
</div>
21
+
{{ end }}
22
+
{{ if eq .TotalCount 0 }}
23
+
<p class="text-gray-500 dark:text-gray-400 col-span-3">No forks yet.</p>
24
+
{{ end }}
25
+
</div>
26
+
{{ if gt .TotalCount .Page.Limit }}
27
+
{{ template "fragments/pagination" (dict
28
+
"Page" .Page
29
+
"TotalCount" .TotalCount
30
+
"BasePath" (printf "/%s/forks" .RepoInfo.FullName)
31
+
"QueryParams" (queryParams)
32
+
) }}
33
+
{{ end }}
34
+
</div>
35
+
{{ end }}
History
6 rounds
0 comments
willdot.net
submitted
#5
1 commit
expand
collapse
appview/db/repos: calculate the fork count of a repo
Signed-off-by: Will <did:plc:dadhhalkfcq3gucaq25hjqon>
merge conflicts detected
expand
collapse
expand
collapse
- appview/db/repos.go:301
- appview/models/repo.go:97
expand 0 comments
willdot.net
submitted
#4
1 commit
expand
collapse
appview/db/repos: calculate the fork count of a repo
Signed-off-by: Will <did:plc:dadhhalkfcq3gucaq25hjqon>
expand 0 comments
willdot.net
submitted
#3
1 commit
expand
collapse
appview/db/repos: calculate the fork count of a repo
Signed-off-by: Will <did:plc:dadhhalkfcq3gucaq25hjqon>
expand 0 comments
willdot.net
submitted
#2
1 commit
expand
collapse
appview/db/repos: calculate the fork count of a repo
Signed-off-by: Will <did:plc:dadhhalkfcq3gucaq25hjqon>
expand 0 comments
willdot.net
submitted
#1
1 commit
expand
collapse
appview/db/repos: calculate the fork count of a repo
Signed-off-by: Will <did:plc:dadhhalkfcq3gucaq25hjqon>
expand 0 comments
willdot.net
submitted
#0
1 commit
expand
collapse
appview/db/repos: calculate the fork count of a repo
Signed-off-by: Will <did:plc:dadhhalkfcq3gucaq25hjqon>