Show ratings

This commit is contained in:
rxdn 2021-07-28 16:17:15 +01:00
parent 513da92150
commit 71f1f6708b
3 changed files with 28 additions and 2 deletions

View File

@ -30,6 +30,7 @@ type transcript struct {
TicketId int `json:"ticket_id"`
Username string `json:"username"`
CloseReason *string `json:"close_reason"`
Rating *uint8 `json:"rating"`
}
func ListTranscripts(ctx *gin.Context) {
@ -89,12 +90,30 @@ func ListTranscripts(ctx *gin.Context) {
}
}
// Get ratings
ticketIds := make([]int, len(tickets))
for i, ticket := range tickets {
ticketIds[i] = ticket.Id
}
ratings, err := dbclient.Client.ServiceRatings.GetMulti(guildId, ticketIds)
if err != nil {
ctx.JSON(500, utils.ErrorJson(err))
return
}
transcripts := make([]transcript, len(tickets))
for i, ticket := range tickets {
var rating *uint8
if v, ok := ratings[ticket.Id]; ok {
rating = &v
}
transcripts[i] = transcript{
TicketId: ticket.Id,
Username: usernames[ticket.UserId],
CloseReason: ticket.CloseReason,
Rating: rating,
}
}
@ -129,7 +148,6 @@ func getTickets(guildId uint64, before, after int) ([]database.TicketWithCloseRe
}
}
status := http.StatusOK
if err != nil {
status = http.StatusInternalServerError

View File

@ -37,6 +37,7 @@
<tr>
<th>Ticket ID</th>
<th>Username</th>
<th>Rating</th>
<th class="reason">Close Reason</th>
<th>Transcript</th>
</tr>
@ -46,6 +47,13 @@
<tr>
<td>{transcript.ticket_id}</td>
<td>{transcript.username}</td>
<td>
{#if transcript.rating}
{transcript.rating}
{:else}
No rating
{/if}
</td>
<td class="reason">{transcript.close_reason || 'No reason specified'}</td>
<td>
<Navigate to="{`/manage/${guildId}/transcripts/view/${transcript.ticket_id}`}" styles="link">

2
go.mod
View File

@ -6,7 +6,7 @@ require (
github.com/BurntSushi/toml v0.3.1
github.com/TicketsBot/archiverclient v0.0.0-20210220155137-a562b2f1bbbb
github.com/TicketsBot/common v0.0.0-20210727134627-35eb7ed03a44
github.com/TicketsBot/database v0.0.0-20210728122440-a0cf03a651c8
github.com/TicketsBot/database v0.0.0-20210728151044-f205b228de2d
github.com/TicketsBot/worker v0.0.0-20210727130432-3df3cd1246a3
github.com/apex/log v1.1.2
github.com/boj/redistore v0.0.0-20180917114910-cd5dcc76aeff // indirect