mirror of
https://github.com/muety/wakapi.git
synced 2023-08-10 21:12:56 +03:00
fix: concurrency bugs with summary aggregation and user counting
This commit is contained in:
@@ -91,7 +91,8 @@ func (srv *AggregationService) AggregateSummaries(userIds datastructure.Set[stri
|
||||
jobs := make(chan *AggregationJob)
|
||||
defer close(jobs)
|
||||
go func() {
|
||||
for job := range jobs {
|
||||
for jobRef := range jobs {
|
||||
job := *jobRef
|
||||
if err := srv.queueWorkers.Dispatch(func() {
|
||||
srv.process(job)
|
||||
}); err != nil {
|
||||
@@ -122,7 +123,7 @@ func (srv *AggregationService) AggregateSummaries(userIds datastructure.Set[stri
|
||||
return nil
|
||||
}
|
||||
|
||||
func (srv *AggregationService) process(job *AggregationJob) {
|
||||
func (srv *AggregationService) process(job AggregationJob) {
|
||||
if summary, err := srv.summaryService.Summarize(job.From, job.To, &models.User{ID: job.UserID}, nil); err != nil {
|
||||
config.Log().Error("failed to generate summary (%v, %v, %s) - %v", job.From, job.To, job.UserID, err)
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user