mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-31 11:52:10 +00:00
fix: use better code to group UID and stopwatches
- Instead of having code that relied on the result being sorted (which wasn't specified in the query and therefore not safe to assume so). Use a map where it doesn't care if the result that we get from the database is sorted or not. - Added unit test.
This commit is contained in:
parent
1e1b162cbe
commit
e4eb82b738
4 changed files with 58 additions and 22 deletions
|
@ -90,8 +90,8 @@ loop:
|
|||
return
|
||||
}
|
||||
|
||||
for _, userStopwatches := range usersStopwatches {
|
||||
apiSWs, err := convert.ToStopWatches(ctx, userStopwatches.StopWatches)
|
||||
for uid, stopwatches := range usersStopwatches {
|
||||
apiSWs, err := convert.ToStopWatches(ctx, stopwatches)
|
||||
if err != nil {
|
||||
if !issues_model.IsErrIssueNotExist(err) {
|
||||
log.Error("Unable to APIFormat stopwatches: %v", err)
|
||||
|
@ -103,7 +103,7 @@ loop:
|
|||
log.Error("Unable to marshal stopwatches: %v", err)
|
||||
continue
|
||||
}
|
||||
m.SendMessage(userStopwatches.UserID, &Event{
|
||||
m.SendMessage(uid, &Event{
|
||||
Name: "stopwatches",
|
||||
Data: string(dataBs),
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue