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