mirror of
https://github.com/simon987/task_tracker.git
synced 2025-12-12 06:28:50 +00:00
Added i18n, started working on monitoring
This commit is contained in:
@@ -122,84 +122,6 @@ func TestGetProjectNotFound(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetProjectStats(t *testing.T) {
|
||||
|
||||
r := createProject(api.CreateProjectRequest{
|
||||
Motd: "motd",
|
||||
Name: "Name",
|
||||
Version: "version",
|
||||
CloneUrl: "http://github.com/drone/test",
|
||||
GitRepo: "drone/test",
|
||||
Priority: 3,
|
||||
Public: true,
|
||||
})
|
||||
|
||||
pid := r.Id
|
||||
worker := genWid()
|
||||
|
||||
createTask(api.CreateTaskRequest{
|
||||
Priority: 1,
|
||||
Project: pid,
|
||||
MaxRetries: 0,
|
||||
Recipe: "{}",
|
||||
}, worker)
|
||||
createTask(api.CreateTaskRequest{
|
||||
Priority: 2,
|
||||
Project: pid,
|
||||
MaxRetries: 0,
|
||||
Recipe: "{}",
|
||||
}, worker)
|
||||
createTask(api.CreateTaskRequest{
|
||||
Priority: 3,
|
||||
Project: pid,
|
||||
MaxRetries: 0,
|
||||
Recipe: "{}",
|
||||
}, worker)
|
||||
|
||||
stats := getProjectStats(pid)
|
||||
|
||||
if stats.Ok != true {
|
||||
t.Error()
|
||||
}
|
||||
|
||||
if stats.Stats.Project.Id != pid {
|
||||
t.Error()
|
||||
}
|
||||
|
||||
if stats.Stats.NewTaskCount != 3 {
|
||||
t.Error()
|
||||
}
|
||||
|
||||
if stats.Stats.Assignees[0].Assignee != "unassigned" {
|
||||
t.Error()
|
||||
}
|
||||
if stats.Stats.Assignees[0].TaskCount != 3 {
|
||||
t.Error()
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetProjectStatsNotFound(t *testing.T) {
|
||||
|
||||
r := createProject(api.CreateProjectRequest{
|
||||
Motd: "eeeeeeeeej",
|
||||
Name: "Namaaaaaaaaaaaa",
|
||||
Version: "versionsssssssss",
|
||||
CloneUrl: "http://github.com/drone/test1",
|
||||
GitRepo: "drone/test1",
|
||||
Priority: 1,
|
||||
})
|
||||
s := getProjectStats(r.Id)
|
||||
|
||||
if s.Ok != true {
|
||||
t.Error()
|
||||
}
|
||||
|
||||
if s.Stats == nil {
|
||||
t.Error()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestUpdateProjectValid(t *testing.T) {
|
||||
|
||||
pid := createProject(api.CreateProjectRequest{
|
||||
@@ -337,18 +259,6 @@ func getProject(id int64) (*api.GetProjectResponse, *http.Response) {
|
||||
return &getResp, r
|
||||
}
|
||||
|
||||
func getProjectStats(id int64) *api.GetProjectStatsResponse {
|
||||
|
||||
r := Get(fmt.Sprintf("/project/stats/%d", id), nil)
|
||||
|
||||
var getResp api.GetProjectStatsResponse
|
||||
data, _ := ioutil.ReadAll(r.Body)
|
||||
err := json.Unmarshal(data, &getResp)
|
||||
handleErr(err)
|
||||
|
||||
return &getResp
|
||||
}
|
||||
|
||||
func updateProject(request api.UpdateProjectRequest, pid int64) *api.UpdateProjectResponse {
|
||||
|
||||
r := Post(fmt.Sprintf("/project/update/%d", pid), request, nil)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
DROP TABLE IF EXISTS worker_identity, worker, project, task, log_entry,
|
||||
worker_has_access_to_project, manager, manager_has_role_on_project, project_monitoring, worker_verifies_task;
|
||||
worker_has_access_to_project, manager, manager_has_role_on_project, project_monitoring_snapshot,
|
||||
worker_verifies_task;
|
||||
DROP TYPE IF EXISTS status;
|
||||
DROP TYPE IF EXISTS log_level;
|
||||
|
||||
@@ -87,12 +88,15 @@ CREATE TABLE manager_has_role_on_project
|
||||
project INTEGER REFERENCES project (id)
|
||||
);
|
||||
|
||||
CREATE TABLE project_monitoring
|
||||
CREATE TABLE project_monitoring_snapshot
|
||||
(
|
||||
project INT REFERENCES project (id),
|
||||
new_task_count INT,
|
||||
failed_task_count INT,
|
||||
closed_task_count INT
|
||||
project INT REFERENCES project (id),
|
||||
new_task_count INT,
|
||||
failed_task_count INT,
|
||||
closed_task_count INT,
|
||||
awaiting_verification_task_count INT,
|
||||
worker_access_count INT,
|
||||
timestamp INT
|
||||
);
|
||||
|
||||
CREATE OR REPLACE FUNCTION on_task_delete_proc() RETURNS TRIGGER AS
|
||||
|
||||
Reference in New Issue
Block a user