monitoring setup, project dashboard, account page

This commit is contained in:
simon987
2019-02-09 13:16:58 -05:00
parent f577e76afa
commit 4ef4752c14
28 changed files with 629 additions and 160 deletions

View File

@@ -156,3 +156,31 @@ func (database Database) GetAllProjects() *[]Project {
return &projects
}
func (database *Database) GetAssigneeStats(pid int64, count int64) *[]AssignedTasks {
db := database.getDB()
assignees := make([]AssignedTasks, 0)
rows, err := db.Query(`SELECT worker.alias, COUNT(*) as wc FROM TASK
LEFT JOIN worker ON TASK.assignee = worker.id WHERE project=$1
GROUP BY worker.id ORDER BY wc LIMIT $2`, pid, count)
handleErr(err)
for rows.Next() {
assignee := AssignedTasks{}
var assigneeAlias sql.NullString
err = rows.Scan(&assigneeAlias, &assignee.TaskCount)
handleErr(err)
if assigneeAlias.Valid {
assignee.Assignee = assigneeAlias.String
} else {
assignee.Assignee = "unassigned"
}
assignees = append(assignees, assignee)
}
return &assignees
}