Add updated_at field to stash_id's (#5259)

* Add updated_at field to stash_id's
* Only set updated at on stash ids when actually updating in identify

---------
Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
This commit is contained in:
Ian McKenzie
2024-10-30 21:56:16 -07:00
committed by GitHub
parent b1d5dc2a0e
commit 180a0fa8dd
35 changed files with 336 additions and 132 deletions

View File

@@ -275,19 +275,21 @@ type stashIDTable struct {
}
type stashIDRow struct {
StashID null.String `db:"stash_id"`
Endpoint null.String `db:"endpoint"`
StashID null.String `db:"stash_id"`
Endpoint null.String `db:"endpoint"`
UpdatedAt Timestamp `db:"updated_at"`
}
func (r *stashIDRow) resolve() models.StashID {
return models.StashID{
StashID: r.StashID.String,
Endpoint: r.Endpoint.String,
StashID: r.StashID.String,
Endpoint: r.Endpoint.String,
UpdatedAt: r.UpdatedAt.Timestamp,
}
}
func (t *stashIDTable) get(ctx context.Context, id int) ([]models.StashID, error) {
q := dialect.Select("endpoint", "stash_id").From(t.table.table).Where(t.idColumn.Eq(id))
q := dialect.Select("endpoint", "stash_id", "updated_at").From(t.table.table).Where(t.idColumn.Eq(id))
const single = false
var ret []models.StashID
@@ -308,8 +310,8 @@ func (t *stashIDTable) get(ctx context.Context, id int) ([]models.StashID, error
}
func (t *stashIDTable) insertJoin(ctx context.Context, id int, v models.StashID) (sql.Result, error) {
q := dialect.Insert(t.table.table).Cols(t.idColumn.GetCol(), "endpoint", "stash_id").Vals(
goqu.Vals{id, v.Endpoint, v.StashID},
var q = dialect.Insert(t.table.table).Cols(t.idColumn.GetCol(), "endpoint", "stash_id", "updated_at").Vals(
goqu.Vals{id, v.Endpoint, v.StashID, v.UpdatedAt},
)
ret, err := exec(ctx, q)
if err != nil {