From 0f9d56fcbf3d41ed3176f6e882028c6d6762d558 Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Wed, 18 Sep 2024 16:45:08 +0200 Subject: [PATCH] qa: Refactor work attribution --- qa/api/todo.go | 31 ++++++++++- qa/ui/src/routes/teams/+page.svelte | 85 +++++++++++++++++++++++------ 2 files changed, 97 insertions(+), 19 deletions(-) diff --git a/qa/api/todo.go b/qa/api/todo.go index 2b2461a1..3ee45c99 100644 --- a/qa/api/todo.go +++ b/qa/api/todo.go @@ -241,8 +241,10 @@ func deleteQATodo(c *gin.Context) { } type QAAssignWork struct { - Turns int `json:"turns"` - Start int `json:"start"` + Turns int `json:"turns"` + Start int `json:"start"` + TeamPrefix string `json:"team_prefix"` + TeamAssistants string `json:"team_assistants"` } func assignWork(c *gin.Context) { @@ -254,6 +256,12 @@ func assignWork(c *gin.Context) { if uaw.Turns == 0 { uaw.Turns = 1 } + if uaw.TeamPrefix == "" { + uaw.TeamPrefix = "FIC Groupe " + } + if uaw.TeamAssistants == "" { + uaw.TeamAssistants = "assistants" + } teams, err := fic.GetTeams() if err != nil { @@ -265,7 +273,7 @@ func assignWork(c *gin.Context) { // Remove assistant team for tid := len(teams) - 1; tid >= 0; tid-- { team := teams[tid] - if strings.Contains(strings.ToLower(team.Name), "assistants") { + if strings.Contains(strings.ToLower(team.Name), uaw.TeamAssistants) { teams = append(teams[:tid], teams[tid+1:]...) } } @@ -277,10 +285,27 @@ func assignWork(c *gin.Context) { return } + // Struct to store reported team (due to owned exercice) + var teamIdStack []int64 + for i := 0; i < uaw.Turns; i++ { for eid, ex := range exercices { team := teams[(uaw.Start+eid+uaw.Turns*i)%len(teams)] + if len(teamIdStack) > 0 { + teamIdStack = append(teamIdStack, team.Id) + team, _ = fic.GetTeam(teamIdStack[0]) + teamIdStack = append([]int64{}, teamIdStack[1:]...) + } + + j := 0 + // Find a team not responsible for this exercice + for (strings.Contains(ex.Path, "grp") && strings.Contains(ex.Path, "-grp"+strings.TrimPrefix(team.Name, uaw.TeamPrefix)+"-")) || (!strings.Contains(ex.Path, "grp") && strings.HasPrefix(ex.Path, strings.TrimPrefix(team.Name, uaw.TeamPrefix)+"-")) { + j += 1 + teamIdStack = append(teamIdStack, team.Id) + team = teams[(uaw.Start+eid+uaw.Turns*i+j)%len(teams)] + } + _, err := team.NewQATodo(ex.Id) if err != nil { c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"errmsg": err.Error()}) diff --git a/qa/ui/src/routes/teams/+page.svelte b/qa/ui/src/routes/teams/+page.svelte index 344a1eec..3df8bb60 100644 --- a/qa/ui/src/routes/teams/+page.svelte +++ b/qa/ui/src/routes/teams/+page.svelte @@ -6,7 +6,10 @@ import { Button, Container, + FormGroup, Input, + Label, + Spinner, Table, } from '@sveltestrap/sveltestrap'; @@ -21,16 +24,35 @@ let start = 0; let turns = 3; + let team_prefix = ""; + let team_assistants = ""; + let assignInProgress = false; async function assignExercices() { + assignInProgress = true; const res = await fetch(`api/qa_assign_work`, { method: 'POST', headers: {'Accept': 'application/json'}, body: JSON.stringify({ start, turns, + team_prefix, + team_assistants, }), }) + if (res.status == 200) { + teams.refresh(); + assignInProgress = false; + } else { + assignInProgress = false; + throw new Error((await res.json()).errmsg); + } + } + + async function deleteAssignation() { + const res = await fetch(`api/qa_assign_work`, { + method: 'DELETE', + }); if (res.status == 200) { teams.refresh(); } else { @@ -40,22 +62,9 @@ -
-

- Équipes -

-
- - - -
-
+

+ Équipes +

@@ -93,4 +102,48 @@ {/each} + +


+

+ Assigner des exercices aux équipes +

+ +
+ + + +

+ Incrémenter de 1 pour chaque nouveau challenge blanc, cela décale l'attribution des exercices. +

+
+ + + + + + + + + + + + + + +