mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 04:14:39 +03:00
Fix incorrectly formatted timestamps (#2918)
* Update updated_at when adding file to object * Use models.SQLTimestamp for timestamps * Add data massage to fix incorrect timestamps
This commit is contained in:
@@ -5,7 +5,6 @@ import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/stashapp/stash/pkg/file"
|
||||
@@ -28,14 +27,14 @@ const (
|
||||
)
|
||||
|
||||
type imageRow struct {
|
||||
ID int `db:"id" goqu:"skipinsert"`
|
||||
Title zero.String `db:"title"`
|
||||
Rating null.Int `db:"rating"`
|
||||
Organized bool `db:"organized"`
|
||||
OCounter int `db:"o_counter"`
|
||||
StudioID null.Int `db:"studio_id,omitempty"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
ID int `db:"id" goqu:"skipinsert"`
|
||||
Title zero.String `db:"title"`
|
||||
Rating null.Int `db:"rating"`
|
||||
Organized bool `db:"organized"`
|
||||
OCounter int `db:"o_counter"`
|
||||
StudioID null.Int `db:"studio_id,omitempty"`
|
||||
CreatedAt models.SQLiteTimestamp `db:"created_at"`
|
||||
UpdatedAt models.SQLiteTimestamp `db:"updated_at"`
|
||||
}
|
||||
|
||||
func (r *imageRow) fromImage(i models.Image) {
|
||||
@@ -45,8 +44,8 @@ func (r *imageRow) fromImage(i models.Image) {
|
||||
r.Organized = i.Organized
|
||||
r.OCounter = i.OCounter
|
||||
r.StudioID = intFromPtr(i.StudioID)
|
||||
r.CreatedAt = i.CreatedAt
|
||||
r.UpdatedAt = i.UpdatedAt
|
||||
r.CreatedAt = models.SQLiteTimestamp{Timestamp: i.CreatedAt}
|
||||
r.UpdatedAt = models.SQLiteTimestamp{Timestamp: i.UpdatedAt}
|
||||
}
|
||||
|
||||
type imageQueryRow struct {
|
||||
@@ -69,8 +68,8 @@ func (r *imageQueryRow) resolve() *models.Image {
|
||||
PrimaryFileID: nullIntFileIDPtr(r.PrimaryFileID),
|
||||
Checksum: r.PrimaryFileChecksum.String,
|
||||
|
||||
CreatedAt: r.CreatedAt,
|
||||
UpdatedAt: r.UpdatedAt,
|
||||
CreatedAt: r.CreatedAt.Timestamp,
|
||||
UpdatedAt: r.UpdatedAt.Timestamp,
|
||||
}
|
||||
|
||||
if r.PrimaryFileFolderPath.Valid && r.PrimaryFileBasename.Valid {
|
||||
|
||||
Reference in New Issue
Block a user