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

Function TaskCountAllUserTask

model/task.go:486–509  ·  view source on GitHub ↗

TaskCountAllUserTask returns total tasks for given user

(userId int, queryParams SyncTaskQueryParams)

Source from the content-addressed store, hash-verified

484
485// TaskCountAllUserTask returns total tasks for given user
486func TaskCountAllUserTask(userId int, queryParams SyncTaskQueryParams) int64 {
487 var total int64
488 query := DB.Model(&Task{}).Where("user_id = ?", userId)
489 if queryParams.TaskID != "" {
490 query = query.Where("task_id = ?", queryParams.TaskID)
491 }
492 if queryParams.Action != "" {
493 query = query.Where("action = ?", queryParams.Action)
494 }
495 if queryParams.Status != "" {
496 query = query.Where("status = ?", queryParams.Status)
497 }
498 if queryParams.Platform != "" {
499 query = query.Where("platform = ?", queryParams.Platform)
500 }
501 if queryParams.StartTimestamp != 0 {
502 query = query.Where("submit_time >= ?", queryParams.StartTimestamp)
503 }
504 if queryParams.EndTimestamp != 0 {
505 query = query.Where("submit_time <= ?", queryParams.EndTimestamp)
506 }
507 _ = query.Count(&total).Error
508 return total
509}
510func (t *Task) ToOpenAIVideo() *dto.OpenAIVideo {
511 openAIVideo := dto.NewOpenAIVideo()
512 openAIVideo.ID = t.TaskID

Callers 1

GetUserTaskFunction · 0.92

Calls 1

CountMethod · 0.80

Tested by

no test coverage detected