Skip to content

Commit

Permalink
feat: change history data field
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-ding committed Jul 15, 2024
1 parent f37a8ee commit b2c4b69
Show file tree
Hide file tree
Showing 15 changed files with 178 additions and 142 deletions.
9 changes: 5 additions & 4 deletions db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,11 +382,11 @@ func (c *Client) SetDefaultStorageByName(name string) error {

func (c *Client) SaveHistoryRecord(h ent.History) (*ent.History, error) {
return c.ent.History.Create().SetSeriesID(h.SeriesID).SetEpisodeID(h.EpisodeID).SetDate(time.Now()).
SetCompleted(h.Completed).SetTargetDir(h.TargetDir).SetSourceTitle(h.SourceTitle).SetSaved(h.Saved).Save(context.TODO())
SetStatus(h.Status).SetTargetDir(h.TargetDir).SetSourceTitle(h.SourceTitle).SetSaved(h.Saved).Save(context.TODO())
}

func (c *Client) SetHistoryComplete(id int) error {
return c.ent.History.Update().Where(history.ID(id)).SetCompleted(true).Exec(context.TODO())
func (c *Client) SetHistoryStatus(id int, status history.Status) error {
return c.ent.History.Update().Where(history.ID(id)).SetStatus(status).Exec(context.TODO())
}

func (c *Client) GetHistories() ent.Histories {
Expand All @@ -398,7 +398,8 @@ func (c *Client) GetHistories() ent.Histories {
}

func (c *Client) GetRunningHistories() ent.Histories {
h, err := c.ent.History.Query().Where(history.Completed(false)).All(context.TODO())
h, err := c.ent.History.Query().Where(history.Or(history.StatusEQ(history.StatusRunning),
history.StatusEQ(history.StatusUploading))).All(context.TODO())
if err != nil {
return nil
}
Expand Down
20 changes: 9 additions & 11 deletions ent/history.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 31 additions & 9 deletions ent/history/history.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 16 additions & 11 deletions ent/history/where.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 13 additions & 26 deletions ent/history_create.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 44 additions & 18 deletions ent/history_update.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ent/migrate/schema.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b2c4b69

Please sign in to comment.