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

Function GetUserTask

controller/task.go:39–61  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

37}
38
39func GetUserTask(c *gin.Context) {
40 pageInfo := common.GetPageQuery(c)
41
42 userId := c.GetInt("id")
43
44 startTimestamp, _ := strconv.ParseInt(c.Query("start_timestamp"), 10, 64)
45 endTimestamp, _ := strconv.ParseInt(c.Query("end_timestamp"), 10, 64)
46
47 queryParams := model.SyncTaskQueryParams{
48 Platform: constant.TaskPlatform(c.Query("platform")),
49 TaskID: c.Query("task_id"),
50 Status: c.Query("status"),
51 Action: c.Query("action"),
52 StartTimestamp: startTimestamp,
53 EndTimestamp: endTimestamp,
54 }
55
56 items := model.TaskGetAllUserTask(userId, pageInfo.GetStartIdx(), pageInfo.GetPageSize(), queryParams)
57 total := model.TaskCountAllUserTask(userId, queryParams)
58 pageInfo.SetTotal(int(total))
59 pageInfo.SetItems(tasksToDto(items, false))
60 common.ApiSuccess(c, pageInfo)
61}
62
63func tasksToDto(tasks []*model.Task, fillUser bool) []*dto.TaskDto {
64 var userIdMap map[int]*model.UserBase

Callers

nothing calls this directly

Calls 11

GetPageQueryFunction · 0.92
TaskPlatformTypeAlias · 0.92
TaskGetAllUserTaskFunction · 0.92
TaskCountAllUserTaskFunction · 0.92
ApiSuccessFunction · 0.92
tasksToDtoFunction · 0.85
QueryMethod · 0.80
GetStartIdxMethod · 0.80
GetPageSizeMethod · 0.80
SetTotalMethod · 0.80
SetItemsMethod · 0.80

Tested by

no test coverage detected