parent
a5c2b337f4
commit
a3fb38821a
|
@ -7,7 +7,6 @@ import (
|
|||
|
||||
"github.com/ThreeDotsLabs/watermill"
|
||||
"github.com/ThreeDotsLabs/watermill/message"
|
||||
"github.com/stephenafamo/bob"
|
||||
"github.com/tigorlazuardi/redmage/models"
|
||||
"github.com/tigorlazuardi/redmage/pkg/errs"
|
||||
"github.com/tigorlazuardi/redmage/pkg/log"
|
||||
|
@ -96,13 +95,12 @@ func (api *API) PubsubStartDownloadSubreddit(ctx context.Context, params PubsubS
|
|||
return errs.Wrapw(err, "failed to verify subreddit existence", "params", params)
|
||||
}
|
||||
|
||||
err = api.withTransaction(ctx, func(exec bob.Executor) error {
|
||||
_, err := api.scheduleSet(ctx, exec, ScheduleSetParams{
|
||||
_, errSchedule := api.scheduleSet(ctx, api.db, ScheduleSetParams{
|
||||
Subreddit: subreddit.Name,
|
||||
Status: ScheduleStatusEnqueued,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
if errSchedule != nil {
|
||||
log.New(ctx).Err(errSchedule).Error("failed to set schedule status", "subreddit", subreddit.Name, "status", ScheduleStatusEnqueued.String())
|
||||
}
|
||||
|
||||
payload, err := json.Marshal(subreddit)
|
||||
|
@ -114,8 +112,5 @@ func (api *API) PubsubStartDownloadSubreddit(ctx context.Context, params PubsubS
|
|||
if err != nil {
|
||||
return errs.Wrapw(err, "failed to enqueue reddit download", "params", params)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue