mirror of
https://github.com/semaphoreui/semaphore.git
synced 2025-01-20 15:29:28 +01:00
feat(api): list tasks for template
This commit is contained in:
parent
8b88446054
commit
ff82c40d23
@ -174,6 +174,8 @@ func Route() *mux.Router {
|
||||
projectTmplManagement.HandleFunc("/{template_id}", projects.UpdateTemplate).Methods("PUT")
|
||||
projectTmplManagement.HandleFunc("/{template_id}", projects.RemoveTemplate).Methods("DELETE")
|
||||
projectTmplManagement.HandleFunc("/{template_id}", projects.GetTemplate).Methods("GET")
|
||||
projectTmplManagement.HandleFunc("/{template_id}/tasks", tasks.GetAllTasks).Methods("GET")
|
||||
projectTmplManagement.HandleFunc("/{template_id}/tasks/last", tasks.GetLastTasks).Methods("GET")
|
||||
|
||||
projectTaskManagement := projectUserAPI.PathPrefix("/tasks").Subrouter()
|
||||
projectTaskManagement.Use(tasks.GetTaskMiddleware)
|
||||
|
@ -57,11 +57,17 @@ func GetTasksList(w http.ResponseWriter, r *http.Request, limit uint64) {
|
||||
project := context.Get(r, "project").(db.Project)
|
||||
|
||||
q := squirrel.Select("task.*, tpl.playbook as tpl_playbook, user.name as user_name, tpl.alias as tpl_alias").
|
||||
From(taskTypeID).
|
||||
From("task").
|
||||
Join("project__template as tpl on task.template_id=tpl.id").
|
||||
LeftJoin("user on task.user_id=user.id").
|
||||
Where("tpl.project_id=?", project.ID).
|
||||
OrderBy("task.created desc")
|
||||
LeftJoin("user on task.user_id=user.id");
|
||||
|
||||
if tpl := context.Get(r, "template"); tpl != nil {
|
||||
q = q.Where("tpl.project_id=? AND task.template_id=?", project.ID, tpl.(db.Template).ID)
|
||||
} else {
|
||||
q = q.Where("tpl.project_id=?", project.ID)
|
||||
}
|
||||
|
||||
q = q.OrderBy("task.created desc, id desc")
|
||||
|
||||
if limit > 0 {
|
||||
q = q.Limit(limit)
|
||||
|
Loading…
Reference in New Issue
Block a user