package consumer import ( "context" "encoding/json" "fmt" "git.0x7f.app/WOJ/woj-server/internal/e" "git.0x7f.app/WOJ/woj-server/internal/model" "github.com/hibiken/asynq" "github.com/jackc/pgtype" "go.uber.org/zap" ) func (h *handler) ProblemUpdate(_ context.Context, t *asynq.Task) error { p := new(model.ProblemUpdatePayload) if err := json.Unmarshal(t.Payload(), &p); err != nil { return fmt.Errorf("json.Unmarshal failed: %v: %w", err, asynq.SkipRetry) } if p.Status != e.Success { h.log.Warn("RunnerError", zap.Any("payload", p)) } status := h.problemService.UpdateVersion( p.ProblemVersionID, map[string]interface{}{ "Context": pgtype.JSON{ Bytes: []byte(p.Context), Status: pgtype.Present, }, "IsEnabled": p.Status == e.Success, }, ) if status != e.Success { return fmt.Errorf(status.String()) } return nil }