Show ratings
This commit is contained in:
parent
513da92150
commit
71f1f6708b
@ -30,6 +30,7 @@ type transcript struct {
|
|||||||
TicketId int `json:"ticket_id"`
|
TicketId int `json:"ticket_id"`
|
||||||
Username string `json:"username"`
|
Username string `json:"username"`
|
||||||
CloseReason *string `json:"close_reason"`
|
CloseReason *string `json:"close_reason"`
|
||||||
|
Rating *uint8 `json:"rating"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func ListTranscripts(ctx *gin.Context) {
|
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))
|
transcripts := make([]transcript, len(tickets))
|
||||||
for i, ticket := range tickets {
|
for i, ticket := range tickets {
|
||||||
|
var rating *uint8
|
||||||
|
if v, ok := ratings[ticket.Id]; ok {
|
||||||
|
rating = &v
|
||||||
|
}
|
||||||
|
|
||||||
transcripts[i] = transcript{
|
transcripts[i] = transcript{
|
||||||
TicketId: ticket.Id,
|
TicketId: ticket.Id,
|
||||||
Username: usernames[ticket.UserId],
|
Username: usernames[ticket.UserId],
|
||||||
CloseReason: ticket.CloseReason,
|
CloseReason: ticket.CloseReason,
|
||||||
|
Rating: rating,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,7 +148,6 @@ func getTickets(guildId uint64, before, after int) ([]database.TicketWithCloseRe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status := http.StatusOK
|
status := http.StatusOK
|
||||||
if err != nil {
|
if err != nil {
|
||||||
status = http.StatusInternalServerError
|
status = http.StatusInternalServerError
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>Ticket ID</th>
|
<th>Ticket ID</th>
|
||||||
<th>Username</th>
|
<th>Username</th>
|
||||||
|
<th>Rating</th>
|
||||||
<th class="reason">Close Reason</th>
|
<th class="reason">Close Reason</th>
|
||||||
<th>Transcript</th>
|
<th>Transcript</th>
|
||||||
</tr>
|
</tr>
|
||||||
@ -46,6 +47,13 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>{transcript.ticket_id}</td>
|
<td>{transcript.ticket_id}</td>
|
||||||
<td>{transcript.username}</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 class="reason">{transcript.close_reason || 'No reason specified'}</td>
|
||||||
<td>
|
<td>
|
||||||
<Navigate to="{`/manage/${guildId}/transcripts/view/${transcript.ticket_id}`}" styles="link">
|
<Navigate to="{`/manage/${guildId}/transcripts/view/${transcript.ticket_id}`}" styles="link">
|
||||||
|
2
go.mod
2
go.mod
@ -6,7 +6,7 @@ require (
|
|||||||
github.com/BurntSushi/toml v0.3.1
|
github.com/BurntSushi/toml v0.3.1
|
||||||
github.com/TicketsBot/archiverclient v0.0.0-20210220155137-a562b2f1bbbb
|
github.com/TicketsBot/archiverclient v0.0.0-20210220155137-a562b2f1bbbb
|
||||||
github.com/TicketsBot/common v0.0.0-20210727134627-35eb7ed03a44
|
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/TicketsBot/worker v0.0.0-20210727130432-3df3cd1246a3
|
||||||
github.com/apex/log v1.1.2
|
github.com/apex/log v1.1.2
|
||||||
github.com/boj/redistore v0.0.0-20180917114910-cd5dcc76aeff // indirect
|
github.com/boj/redistore v0.0.0-20180917114910-cd5dcc76aeff // indirect
|
||||||
|
Loading…
x
Reference in New Issue
Block a user