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

Function GetLatestSystemTasks

model/system_task.go:205–223  ·  view source on GitHub ↗
(taskTypes []string)

Source from the content-addressed store, hash-verified

203}
204
205func GetLatestSystemTasks(taskTypes []string) (map[string]*SystemTask, error) {
206 tasksByType := map[string]*SystemTask{}
207 if len(taskTypes) == 0 {
208 return tasksByType, nil
209 }
210
211 subQuery := DB.Model(&SystemTask{}).
212 Select("MAX(id)").
213 Where("type IN ?", taskTypes).
214 Group("type")
215 var tasks []*SystemTask
216 if err := DB.Where("id IN (?)", subQuery).Find(&tasks).Error; err != nil {
217 return nil, err
218 }
219 for _, task := range tasks {
220 tasksByType[task.Type] = task
221 }
222 return tasksByType, nil
223}
224
225func ClaimSystemTask(id int64, taskType string, runnerID string, lockUntil int64) (*SystemTask, bool, error) {
226 now := common.GetTimestamp()

Callers 2

runSystemTaskSchedulerFunction · 0.92
TestGetLatestSystemTasksFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestGetLatestSystemTasksFunction · 0.68