2023-12-30 09:19:53 +01:00
|
|
|
package job
|
|
|
|
|
|
|
|
import (
|
2024-01-18 08:57:56 +01:00
|
|
|
"slices"
|
2023-12-30 09:19:53 +01:00
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
type JobStatus string
|
|
|
|
|
|
|
|
type Action string
|
|
|
|
|
|
|
|
const (
|
2024-01-18 07:56:25 +01:00
|
|
|
interval = 20 * time.Second
|
2023-12-30 09:19:53 +01:00
|
|
|
|
|
|
|
ActionRefreshIMDBReviews Action = "refresh-imdb-reviews"
|
|
|
|
ActionRefreshAllIMDBReviews Action = "refresh-all-imdb-reviews"
|
|
|
|
)
|
|
|
|
|
2024-01-18 07:38:32 +01:00
|
|
|
var (
|
|
|
|
validActions = []Action{
|
|
|
|
ActionRefreshIMDBReviews,
|
|
|
|
ActionRefreshAllIMDBReviews,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2023-12-30 09:19:53 +01:00
|
|
|
type Job struct {
|
|
|
|
ID int
|
|
|
|
MovieID string
|
|
|
|
Action Action
|
|
|
|
Status JobStatus
|
2024-01-18 07:38:32 +01:00
|
|
|
Created time.Time
|
|
|
|
Updated time.Time
|
2023-12-30 09:19:53 +01:00
|
|
|
}
|
2024-01-18 08:57:56 +01:00
|
|
|
|
|
|
|
func Valid(action Action) bool {
|
|
|
|
if slices.Contains(validActions, action) {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|