MCPcopy Create free account
hub / github.com/QuantumNous/new-api / GetLatestSystemTask

Function GetLatestSystemTask

model/system_task.go:193–203  ·  view source on GitHub ↗

GetLatestSystemTask returns the most recent task row of the given type (any status) so the scheduler can decide whether enough time has elapsed since the last run. Returns (nil, nil) when no row exists.

(taskType string)

Source from the content-addressed store, hash-verified

191// (any status) so the scheduler can decide whether enough time has elapsed
192// since the last run. Returns (nil, nil) when no row exists.
193func GetLatestSystemTask(taskType string) (*SystemTask, error) {
194 var task SystemTask
195 err := DB.Where("type = ?", taskType).Order("id desc").First(&task).Error
196 if err != nil {
197 if errors.Is(err, gorm.ErrRecordNotFound) {
198 return nil, nil
199 }
200 return nil, err
201 }
202 return &task, nil
203}
204
205func GetLatestSystemTasks(taskTypes []string) (map[string]*SystemTask, error) {
206 tasksByType := map[string]*SystemTask{}

Calls

no outgoing calls