From 44f7d98ef537449237c30e0664bac34ff8d74553 Mon Sep 17 00:00:00 2001 From: Akshay Date: Mon, 10 Mar 2025 18:21:53 +0000 Subject: [PATCH] improve issue styling, add comment counts --- appview/db/issues.go | 31 ++++++- appview/pages/templates/fragments/star.html | 2 +- appview/pages/templates/layouts/repobase.html | 22 ++--- appview/pages/templates/repo/index.html | 4 +- .../pages/templates/repo/issues/issues.html | 86 +++++++++++-------- appview/pages/templates/repo/log.html | 2 +- appview/pages/templates/settings.html | 4 +- appview/pages/templates/timeline.html | 6 +- appview/pages/templates/user/profile.html | 8 +- flake.nix | 45 +++++++--- input.css | 10 +-- tailwind.config.js | 18 ++-- 12 files changed, 152 insertions(+), 86 deletions(-) diff --git a/appview/db/issues.go b/appview/db/issues.go index c6447330..66ce49ba 100644 --- a/appview/db/issues.go +++ b/appview/db/issues.go @@ -16,6 +16,12 @@ type Issue struct { Title string Body string Open bool + Metadata *IssueMetadata +} + +type IssueMetadata struct { + CommentCount int + // labels, assignee etc. } type Comment struct { @@ -93,7 +99,26 @@ func GetIssueOwnerDid(e Execer, repoAt syntax.ATURI, issueId int) (string, error func GetIssues(e Execer, repoAt syntax.ATURI) ([]Issue, error) { var issues []Issue - rows, err := e.Query(`select owner_did, issue_id, created, title, body, open from issues where repo_at = ? order by created desc`, repoAt) + rows, err := e.Query( + `select + i.owner_did, + i.issue_id, + i.created, + i.title, + i.body, + i.open, + count(c.id) + from + issues i + left join + comments c on i.repo_at = c.repo_at and i.issue_id = c.issue_id + where + i.repo_at = ? + group by + i.id, i.owner_did, i.issue_id, i.created, i.title, i.body, i.open + order by + i.created desc`, + repoAt) if err != nil { return nil, err } @@ -102,7 +127,8 @@ func GetIssues(e Execer, repoAt syntax.ATURI) ([]Issue, error) { for rows.Next() { var issue Issue var createdAt string - err := rows.Scan(&issue.OwnerDid, &issue.IssueId, &createdAt, &issue.Title, &issue.Body, &issue.Open) + var metadata IssueMetadata + err := rows.Scan(&issue.OwnerDid, &issue.IssueId, &createdAt, &issue.Title, &issue.Body, &issue.Open, &metadata.CommentCount) if err != nil { return nil, err } @@ -112,6 +138,7 @@ func GetIssues(e Execer, repoAt syntax.ATURI) ([]Issue, error) { return nil, err } issue.Created = &createdTime + issue.Metadata = &metadata issues = append(issues, issue) } diff --git a/appview/pages/templates/fragments/star.html b/appview/pages/templates/fragments/star.html index b14acc96..12041dfc 100644 --- a/appview/pages/templates/fragments/star.html +++ b/appview/pages/templates/fragments/star.html @@ -1,6 +1,6 @@ {{ define "fragments/star" }}