Monorepo for Tangled

appview/models: add helper func to count total comments on a PR

Signed-off-by: oppiliappan <me@oppi.li>

authored by oppi.li and committed by tangled.org 6a123c31 525aa795

+12 -32
+7 -17
appview/models/pull.go
··· 171 return syntax.ATURI(p.CommentAt) 172 } 173 174 - // func (p *PullComment) AsRecord() tangled.RepoPullComment { 175 - // mentions := make([]string, len(p.Mentions)) 176 - // for i, did := range p.Mentions { 177 - // mentions[i] = string(did) 178 - // } 179 - // references := make([]string, len(p.References)) 180 - // for i, uri := range p.References { 181 - // references[i] = string(uri) 182 - // } 183 - // return tangled.RepoPullComment{ 184 - // Pull: p.PullAt, 185 - // Body: p.Body, 186 - // Mentions: mentions, 187 - // References: references, 188 - // CreatedAt: p.Created.Format(time.RFC3339), 189 - // } 190 - // } 191 192 func (p *Pull) LastRoundNumber() int { 193 return len(p.Submissions) - 1
··· 171 return syntax.ATURI(p.CommentAt) 172 } 173 174 + func (p *Pull) TotalComments() int { 175 + total := 0 176 + for _, s := range p.Submissions { 177 + total += len(s.Comments) 178 + } 179 + return total 180 + } 181 182 func (p *Pull) LastRoundNumber() int { 183 return len(p.Submissions) - 1
+2 -3
appview/pages/templates/repo/pulls/fragments/summarizedPullHeader.html
··· 15 16 <div class="flex-shrink-0 flex items-center gap-2"> 17 {{ $latestRound := .LastRoundNumber }} 18 - {{ $lastSubmission := index .Submissions $latestRound }} 19 - {{ $commentCount := len $lastSubmission.Comments }} 20 {{ if and $pipeline $pipeline.Id }} 21 - {{ template "repo/pipelines/fragments/pipelineSymbol" $pipeline }} 22 <span class="before:content-['·'] before:select-none text-gray-500 dark:text-gray-400"></span> 23 {{ end }} 24 <span>
··· 15 16 <div class="flex-shrink-0 flex items-center gap-2"> 17 {{ $latestRound := .LastRoundNumber }} 18 + {{ $commentCount := .TotalComments }} 19 {{ if and $pipeline $pipeline.Id }} 20 + {{ template "repo/pipelines/fragments/pipelineSymbol" (dict "Pipeline" $pipeline "ShortSummary" true) }} 21 <span class="before:content-['·'] before:select-none text-gray-500 dark:text-gray-400"></span> 22 {{ end }} 23 <span>
+3 -12
appview/pages/templates/repo/pulls/pulls.html
··· 112 {{ template "repo/fragments/time" .Created }} 113 </span> 114 115 - 116 - {{ $latestRound := .LastRoundNumber }} 117 - {{ $lastSubmission := index .Submissions $latestRound }} 118 - 119 <span class="before:content-['·']"> 120 - {{ $commentCount := len $lastSubmission.Comments }} 121 - {{ $s := "s" }} 122 - {{ if eq $commentCount 1 }} 123 - {{ $s = "" }} 124 - {{ end }} 125 - 126 - {{ len $lastSubmission.Comments}} comment{{$s}} 127 </span> 128 129 <span class="before:content-['·']"> ··· 136 {{ $pipeline := index $.Pipelines .LatestSha }} 137 {{ if and $pipeline $pipeline.Id }} 138 <span class="before:content-['·']"></span> 139 - {{ template "repo/pipelines/fragments/pipelineSymbol" $pipeline }} 140 {{ end }} 141 142 {{ $state := .Labels }}
··· 112 {{ template "repo/fragments/time" .Created }} 113 </span> 114 115 <span class="before:content-['·']"> 116 + {{ $commentCount := .TotalComments }} 117 + {{ $commentCount }} comment{{ if ne $commentCount 1 }}s{{ end }} 118 </span> 119 120 <span class="before:content-['·']"> ··· 127 {{ $pipeline := index $.Pipelines .LatestSha }} 128 {{ if and $pipeline $pipeline.Id }} 129 <span class="before:content-['·']"></span> 130 + {{ template "repo/pipelines/fragments/pipelineSymbol" (dict "Pipeline" $pipeline "ShortSummary" true) }} 131 {{ end }} 132 133 {{ $state := .Labels }}