challenge-sync-airbus: Add an option to not search for exercice validation

This commit is contained in:
nemunaire 2023-04-03 12:04:48 +02:00
parent bd9d9e9402
commit 1bd30632d3
2 changed files with 6 additions and 1 deletions

View File

@ -24,6 +24,7 @@ func main() {
flag.StringVar(&TeamsDir, "teams", "./TEAMS", "Base directory where save teams JSON files")
var debugINotify = flag.Bool("debuginotify", false, "Show skipped inotofy events")
flag.BoolVar(&skipInitialSync, "skipinitialsync", skipInitialSync, "Skip the initial synchronization")
flag.BoolVar(&noValidateChallenge, "no-validate-challenge", noValidateChallenge, "Consider challenge validation as a standard award (if each exercice hasn't been imported on their side)")
daemon := flag.Bool("watch", false, "Enable daemon mode by watching the directory")
tspath := flag.String("timestamp-file", "./REMOTE/timestamp", "Path to the file storing the last timestamp")
exercicespath := flag.String("exercices-file", "./REMOTE/exercices-bindings.json", "Path to the file containing the ID bindings")

View File

@ -10,6 +10,10 @@ import (
"srs.epita.fr/fic-server/libfic"
)
var (
noValidateChallenge bool
)
type Walker struct {
LastSync map[AirbusUserId]time.Time
Exercices AirbusExercicesBindings
@ -87,7 +91,7 @@ func (w *Walker) TreatScoreGrid(path string, airbusTeamId AirbusUserId) error {
maxts = row.Time
}
if row.Time.After(w.LastSync[airbusTeamId]) {
if row.Reason == "Validation" {
if !noValidateChallenge && row.Reason == "Validation" {
err = w.API.ValidateChallengeFromUser(airbusTeamId, w.Exercices[row.IdExercice])
} else {
err = w.API.AwardUser(airbusTeamId, int64(row.Points*row.Coeff*w.Coeff), row.Reason)