mirror of
https://git.sr.ht/~phw/scotty
synced 2025-04-30 13:47:05 +02:00
Better naming, distingiush between "service" and "backend"
This commit is contained in:
parent
6e330daf06
commit
8b227cb514
5 changed files with 20 additions and 20 deletions
|
@ -58,23 +58,23 @@ func New(dsn string) (db Database, err error) {
|
|||
|
||||
func (db Database) GetImportTimestamp(source string, target string, entity string) (time.Time, error) {
|
||||
result := ImportTimestamp{
|
||||
SourceBackend: source,
|
||||
TargetBackend: target,
|
||||
SourceService: source,
|
||||
TargetService: target,
|
||||
Entity: entity,
|
||||
}
|
||||
db.db.Limit(1).Find(&result)
|
||||
return result.Timestamp, nil
|
||||
err := db.db.Limit(1).Find(&result).Error
|
||||
return result.Timestamp, err
|
||||
}
|
||||
|
||||
func (db Database) SetImportTimestamp(source string, target string, entity string, timestamp time.Time) error {
|
||||
entry := ImportTimestamp{
|
||||
SourceBackend: source,
|
||||
TargetBackend: target,
|
||||
SourceService: source,
|
||||
TargetService: target,
|
||||
Entity: entity,
|
||||
Timestamp: timestamp,
|
||||
}
|
||||
db.db.Clauses(clause.OnConflict{
|
||||
err := db.db.Clauses(clause.OnConflict{
|
||||
DoUpdates: clause.AssignmentColumns([]string{"timestamp", "updated_at"}),
|
||||
}).Create(&entry)
|
||||
return nil
|
||||
}).Create(&entry).Error
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -27,8 +27,8 @@ import (
|
|||
)
|
||||
|
||||
type ImportTimestamp struct {
|
||||
SourceBackend string `gorm:"primaryKey"`
|
||||
TargetBackend string `gorm:"primaryKey"`
|
||||
SourceService string `gorm:"primaryKey"`
|
||||
TargetService string `gorm:"primaryKey"`
|
||||
Entity string `gorm:"primaryKey"`
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue