mirror of
https://git.sr.ht/~phw/scotty
synced 2025-04-30 05:37:05 +02:00
Introduce models.Entity type
This commit is contained in:
parent
a59a542967
commit
c4587b80af
6 changed files with 18 additions and 9 deletions
|
@ -24,6 +24,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/glebarez/sqlite"
|
||||
"go.uploadedlobster.com/scotty/internal/models"
|
||||
"golang.org/x/oauth2"
|
||||
"gorm.io/datatypes"
|
||||
"gorm.io/gorm"
|
||||
|
@ -54,7 +55,7 @@ func New(dsn string) (db Database, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func (db Database) GetImportTimestamp(source string, target string, entity string) (time.Time, error) {
|
||||
func (db Database) GetImportTimestamp(source string, target string, entity models.Entity) (time.Time, error) {
|
||||
result := ImportTimestamp{
|
||||
SourceService: source,
|
||||
TargetService: target,
|
||||
|
@ -64,7 +65,7 @@ func (db Database) GetImportTimestamp(source string, target string, entity strin
|
|||
return result.Timestamp, err
|
||||
}
|
||||
|
||||
func (db Database) SetImportTimestamp(source string, target string, entity string, timestamp time.Time) error {
|
||||
func (db Database) SetImportTimestamp(source string, target string, entity models.Entity, timestamp time.Time) error {
|
||||
entry := ImportTimestamp{
|
||||
SourceService: source,
|
||||
TargetService: target,
|
||||
|
|
|
@ -23,6 +23,7 @@ import (
|
|||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uploadedlobster.com/scotty/internal/models"
|
||||
"go.uploadedlobster.com/scotty/internal/storage"
|
||||
"golang.org/x/oauth2"
|
||||
)
|
||||
|
@ -33,7 +34,7 @@ func TestTimestampUpdate(t *testing.T) {
|
|||
|
||||
source := "maloja"
|
||||
target := "funkwhale"
|
||||
entity := "loves"
|
||||
entity := models.Loves
|
||||
timestamp, err := db.GetImportTimestamp(source, target, entity)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, time.Time{}, timestamp)
|
||||
|
|
|
@ -20,13 +20,14 @@ package storage
|
|||
import (
|
||||
"time"
|
||||
|
||||
"go.uploadedlobster.com/scotty/internal/models"
|
||||
"gorm.io/datatypes"
|
||||
)
|
||||
|
||||
type ImportTimestamp struct {
|
||||
SourceService string `gorm:"primaryKey"`
|
||||
TargetService string `gorm:"primaryKey"`
|
||||
Entity string `gorm:"primaryKey"`
|
||||
SourceService string `gorm:"primaryKey"`
|
||||
TargetService string `gorm:"primaryKey"`
|
||||
Entity models.Entity `gorm:"primaryKey"`
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
Timestamp time.Time `gorm:"default:'1970-01-01T00:00:00'"`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue