diff --git a/server/backend/cron/movies.go b/server/backend/cron/movies.go index de71c47b..0d9eaee4 100644 --- a/server/backend/cron/movies.go +++ b/server/backend/cron/movies.go @@ -4,13 +4,14 @@ import ( "encoding/json" "encoding/xml" "errors" - "github.com/guregu/null" "io" "net/http" "os" "strings" "time" + "github.com/guregu/null" + "github.com/PuerkitoBio/goquery" "github.com/TUM-Dev/Campus-Backend/server/model" log "github.com/sirupsen/logrus" diff --git a/server/backend/migration/2023090410000000.go b/server/backend/migration/2023090410000000.go index bbc6efca..82117b56 100644 --- a/server/backend/migration/2023090410000000.go +++ b/server/backend/migration/2023090410000000.go @@ -1,8 +1,6 @@ package migration import ( - "database/sql" - "github.com/TUM-Dev/Campus-Backend/server/model" "github.com/go-gormigrate/gormigrate/v2" "github.com/guregu/null" @@ -27,8 +25,8 @@ func (m TumDBMigrator) migrate2023090410000000() *gormigrate.Migration { } if err := tx.Create(&model.Crontab{ Interval: 60 * 60 * 24, // daily - Type: null.String{NullString: sql.NullString{String: "movie", Valid: true}}, - ID: null.Int{NullInt64: sql.NullInt64{Int64: 2, Valid: true}}, + Type: null.StringFrom("movie"), + ID: null.IntFrom(2), }).Error; err != nil { return err } @@ -48,7 +46,7 @@ func (m TumDBMigrator) migrate2023090410000000() *gormigrate.Migration { } if err := tx.Create(&model.Crontab{ Interval: 24 * 60 * 60, // daily - Type: null.String{NullString: sql.NullString{String: "kino", Valid: true}}, + Type: null.StringFrom("kino"), }).Error; err != nil { return err } diff --git a/server/model/kino.go b/server/model/kino.go index 6f7a7026..cc5e6a5e 100644 --- a/server/model/kino.go +++ b/server/model/kino.go @@ -1,27 +1,28 @@ package model import ( - "database/sql" "time" + + "github.com/guregu/null" ) // Kino stores all movies type Kino struct { - Id int32 `gorm:"primary_key;AUTO_INCREMENT;column:kino;type:int;not null;"` - Date time.Time `gorm:"column:date;type:datetime;not null;"` - Created time.Time `gorm:"column:created;type:timestamp;not null;default:CURRENT_TIMESTAMP"` - Title string `gorm:"column:title;type:text;not null;"` - Year string `gorm:"column:year;type:varchar(4);not null;"` - Runtime string `gorm:"column:runtime;type:varchar(40);not null;"` - Genre string `gorm:"column:genre;type:varchar(100);not null;"` - Director string `gorm:"column:director;type:text;not null;"` - Actors string `gorm:"column:actors;type:text;not null;"` - ImdbRating string `gorm:"column:rating;type:varchar(4);not null;"` - Description string `gorm:"column:description;type:text;not null;"` - Trailer sql.NullString `gorm:"column:trailer"` - FilesID int32 `gorm:"column:cover"` - Files Files `gorm:"foreignKey:FilesID;references:file"` - Link string `gorm:"column:link;type:varchar(190);not null;unique;"` + Id int32 `gorm:"primary_key;AUTO_INCREMENT;column:kino;type:int;not null;"` + Date time.Time `gorm:"column:date;type:datetime;not null;"` + Created time.Time `gorm:"column:created;type:timestamp;not null;default:CURRENT_TIMESTAMP"` + Title string `gorm:"column:title;type:text;not null;"` + Year string `gorm:"column:year;type:varchar(4);not null;"` + Runtime string `gorm:"column:runtime;type:varchar(40);not null;"` + Genre string `gorm:"column:genre;type:varchar(100);not null;"` + Director string `gorm:"column:director;type:text;not null;"` + Actors string `gorm:"column:actors;type:text;not null;"` + ImdbRating string `gorm:"column:rating;type:varchar(4);not null;"` + Description string `gorm:"column:description;type:text;not null;"` + Trailer null.String `gorm:"column:trailer"` + FilesID int32 `gorm:"column:cover"` + Files Files `gorm:"foreignKey:FilesID;references:file"` + Link string `gorm:"column:link;type:varchar(190);not null;unique;"` } // TableName sets the insert table name for this struct type