mirror of
https://github.com/simon987/task_tracker.git
synced 2025-04-19 18:16:45 +00:00
revert accidental search&replace fail
This commit is contained in:
parent
6ca92bc0a7
commit
03153c4d39
@ -134,8 +134,8 @@ func (api *WebAPI) getAssociatedProject(payload *GitPayload) *storage.Project {
|
|||||||
project := api.Database.GetProjectWithRepoName(payload.Repository.FullName)
|
project := api.Database.GetProjectWithRepoName(payload.Repository.FullName)
|
||||||
|
|
||||||
logrus.WithFields(logrus.Fields{
|
logrus.WithFields(logrus.Fields{
|
||||||
"projectChange": project,
|
"project": project,
|
||||||
}).Trace("Found projectChange associated with WebHook")
|
}).Trace("Found project associated with WebHook")
|
||||||
|
|
||||||
return project
|
return project
|
||||||
}
|
}
|
||||||
|
20
api/main.go
20
api/main.go
@ -83,18 +83,18 @@ func New() *WebAPI {
|
|||||||
api.router.POST("/access/grant", LogRequestMiddleware(api.WorkerGrantAccess))
|
api.router.POST("/access/grant", LogRequestMiddleware(api.WorkerGrantAccess))
|
||||||
api.router.POST("/access/remove", LogRequestMiddleware(api.WorkerRemoveAccess))
|
api.router.POST("/access/remove", LogRequestMiddleware(api.WorkerRemoveAccess))
|
||||||
|
|
||||||
api.router.POST("/projectChange/create", LogRequestMiddleware(api.ProjectCreate))
|
api.router.POST("/project/create", LogRequestMiddleware(api.ProjectCreate))
|
||||||
api.router.GET("/projectChange/get/:id", LogRequestMiddleware(api.ProjectGet))
|
api.router.GET("/project/get/:id", LogRequestMiddleware(api.ProjectGet))
|
||||||
api.router.POST("/projectChange/update/:id", LogRequestMiddleware(api.ProjectUpdate))
|
api.router.POST("/project/update/:id", LogRequestMiddleware(api.ProjectUpdate))
|
||||||
api.router.GET("/projectChange/list", LogRequestMiddleware(api.ProjectGetAllProjects))
|
api.router.GET("/project/list", LogRequestMiddleware(api.ProjectGetAllProjects))
|
||||||
api.router.GET("/projectChange/monitoring-between/:id", LogRequestMiddleware(api.GetSnapshotsBetween))
|
api.router.GET("/project/monitoring-between/:id", LogRequestMiddleware(api.GetSnapshotsBetween))
|
||||||
api.router.GET("/projectChange/monitoring/:id", LogRequestMiddleware(api.GetNSnapshots))
|
api.router.GET("/project/monitoring/:id", LogRequestMiddleware(api.GetNSnapshots))
|
||||||
api.router.GET("/projectChange/assignees/:id", LogRequestMiddleware(api.ProjectGetAssigneeStats))
|
api.router.GET("/project/assignees/:id", LogRequestMiddleware(api.ProjectGetAssigneeStats))
|
||||||
api.router.GET("/projectChange/requests/:id", LogRequestMiddleware(api.ProjectGetAccessRequests))
|
api.router.GET("/project/requests/:id", LogRequestMiddleware(api.ProjectGetAccessRequests))
|
||||||
api.router.GET("/projectChange/request_access/:id", LogRequestMiddleware(api.WorkerRequestAccess))
|
api.router.GET("/project/request_access/:id", LogRequestMiddleware(api.WorkerRequestAccess))
|
||||||
|
|
||||||
api.router.POST("/task/create", LogRequestMiddleware(api.TaskCreate))
|
api.router.POST("/task/create", LogRequestMiddleware(api.TaskCreate))
|
||||||
api.router.GET("/task/get/:projectChange", LogRequestMiddleware(api.TaskGetFromProject))
|
api.router.GET("/task/get/:project", LogRequestMiddleware(api.TaskGetFromProject))
|
||||||
api.router.GET("/task/get", LogRequestMiddleware(api.TaskGet))
|
api.router.GET("/task/get", LogRequestMiddleware(api.TaskGet))
|
||||||
api.router.POST("/task/release", LogRequestMiddleware(api.TaskRelease))
|
api.router.POST("/task/release", LogRequestMiddleware(api.TaskRelease))
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ type CreateProjectResponse struct {
|
|||||||
type GetProjectResponse struct {
|
type GetProjectResponse struct {
|
||||||
Ok bool `json:"ok"`
|
Ok bool `json:"ok"`
|
||||||
Message string `json:"message,omitempty"`
|
Message string `json:"message,omitempty"`
|
||||||
Project *storage.Project `json:"projectChange,omitempty"`
|
Project *storage.Project `json:"project,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetAllProjectsResponse struct {
|
type GetAllProjectsResponse struct {
|
||||||
@ -98,24 +98,24 @@ func (api *WebAPI) ProjectCreate(r *Request) {
|
|||||||
|
|
||||||
if !isValidProject(project) {
|
if !isValidProject(project) {
|
||||||
logrus.WithFields(logrus.Fields{
|
logrus.WithFields(logrus.Fields{
|
||||||
"projectChange": project,
|
"project": project,
|
||||||
}).Warn("Invalid projectChange")
|
}).Warn("Invalid project")
|
||||||
|
|
||||||
r.Json(CreateProjectResponse{
|
r.Json(CreateProjectResponse{
|
||||||
Ok: false,
|
Ok: false,
|
||||||
Message: "Invalid projectChange",
|
Message: "Invalid project",
|
||||||
}, 400)
|
}, 400)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !isProjectCreationAuthorized(project, manager) {
|
if !isProjectCreationAuthorized(project, manager) {
|
||||||
logrus.WithFields(logrus.Fields{
|
logrus.WithFields(logrus.Fields{
|
||||||
"projectChange": project,
|
"project": project,
|
||||||
}).Warn("Unauthorized projectChange creation")
|
}).Warn("Unauthorized project creation")
|
||||||
|
|
||||||
r.Json(CreateProjectResponse{
|
r.Json(CreateProjectResponse{
|
||||||
Ok: false,
|
Ok: false,
|
||||||
Message: "You are not permitted to create a projectChange with this configuration",
|
Message: "You are not permitted to create a project with this configuration",
|
||||||
}, 400)
|
}, 400)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -133,8 +133,8 @@ func (api *WebAPI) ProjectCreate(r *Request) {
|
|||||||
Id: id,
|
Id: id,
|
||||||
})
|
})
|
||||||
logrus.WithFields(logrus.Fields{
|
logrus.WithFields(logrus.Fields{
|
||||||
"projectChange": project,
|
"project": project,
|
||||||
}).Debug("Created projectChange")
|
}).Debug("Created project")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (api *WebAPI) ProjectUpdate(r *Request) {
|
func (api *WebAPI) ProjectUpdate(r *Request) {
|
||||||
@ -143,7 +143,7 @@ func (api *WebAPI) ProjectUpdate(r *Request) {
|
|||||||
if err != nil || id <= 0 {
|
if err != nil || id <= 0 {
|
||||||
r.Json(CreateProjectResponse{
|
r.Json(CreateProjectResponse{
|
||||||
Ok: false,
|
Ok: false,
|
||||||
Message: "Invalid projectChange id",
|
Message: "Invalid project id",
|
||||||
}, 400)
|
}, 400)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -179,26 +179,26 @@ func (api *WebAPI) ProjectUpdate(r *Request) {
|
|||||||
}, 500)
|
}, 500)
|
||||||
|
|
||||||
logrus.WithError(err).WithFields(logrus.Fields{
|
logrus.WithError(err).WithFields(logrus.Fields{
|
||||||
"projectChange": project,
|
"project": project,
|
||||||
}).Warn("Error during projectChange update")
|
}).Warn("Error during project update")
|
||||||
} else {
|
} else {
|
||||||
r.OkJson(UpdateProjectResponse{
|
r.OkJson(UpdateProjectResponse{
|
||||||
Ok: true,
|
Ok: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
logrus.WithFields(logrus.Fields{
|
logrus.WithFields(logrus.Fields{
|
||||||
"projectChange": project,
|
"project": project,
|
||||||
}).Debug("Updated projectChange")
|
}).Debug("Updated project")
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
logrus.WithFields(logrus.Fields{
|
logrus.WithFields(logrus.Fields{
|
||||||
"projectChange": project,
|
"project": project,
|
||||||
}).Warn("Invalid projectChange")
|
}).Warn("Invalid project")
|
||||||
|
|
||||||
r.Json(CreateProjectResponse{
|
r.Json(CreateProjectResponse{
|
||||||
Ok: false,
|
Ok: false,
|
||||||
Message: "Invalid projectChange",
|
Message: "Invalid project",
|
||||||
}, 400)
|
}, 400)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -353,7 +353,7 @@ func (api *WebAPI) WorkerRequestAccess(r *Request) {
|
|||||||
r.Json(WorkerRequestAccessResponse{
|
r.Json(WorkerRequestAccessResponse{
|
||||||
Ok: false,
|
Ok: false,
|
||||||
Message: "Project is public, you already have " +
|
Message: "Project is public, you already have " +
|
||||||
"an active request or you already have access to this projectChange",
|
"an active request or you already have access to this project",
|
||||||
}, 400)
|
}, 400)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type CreateTaskRequest struct {
|
type CreateTaskRequest struct {
|
||||||
Project int64 `json:"projectChange"`
|
Project int64 `json:"project"`
|
||||||
MaxRetries int64 `json:"max_retries"`
|
MaxRetries int64 `json:"max_retries"`
|
||||||
Recipe string `json:"recipe"`
|
Recipe string `json:"recipe"`
|
||||||
Priority int64 `json:"priority"`
|
Priority int64 `json:"priority"`
|
||||||
@ -123,7 +123,7 @@ func (api *WebAPI) TaskGetFromProject(r *Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
project, err := strconv.ParseInt(r.Ctx.UserValue("projectChange").(string), 10, 64)
|
project, err := strconv.ParseInt(r.Ctx.UserValue("project").(string), 10, 64)
|
||||||
handleErr(err, r)
|
handleErr(err, r)
|
||||||
task := api.Database.GetTaskFromProject(worker, project)
|
task := api.Database.GetTaskFromProject(worker, project)
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ func (api *WebAPI) WorkerGrantAccess(r *Request) {
|
|||||||
} else {
|
} else {
|
||||||
r.OkJson(WorkerAccessResponse{
|
r.OkJson(WorkerAccessResponse{
|
||||||
Ok: false,
|
Ok: false,
|
||||||
Message: "Worker already has access to this projectChange",
|
Message: "Worker already has access to this project",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -171,7 +171,7 @@ func (api *WebAPI) WorkerRemoveAccess(r *Request) {
|
|||||||
} else {
|
} else {
|
||||||
r.OkJson(WorkerAccessResponse{
|
r.OkJson(WorkerAccessResponse{
|
||||||
Ok: false,
|
Ok: false,
|
||||||
Message: "Worker did not have access to this projectChange",
|
Message: "Worker did not have access to this project",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -131,7 +131,7 @@ func (database *Database) ManagerHasRoleOn(manager *Manager, projectId int64) Ma
|
|||||||
db := database.getDB()
|
db := database.getDB()
|
||||||
|
|
||||||
row := db.QueryRow(`SELECT role FROM manager_has_role_on_project
|
row := db.QueryRow(`SELECT role FROM manager_has_role_on_project
|
||||||
WHERE projectChange=$1 AND manager=$2`, projectId, manager.Id)
|
WHERE project=$1 AND manager=$2`, projectId, manager.Id)
|
||||||
|
|
||||||
var role ManagerRole
|
var role ManagerRole
|
||||||
err := row.Scan(&role)
|
err := row.Scan(&role)
|
||||||
|
@ -22,19 +22,19 @@ func (database *Database) MakeProjectSnapshots() {
|
|||||||
|
|
||||||
insertRes, err := db.Exec(`
|
insertRes, err := db.Exec(`
|
||||||
INSERT INTO project_monitoring_snapshot
|
INSERT INTO project_monitoring_snapshot
|
||||||
(projectChange, new_task_count, failed_task_count, closed_task_count, worker_access_count,
|
(project, new_task_count, failed_task_count, closed_task_count, worker_access_count,
|
||||||
awaiting_verification_task_count, timestamp)
|
awaiting_verification_task_count, timestamp)
|
||||||
SELECT id,
|
SELECT id,
|
||||||
(SELECT COUNT(*) FROM task
|
(SELECT COUNT(*) FROM task
|
||||||
LEFT JOIN worker_verifies_task wvt on task.id = wvt.task
|
LEFT JOIN worker_verifies_task wvt on task.id = wvt.task
|
||||||
WHERE task.projectChange = projectChange.id AND status = 1 AND wvt.task IS NULL),
|
WHERE task.project = project.id AND status = 1 AND wvt.task IS NULL),
|
||||||
(SELECT COUNT(*) FROM task WHERE task.projectChange = projectChange.id AND status = 2),
|
(SELECT COUNT(*) FROM task WHERE task.project = project.id AND status = 2),
|
||||||
closed_task_count,
|
closed_task_count,
|
||||||
(SELECT COUNT(*) FROM worker_has_access_to_project wa WHERE wa.projectChange = projectChange.id),
|
(SELECT COUNT(*) FROM worker_has_access_to_project wa WHERE wa.project = project.id),
|
||||||
(SELECT COUNT(*) FROM worker_verifies_task INNER JOIN task t on worker_verifies_task.task = t.id
|
(SELECT COUNT(*) FROM worker_verifies_task INNER JOIN task t on worker_verifies_task.task = t.id
|
||||||
WHERE t.projectChange = projectChange.id),
|
WHERE t.project = project.id),
|
||||||
extract(epoch from now() at time zone 'utc')
|
extract(epoch from now() at time zone 'utc')
|
||||||
FROM projectChange`)
|
FROM project`)
|
||||||
handleErr(err)
|
handleErr(err)
|
||||||
inserted, _ := insertRes.RowsAffected()
|
inserted, _ := insertRes.RowsAffected()
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ func (database *Database) MakeProjectSnapshots() {
|
|||||||
"took": time.Now().Sub(startTime),
|
"took": time.Now().Sub(startTime),
|
||||||
"add": inserted,
|
"add": inserted,
|
||||||
"remove": deleted,
|
"remove": deleted,
|
||||||
}).Trace("Took projectChange monitoring snapshot")
|
}).Trace("Took project monitoring snapshot")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (database *Database) GetMonitoringSnapshotsBetween(pid int64, from int, to int) (ss *[]ProjectMonitoringSnapshot) {
|
func (database *Database) GetMonitoringSnapshotsBetween(pid int64, from int, to int) (ss *[]ProjectMonitoringSnapshot) {
|
||||||
@ -58,7 +58,7 @@ func (database *Database) GetMonitoringSnapshotsBetween(pid int64, from int, to
|
|||||||
|
|
||||||
rows, err := db.Query(`SELECT new_task_count, failed_task_count, closed_task_count,
|
rows, err := db.Query(`SELECT new_task_count, failed_task_count, closed_task_count,
|
||||||
worker_access_count, awaiting_verification_task_count, timestamp FROM project_monitoring_snapshot
|
worker_access_count, awaiting_verification_task_count, timestamp FROM project_monitoring_snapshot
|
||||||
WHERE projectChange=$1 AND timestamp BETWEEN $2 AND $3 ORDER BY TIMESTAMP DESC `, pid, from, to)
|
WHERE project=$1 AND timestamp BETWEEN $2 AND $3 ORDER BY TIMESTAMP DESC `, pid, from, to)
|
||||||
handleErr(err)
|
handleErr(err)
|
||||||
|
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
@ -89,7 +89,7 @@ func (database *Database) GetNMonitoringSnapshots(pid int64, count int) (ss *[]P
|
|||||||
|
|
||||||
rows, err := db.Query(`SELECT new_task_count, failed_task_count, closed_task_count,
|
rows, err := db.Query(`SELECT new_task_count, failed_task_count, closed_task_count,
|
||||||
worker_access_count, awaiting_verification_task_count, timestamp FROM project_monitoring_snapshot
|
worker_access_count, awaiting_verification_task_count, timestamp FROM project_monitoring_snapshot
|
||||||
WHERE projectChange=$1 ORDER BY TIMESTAMP DESC LIMIT $2`, pid, count)
|
WHERE project=$1 ORDER BY TIMESTAMP DESC LIMIT $2`, pid, count)
|
||||||
handleErr(err)
|
handleErr(err)
|
||||||
|
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
|
@ -27,7 +27,7 @@ type AssignedTasks struct {
|
|||||||
func (database *Database) SaveProject(project *Project) (int64, error) {
|
func (database *Database) SaveProject(project *Project) (int64, error) {
|
||||||
db := database.getDB()
|
db := database.getDB()
|
||||||
|
|
||||||
row := db.QueryRow(`INSERT INTO projectChange (name, git_repo, clone_url, version, priority,
|
row := db.QueryRow(`INSERT INTO project (name, git_repo, clone_url, version, priority,
|
||||||
motd, public, hidden, chain)
|
motd, public, hidden, chain)
|
||||||
VALUES ($1,$2,$3,$4,$5,$6,$7,$8,NULLIF($9, 0)) RETURNING id`,
|
VALUES ($1,$2,$3,$4,$5,$6,$7,$8,NULLIF($9, 0)) RETURNING id`,
|
||||||
project.Name, project.GitRepo, project.CloneUrl, project.Version, project.Priority, project.Motd,
|
project.Name, project.GitRepo, project.CloneUrl, project.Version, project.Priority, project.Motd,
|
||||||
@ -38,17 +38,17 @@ func (database *Database) SaveProject(project *Project) (int64, error) {
|
|||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithError(err).WithFields(logrus.Fields{
|
logrus.WithError(err).WithFields(logrus.Fields{
|
||||||
"projectChange": project,
|
"project": project,
|
||||||
}).Warn("Database.saveProject INSERT projectChange ERROR")
|
}).Warn("Database.saveProject INSERT project ERROR")
|
||||||
return -1, err
|
return -1, err
|
||||||
}
|
}
|
||||||
|
|
||||||
project.Id = id
|
project.Id = id
|
||||||
|
|
||||||
logrus.WithFields(logrus.Fields{
|
logrus.WithFields(logrus.Fields{
|
||||||
"id": id,
|
"id": id,
|
||||||
"projectChange": project,
|
"project": project,
|
||||||
}).Trace("Database.saveProject INSERT projectChange")
|
}).Trace("Database.saveProject INSERT project")
|
||||||
|
|
||||||
return id, nil
|
return id, nil
|
||||||
}
|
}
|
||||||
@ -58,20 +58,20 @@ func (database *Database) GetProject(id int64) *Project {
|
|||||||
db := database.getDB()
|
db := database.getDB()
|
||||||
row := db.QueryRow(`SELECT id, priority, name, clone_url, git_repo, version,
|
row := db.QueryRow(`SELECT id, priority, name, clone_url, git_repo, version,
|
||||||
motd, public, hidden, COALESCE(chain, 0)
|
motd, public, hidden, COALESCE(chain, 0)
|
||||||
FROM projectChange WHERE id=$1`, id)
|
FROM project WHERE id=$1`, id)
|
||||||
|
|
||||||
project, err := scanProject(row)
|
project, err := scanProject(row)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithError(err).WithFields(logrus.Fields{
|
logrus.WithError(err).WithFields(logrus.Fields{
|
||||||
"id": id,
|
"id": id,
|
||||||
}).Warn("Database.getProject SELECT projectChange NOT FOUND")
|
}).Warn("Database.getProject SELECT project NOT FOUND")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.WithFields(logrus.Fields{
|
logrus.WithFields(logrus.Fields{
|
||||||
"id": id,
|
"id": id,
|
||||||
"projectChange": project,
|
"project": project,
|
||||||
}).Trace("Database.saveProject SELECT projectChange")
|
}).Trace("Database.saveProject SELECT project")
|
||||||
|
|
||||||
return project
|
return project
|
||||||
}
|
}
|
||||||
@ -89,14 +89,14 @@ func (database *Database) GetProjectWithRepoName(repoName string) *Project {
|
|||||||
|
|
||||||
db := database.getDB()
|
db := database.getDB()
|
||||||
row := db.QueryRow(`SELECT id, priority, name, clone_url, git_repo, version,
|
row := db.QueryRow(`SELECT id, priority, name, clone_url, git_repo, version,
|
||||||
motd, public, hidden, COALESCE(chain, 0) FROM projectChange WHERE LOWER(git_repo)=$1`,
|
motd, public, hidden, COALESCE(chain, 0) FROM project WHERE LOWER(git_repo)=$1`,
|
||||||
strings.ToLower(repoName))
|
strings.ToLower(repoName))
|
||||||
|
|
||||||
project, err := scanProject(row)
|
project, err := scanProject(row)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithError(err).WithFields(logrus.Fields{
|
logrus.WithError(err).WithFields(logrus.Fields{
|
||||||
"repoName": repoName,
|
"repoName": repoName,
|
||||||
}).Warn("Database.getProjectWithRepoName SELECT projectChange NOT FOUND")
|
}).Warn("Database.getProjectWithRepoName SELECT project NOT FOUND")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ func (database *Database) UpdateProject(project *Project) error {
|
|||||||
|
|
||||||
db := database.getDB()
|
db := database.getDB()
|
||||||
|
|
||||||
res, err := db.Exec(`UPDATE projectChange
|
res, err := db.Exec(`UPDATE project
|
||||||
SET (priority, name, clone_url, git_repo, version, motd, public, hidden, chain) =
|
SET (priority, name, clone_url, git_repo, version, motd, public, hidden, chain) =
|
||||||
($1,$2,$3,$4,$5,$6,$7,$8,NULLIF($9, 0))
|
($1,$2,$3,$4,$5,$6,$7,$8,NULLIF($9, 0))
|
||||||
WHERE id=$10`,
|
WHERE id=$10`,
|
||||||
@ -120,9 +120,9 @@ func (database *Database) UpdateProject(project *Project) error {
|
|||||||
rowsAffected, _ := res.RowsAffected()
|
rowsAffected, _ := res.RowsAffected()
|
||||||
|
|
||||||
logrus.WithFields(logrus.Fields{
|
logrus.WithFields(logrus.Fields{
|
||||||
"projectChange": project,
|
"project": project,
|
||||||
"rowsAffected": rowsAffected,
|
"rowsAffected": rowsAffected,
|
||||||
}).Trace("Database.updateProject UPDATE projectChange")
|
}).Trace("Database.updateProject UPDATE project")
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -136,14 +136,14 @@ func (database Database) GetAllProjects(workerId int64) *[]Project {
|
|||||||
if workerId == 0 {
|
if workerId == 0 {
|
||||||
rows, err = db.Query(`SELECT
|
rows, err = db.Query(`SELECT
|
||||||
Id, priority, name, clone_url, git_repo, version, motd, public, hidden, COALESCE(chain,0)
|
Id, priority, name, clone_url, git_repo, version, motd, public, hidden, COALESCE(chain,0)
|
||||||
FROM projectChange
|
FROM project
|
||||||
WHERE NOT hidden
|
WHERE NOT hidden
|
||||||
ORDER BY name`)
|
ORDER BY name`)
|
||||||
} else {
|
} else {
|
||||||
rows, err = db.Query(`SELECT
|
rows, err = db.Query(`SELECT
|
||||||
Id, priority, name, clone_url, git_repo, version, motd, public, hidden, COALESCE(chain,0)
|
Id, priority, name, clone_url, git_repo, version, motd, public, hidden, COALESCE(chain,0)
|
||||||
FROM projectChange
|
FROM project
|
||||||
LEFT JOIN worker_has_access_to_project whatp ON whatp.projectChange = id
|
LEFT JOIN worker_has_access_to_project whatp ON whatp.project = id
|
||||||
WHERE NOT hidden OR whatp.worker = $1
|
WHERE NOT hidden OR whatp.worker = $1
|
||||||
ORDER BY name`, workerId)
|
ORDER BY name`, workerId)
|
||||||
}
|
}
|
||||||
@ -171,7 +171,7 @@ func (database *Database) GetAssigneeStats(pid int64, count int64) *[]AssignedTa
|
|||||||
assignees := make([]AssignedTasks, 0)
|
assignees := make([]AssignedTasks, 0)
|
||||||
|
|
||||||
rows, err := db.Query(`SELECT worker.alias, COUNT(*) as wc FROM TASK
|
rows, err := db.Query(`SELECT worker.alias, COUNT(*) as wc FROM TASK
|
||||||
LEFT JOIN worker ON TASK.assignee = worker.id WHERE projectChange=$1
|
LEFT JOIN worker ON TASK.assignee = worker.id WHERE project=$1
|
||||||
GROUP BY worker.id ORDER BY wc LIMIT $2`, pid, count)
|
GROUP BY worker.id ORDER BY wc LIMIT $2`, pid, count)
|
||||||
handleErr(err)
|
handleErr(err)
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
type Task struct {
|
type Task struct {
|
||||||
Id int64 `json:"id"`
|
Id int64 `json:"id"`
|
||||||
Priority int64 `json:"priority"`
|
Priority int64 `json:"priority"`
|
||||||
Project *Project `json:"projectChange"`
|
Project *Project `json:"project"`
|
||||||
Assignee int64 `json:"assignee"`
|
Assignee int64 `json:"assignee"`
|
||||||
Retries int64 `json:"retries"`
|
Retries int64 `json:"retries"`
|
||||||
MaxRetries int64 `json:"max_retries"`
|
MaxRetries int64 `json:"max_retries"`
|
||||||
@ -41,7 +41,7 @@ func (database *Database) SaveTask(task *Task, project int64, hash64 int64) erro
|
|||||||
|
|
||||||
//TODO: For some reason it refuses to insert the 64-bit value unless I do that...
|
//TODO: For some reason it refuses to insert the 64-bit value unless I do that...
|
||||||
res, err := db.Exec(fmt.Sprintf(`
|
res, err := db.Exec(fmt.Sprintf(`
|
||||||
INSERT INTO task (projectChange, max_retries, recipe, priority, max_assign_time, hash64,verification_count)
|
INSERT INTO task (project, max_retries, recipe, priority, max_assign_time, hash64,verification_count)
|
||||||
VALUES ($1,$2,$3,$4,$5,NULLIF(%d, 0),$6)`, hash64),
|
VALUES ($1,$2,$3,$4,$5,NULLIF(%d, 0),$6)`, hash64),
|
||||||
project, task.MaxRetries, task.Recipe, task.Priority, task.MaxAssignTime, task.VerificationCount)
|
project, task.MaxRetries, task.Recipe, task.Priority, task.MaxAssignTime, task.VerificationCount)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -73,11 +73,11 @@ func (database *Database) GetTask(worker *Worker) *Task {
|
|||||||
(
|
(
|
||||||
SELECT task.id
|
SELECT task.id
|
||||||
FROM task
|
FROM task
|
||||||
INNER JOIN projectChange project on task.projectChange = project.id
|
INNER JOIN project project on task.project = project.id
|
||||||
LEFT JOIN worker_verifies_task wvt on task.id = wvt.task AND wvt.worker=$1
|
LEFT JOIN worker_verifies_task wvt on task.id = wvt.task AND wvt.worker=$1
|
||||||
WHERE assignee IS NULL AND task.status=1
|
WHERE assignee IS NULL AND task.status=1
|
||||||
AND (project.public OR EXISTS (
|
AND (project.public OR EXISTS (
|
||||||
SELECT 1 FROM worker_has_access_to_project a WHERE a.worker=$1 AND a.projectChange=project.id
|
SELECT 1 FROM worker_has_access_to_project a WHERE a.worker=$1 AND a.project=project.id
|
||||||
))
|
))
|
||||||
AND wvt.task IS NULL
|
AND wvt.task IS NULL
|
||||||
ORDER BY project.priority DESC, task.priority DESC
|
ORDER BY project.priority DESC, task.priority DESC
|
||||||
@ -107,10 +107,10 @@ func (database *Database) GetTask(worker *Worker) *Task {
|
|||||||
func getTaskById(id int64, db *sql.DB) *Task {
|
func getTaskById(id int64, db *sql.DB) *Task {
|
||||||
|
|
||||||
row := db.QueryRow(`
|
row := db.QueryRow(`
|
||||||
SELECT task.id, task.priority, task.projectChange, assignee, retries, max_retries,
|
SELECT task.id, task.priority, task.project, assignee, retries, max_retries,
|
||||||
status, recipe, max_assign_time, assign_time, verification_count, project.priority, project.name,
|
status, recipe, max_assign_time, assign_time, verification_count, project.priority, project.name,
|
||||||
project.clone_url, project.git_repo, project.version, project.motd, project.public, COALESCE(project.chain,0) FROM task
|
project.clone_url, project.git_repo, project.version, project.motd, project.public, COALESCE(project.chain,0) FROM task
|
||||||
INNER JOIN projectChange project ON task.projectChange = project.id
|
INNER JOIN project project ON task.project = project.id
|
||||||
WHERE task.id=$1`, id)
|
WHERE task.id=$1`, id)
|
||||||
project := &Project{}
|
project := &Project{}
|
||||||
task := &Task{}
|
task := &Task{}
|
||||||
@ -176,11 +176,11 @@ func (database *Database) GetTaskFromProject(worker *Worker, projectId int64) *T
|
|||||||
(
|
(
|
||||||
SELECT task.id
|
SELECT task.id
|
||||||
FROM task
|
FROM task
|
||||||
INNER JOIN projectChange project on task.projectChange = project.id
|
INNER JOIN project project on task.project = project.id
|
||||||
LEFT JOIN worker_verifies_task wvt on task.id = wvt.task AND wvt.worker=$1
|
LEFT JOIN worker_verifies_task wvt on task.id = wvt.task AND wvt.worker=$1
|
||||||
WHERE assignee IS NULL AND project.id=$2 AND status=1
|
WHERE assignee IS NULL AND project.id=$2 AND status=1
|
||||||
AND (project.public OR EXISTS (
|
AND (project.public OR EXISTS (
|
||||||
SELECT 1 FROM worker_has_access_to_project a WHERE a.worker=$1 AND a.projectChange=$2
|
SELECT 1 FROM worker_has_access_to_project a WHERE a.worker=$1 AND a.project=$2
|
||||||
))
|
))
|
||||||
AND wvt.task IS NULL
|
AND wvt.task IS NULL
|
||||||
ORDER BY task.priority DESC
|
ORDER BY task.priority DESC
|
||||||
|
@ -56,7 +56,7 @@ func (database *Database) GetWorker(id int64) *Worker {
|
|||||||
func (database *Database) GrantAccess(workerId int64, projectId int64) bool {
|
func (database *Database) GrantAccess(workerId int64, projectId int64) bool {
|
||||||
|
|
||||||
db := database.getDB()
|
db := database.getDB()
|
||||||
res, err := db.Exec(`INSERT INTO worker_has_access_to_project (worker, projectChange) VALUES ($1,$2)
|
res, err := db.Exec(`INSERT INTO worker_has_access_to_project (worker, project) VALUES ($1,$2)
|
||||||
ON CONFLICT DO NOTHING`,
|
ON CONFLICT DO NOTHING`,
|
||||||
workerId, projectId)
|
workerId, projectId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -81,7 +81,7 @@ func (database *Database) GrantAccess(workerId int64, projectId int64) bool {
|
|||||||
func (database *Database) RemoveAccess(workerId int64, projectId int64) bool {
|
func (database *Database) RemoveAccess(workerId int64, projectId int64) bool {
|
||||||
|
|
||||||
db := database.getDB()
|
db := database.getDB()
|
||||||
res, err := db.Exec(`DELETE FROM worker_has_access_to_project WHERE worker=$1 AND projectChange=$2`,
|
res, err := db.Exec(`DELETE FROM worker_has_access_to_project WHERE worker=$1 AND project=$2`,
|
||||||
workerId, projectId)
|
workerId, projectId)
|
||||||
handleErr(err)
|
handleErr(err)
|
||||||
|
|
||||||
@ -118,8 +118,8 @@ func (database *Database) SaveAccessRequest(worker *Worker, projectId int64) boo
|
|||||||
db := database.getDB()
|
db := database.getDB()
|
||||||
|
|
||||||
res, err := db.Exec(`INSERT INTO worker_requests_access_to_project
|
res, err := db.Exec(`INSERT INTO worker_requests_access_to_project
|
||||||
SELECT $1, id FROM projectChange WHERE id=$2 AND NOT projectChange.public
|
SELECT $1, id FROM project WHERE id=$2 AND NOT project.public
|
||||||
AND NOT EXISTS(SELECT * FROM worker_has_access_to_project WHERE worker=$1 AND projectChange=$2)`,
|
AND NOT EXISTS(SELECT * FROM worker_has_access_to_project WHERE worker=$1 AND project=$2)`,
|
||||||
worker.Id, projectId)
|
worker.Id, projectId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false
|
return false
|
||||||
@ -139,13 +139,13 @@ func (database *Database) AcceptAccessRequest(worker *Worker, projectId int64) b
|
|||||||
db := database.getDB()
|
db := database.getDB()
|
||||||
|
|
||||||
res, err := db.Exec(`DELETE FROM worker_requests_access_to_project
|
res, err := db.Exec(`DELETE FROM worker_requests_access_to_project
|
||||||
WHERE worker=$1 AND projectChange=$2`)
|
WHERE worker=$1 AND project=$2`)
|
||||||
handleErr(err)
|
handleErr(err)
|
||||||
|
|
||||||
rowsAffected, _ := res.RowsAffected()
|
rowsAffected, _ := res.RowsAffected()
|
||||||
if rowsAffected == 1 {
|
if rowsAffected == 1 {
|
||||||
_, err := db.Exec(`INSERT INTO worker_has_access_to_project
|
_, err := db.Exec(`INSERT INTO worker_has_access_to_project
|
||||||
(worker, projectChange) VALUES ($1,$2)`,
|
(worker, project) VALUES ($1,$2)`,
|
||||||
worker.Id, projectId)
|
worker.Id, projectId)
|
||||||
handleErr(err)
|
handleErr(err)
|
||||||
}
|
}
|
||||||
@ -162,7 +162,7 @@ func (database *Database) RejectAccessRequest(worker *Worker, projectId int64) b
|
|||||||
db := database.getDB()
|
db := database.getDB()
|
||||||
|
|
||||||
res, err := db.Exec(`DELETE FROM worker_requests_access_to_project
|
res, err := db.Exec(`DELETE FROM worker_requests_access_to_project
|
||||||
WHERE worker=$1 AND projectChange=$2`, worker.Id, projectId)
|
WHERE worker=$1 AND project=$2`, worker.Id, projectId)
|
||||||
handleErr(err)
|
handleErr(err)
|
||||||
|
|
||||||
rowsAffected, _ := res.RowsAffected()
|
rowsAffected, _ := res.RowsAffected()
|
||||||
@ -180,7 +180,7 @@ func (database *Database) GetAllAccessRequests(projectId int64) *[]Worker {
|
|||||||
|
|
||||||
rows, err := db.Query(`SELECT id, alias, created FROM worker_requests_access_to_project
|
rows, err := db.Query(`SELECT id, alias, created FROM worker_requests_access_to_project
|
||||||
INNER JOIN worker w on worker_requests_access_to_project.worker = w.id
|
INNER JOIN worker w on worker_requests_access_to_project.worker = w.id
|
||||||
WHERE projectChange=$1`,
|
WHERE project=$1`,
|
||||||
projectId)
|
projectId)
|
||||||
handleErr(err)
|
handleErr(err)
|
||||||
|
|
||||||
|
@ -245,7 +245,7 @@ func TestUpdateProjectConstraintFail(t *testing.T) {
|
|||||||
|
|
||||||
func createProject(req api.CreateProjectRequest) *api.CreateProjectResponse {
|
func createProject(req api.CreateProjectRequest) *api.CreateProjectResponse {
|
||||||
|
|
||||||
r := Post("/projectChange/create", req, nil)
|
r := Post("/project/create", req, nil)
|
||||||
|
|
||||||
var resp api.CreateProjectResponse
|
var resp api.CreateProjectResponse
|
||||||
data, _ := ioutil.ReadAll(r.Body)
|
data, _ := ioutil.ReadAll(r.Body)
|
||||||
@ -257,7 +257,7 @@ func createProject(req api.CreateProjectRequest) *api.CreateProjectResponse {
|
|||||||
|
|
||||||
func getProject(id int64) (*api.GetProjectResponse, *http.Response) {
|
func getProject(id int64) (*api.GetProjectResponse, *http.Response) {
|
||||||
|
|
||||||
r := Get(fmt.Sprintf("/projectChange/get/%d", id), nil)
|
r := Get(fmt.Sprintf("/project/get/%d", id), nil)
|
||||||
|
|
||||||
var getResp api.GetProjectResponse
|
var getResp api.GetProjectResponse
|
||||||
data, _ := ioutil.ReadAll(r.Body)
|
data, _ := ioutil.ReadAll(r.Body)
|
||||||
@ -269,7 +269,7 @@ func getProject(id int64) (*api.GetProjectResponse, *http.Response) {
|
|||||||
|
|
||||||
func updateProject(request api.UpdateProjectRequest, pid int64) *api.UpdateProjectResponse {
|
func updateProject(request api.UpdateProjectRequest, pid int64) *api.UpdateProjectResponse {
|
||||||
|
|
||||||
r := Post(fmt.Sprintf("/projectChange/update/%d", pid), request, nil)
|
r := Post(fmt.Sprintf("/project/update/%d", pid), request, nil)
|
||||||
|
|
||||||
var resp api.UpdateProjectResponse
|
var resp api.UpdateProjectResponse
|
||||||
data, _ := ioutil.ReadAll(r.Body)
|
data, _ := ioutil.ReadAll(r.Body)
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
|
|
||||||
func TestCreateTaskValid(t *testing.T) {
|
func TestCreateTaskValid(t *testing.T) {
|
||||||
|
|
||||||
//Make sure there is always a projectChange for id:1
|
//Make sure there is always a project for id:1
|
||||||
createProject(api.CreateProjectRequest{
|
createProject(api.CreateProjectRequest{
|
||||||
Name: "Some Test name",
|
Name: "Some Test name",
|
||||||
Version: "Test Version",
|
Version: "Test Version",
|
||||||
@ -132,9 +132,9 @@ func TestCreateTaskInvalidRecipe(t *testing.T) {
|
|||||||
|
|
||||||
func TestCreateGetTask(t *testing.T) {
|
func TestCreateGetTask(t *testing.T) {
|
||||||
|
|
||||||
//Make sure there is always a projectChange for id:1
|
//Make sure there is always a project for id:1
|
||||||
resp := createProject(api.CreateProjectRequest{
|
resp := createProject(api.CreateProjectRequest{
|
||||||
Name: "My projectChange",
|
Name: "My project",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
CloneUrl: "http://github.com/test/test",
|
CloneUrl: "http://github.com/test/test",
|
||||||
GitRepo: "myrepo",
|
GitRepo: "myrepo",
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import {AppPage} from './app.po';
|
import {AppPage} from './app.po';
|
||||||
import {browser, logging} from 'protractor';
|
import {browser, logging} from 'protractor';
|
||||||
|
|
||||||
describe('workspace-projectChange App', () => {
|
describe('workspace-project App', () => {
|
||||||
let page: AppPage;
|
let page: AppPage;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
@ -42,7 +42,8 @@
|
|||||||
<ng-container matColumnDef="message">
|
<ng-container matColumnDef="message">
|
||||||
<mat-header-cell mat-sort-header
|
<mat-header-cell mat-sort-header
|
||||||
*matHeaderCellDef>{{"logs.message" | translate}}</mat-header-cell>
|
*matHeaderCellDef>{{"logs.message" | translate}}</mat-header-cell>
|
||||||
<mat-cell style="flex: 0 0 30em" *matCellDef="let entry"> {{entry.message}} </mat-cell>
|
<mat-cell class="text-mono" style="flex: 0 0 30em"
|
||||||
|
*matCellDef="let entry"> {{entry.message}} </mat-cell>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<ng-container matColumnDef="data">
|
<ng-container matColumnDef="data">
|
||||||
<mat-header-cell mat-sort-header *matHeaderCellDef>{{"logs.data" | translate}}</mat-header-cell>
|
<mat-header-cell mat-sort-header *matHeaderCellDef>{{"logs.data" | translate}}</mat-header-cell>
|
||||||
|
@ -12,7 +12,9 @@
|
|||||||
|
|
||||||
<p *ngIf="project">
|
<p *ngIf="project">
|
||||||
{{"project.git_repo" | translate}}:
|
{{"project.git_repo" | translate}}:
|
||||||
<a target="_blank" [href]="project['clone_url']">{{project.git_repo}}</a>
|
<a target="_blank" [href]="project['clone_url']"
|
||||||
|
*ngIf="isSafeUrl(project['clone_url'])">{{project.git_repo}}</a>
|
||||||
|
<span class="text-mono" *ngIf="!isSafeUrl(project['clone_url'])">{{project['git_repo']}}</span>
|
||||||
</p>
|
</p>
|
||||||
<p>{{"project.motd" | translate}}:</p>
|
<p>{{"project.motd" | translate}}:</p>
|
||||||
<pre *ngIf="project">{{project.motd}}</pre>
|
<pre *ngIf="project">{{project.motd}}</pre>
|
||||||
|
@ -44,13 +44,17 @@ export class ProjectDashboardComponent implements OnInit {
|
|||||||
constructor(private apiService: ApiService, private route: ActivatedRoute) {
|
constructor(private apiService: ApiService, private route: ActivatedRoute) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.route.params.subscribe(params => {
|
this.route.params.subscribe(params => {
|
||||||
this.projectId = params["id"];
|
this.projectId = params["id"];
|
||||||
this.getProject();
|
this.getProject();
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public isSafeUrl(url: string) {
|
||||||
|
if (url.substr(0, "http".length) == "http") {
|
||||||
|
return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public refresh() {
|
public refresh() {
|
||||||
|
@ -20,6 +20,10 @@ export class ProjectListComponent implements OnInit {
|
|||||||
this.getProjects()
|
this.getProjects()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
refresh() {
|
||||||
|
this.getProjects();
|
||||||
|
}
|
||||||
|
|
||||||
getProjects() {
|
getProjects() {
|
||||||
this.apiService.getProjects().subscribe(data => this.projects = data["projects"]);
|
this.apiService.getProjects().subscribe(data => this.projects = data["projects"]);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,3 @@
|
|||||||
.text-mono {
|
|
||||||
font-family: Hack, Courier, "Courier New", monospace;
|
|
||||||
color: #ff4081;
|
|
||||||
}
|
|
||||||
|
|
||||||
button {
|
button {
|
||||||
margin-left: 15px;
|
margin-left: 15px;
|
||||||
|
@ -38,7 +38,7 @@ export class ProjectPermsComponent implements OnInit {
|
|||||||
|
|
||||||
private getProject() {
|
private getProject() {
|
||||||
this.apiService.getProject(this.projectId).subscribe(data => {
|
this.apiService.getProject(this.projectId).subscribe(data => {
|
||||||
this.project = data["projectChange"]
|
this.project = data["project"]
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,3 +94,8 @@ pre {
|
|||||||
margin-top: 2em !important;
|
margin-top: 2em !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.text-mono {
|
||||||
|
font-family: Hack, Courier, "Courier New", monospace;
|
||||||
|
color: #ff4081;
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user