sql:=fmt.Sprintf("SELECT time,sum(fee) AS fee FROM bills WHERE uid='%d' and time >= '%s' and time <= '%s' SAMPLE BY 1M ALIGN TO CALENDAR ORDER BY time DESC LIMIT %d,%d;",info.UserID,startTime,endTime,offset,appRequest.Size)
counts,err:=postgres.CountTasks(sql)
sql:=fmt.Sprintf("SELECT count(*) FROM bills WHERE uid='%d' and time >= '%s' and time <= '%s' SAMPLE BY 1M ALIGN TO CALENDAR;",info.UserID,startTime,endTime)
total,err:=postgres.QueryTotal(sql)
iferr!=nil{
server.respond(models.BusinessFailed,err.Error())
return
}
logs.Debug("total = %d",total)
varresponseTasks[]models.Bills
iftotal==0{
responseData:=struct{
Totalint64`json:"total"`
Datainterface{}`json:"data,omitempty"`
}{
Total:total,
Data:responseTasks,
}
server.respond(http.StatusOK,"",responseData)
return
}
server.respond(http.StatusOK,"",counts)
sql=fmt.Sprintf("SELECT time,sum(fee) AS fee FROM bills WHERE uid='%d' and time >= '%s' and time <= '%s' SAMPLE BY 1M ALIGN TO CALENDAR ORDER BY time DESC LIMIT %d,%d;",info.UserID,startTime,endTime,offset,size)
timeCondition=fmt.Sprintf(" and time >= '%s' and time <= '%s'",startTime,endTime)
}
sql:=fmt.Sprintf("SELECT id,type,time,fee,result FROM bills WHERE uid='%d'%s ORDER BY time DESC LIMIT %d,%d;",info.UserID,timeCondition,offset,appRequest.Size)
data,err:=postgres.QueryBills(sql)
sql:=fmt.Sprintf("SELECT count(*) FROM bills WHERE uid='%d'%s;",info.UserID,timeCondition)
total,err:=postgres.QueryTotal(sql)
iferr!=nil{
server.respond(models.BusinessFailed,err.Error())
return
}
logs.Debug("total = %d",total)
varresponseTasks[]models.Bills
iftotal==0{
responseData:=struct{
Totalint64`json:"total"`
Datainterface{}`json:"data,omitempty"`
}{
Total:total,
Data:responseTasks,
}
server.respond(http.StatusOK,"",responseData)
return
}
sql=fmt.Sprintf("SELECT id,type,time,fee,result FROM bills WHERE uid='%d'%s ORDER BY time DESC LIMIT %d,%d;",info.UserID,timeCondition,offset,size)
sql:=fmt.Sprintf("SELECT id,type,time,workload,profit_acc,worker_acc,result FROM bills %s ORDER BY time DESC LIMIT %d,%d;",timeCondition,offset,appRequest.Size)
data,err:=postgres.QueryBills(sql)
sql:=fmt.Sprintf("SELECT count(*) FROM bills %s;",timeCondition)
total,err:=postgres.QueryTotal(sql)
iferr!=nil{
server.respond(models.BusinessFailed,err.Error())
return
}
logs.Debug("total = %d",total)
varresponseTasks[]models.Bills
iftotal==0{
responseData:=struct{
Totalint64`json:"total"`
Datainterface{}`json:"data,omitempty"`
}{
Total:total,
Data:responseTasks,
}
server.respond(http.StatusOK,"",responseData)
return
}
sql=fmt.Sprintf("SELECT id,type,time,workload,profit_acc,worker_acc,result FROM bills %s ORDER BY time DESC LIMIT %d,%d;",timeCondition,offset,size)
sql:=fmt.Sprintf("SELECT time,count(*) FROM bills WHERE time >= '%s' and time <= '%s' %s SAMPLE BY 1d ALIGN TO CALENDAR;",startTime,endTime,timeCondition)
sql:=fmt.Sprintf("SELECT id,type,time,fee,in_len FROM tasks WHERE uid='%d'%s ORDER BY time DESC LIMIT %d,%d;",info.UserID,timeCondition,offset,appRequest.Size)
sql=fmt.Sprintf("SELECT id,type,time,fee,in_len FROM tasks WHERE uid='%d'%s ORDER BY time DESC LIMIT %d,%d;",info.UserID,timeCondition,offset,size)
sql=fmt.Sprintf("SELECT id,time,fee,out_len,result,task_duration FROM bills WHERE uid='%d'%s ORDER BY time DESC LIMIT %d,%d;",info.UserID,timeCondition,offset,appRequest.Size)
sql=fmt.Sprintf("SELECT id,time,fee,out_len,result,task_duration FROM bills WHERE uid='%d'%s ORDER BY time DESC LIMIT %d,%d;",info.UserID,timeCondition,offset,size)
sql:=fmt.Sprintf("SELECT time,count(*) FROM tasks WHERE uid='%d' and time >= '%s' and time <= '%s' SAMPLE BY 1d ALIGN TO CALENDAR;",info.UserID,startTime,endTime)
sql:=fmt.Sprintf("SELECT type, time,count(*) FROM tasks WHERE uid='%d' and time >= '%s' and time <= '%s' SAMPLE BY 1d ALIGN TO CALENDAR;",info.UserID,startTime,endTime)
sql:=fmt.Sprintf("SELECT time,sum(fee) AS fee FROM bills WHERE uid='%d' and time >= '%s' and time <= '%s' SAMPLE BY 1d ALIGN TO CALENDAR;",info.UserID,startTime,endTime)
sql:=fmt.Sprintf("SELECT type, time,sum(fee) AS fee FROM bills WHERE uid='%d' and time >= '%s' and time <= '%s' SAMPLE BY 1d ALIGN TO CALENDAR;",info.UserID,startTime,endTime)
sql:=fmt.Sprintf("SELECT id, `name` AS tit,type,`desc` AS content, tags ,examples,codes,base_model,api_path,version FROM task_type WHERE deleted = 0 %s LIMIT %d,%d;",where,offset,appRequest.Size)
sql:=fmt.Sprintf("SELECT id, `name` AS tit,type,`desc` AS content, tags ,examples,codes,base_model,api_path,version FROM task_type WHERE deleted = 0 %s LIMIT %d,%d;",where,offset,size)