emdb/cmd/api-service/job/job.go

52 lines
920 B
Go
Raw Normal View History

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"
)
2024-01-20 12:30:06 +01:00
type Status string
type Type string
2023-12-30 09:19:53 +01:00
const (
2024-01-18 07:56:25 +01:00
interval = 20 * time.Second
2023-12-30 09:19:53 +01:00
2024-01-20 12:30:06 +01:00
TypeSimple Type = "simple"
TypeAI Type = "ai"
ActionRefreshIMDBReviews = "refresh-imdb-reviews"
ActionRefreshAllIMDBReviews = "refresh-all-imdb-reviews"
ActionFindTitles = "find-titles"
ActionFindAllTitles = "find-all-titles"
2023-12-30 09:19:53 +01:00
)
var (
2024-01-20 12:30:06 +01:00
simpleActions = []string{
ActionRefreshIMDBReviews,
2024-01-20 12:30:06 +01:00
ActionRefreshAllIMDBReviews, // just creates a job for each movie
ActionFindAllTitles, // just creates a job for each review
}
2024-01-20 12:30:06 +01:00
aiActions = []string{
ActionFindTitles,
}
validActions = append(simpleActions, aiActions...)
)
2023-12-30 09:19:53 +01:00
type Job struct {
2024-01-20 13:24:42 +01:00
ID int
ActionID string
Action string
Status Status
Created time.Time
Updated time.Time
2023-12-30 09:19:53 +01:00
}
2024-01-18 08:57:56 +01:00
2024-01-20 12:30:06 +01:00
func Valid(action string) bool {
2024-01-18 08:57:56 +01:00
if slices.Contains(validActions, action) {
return true
}
return false
}