sync: Better perform exception in exercices

This commit is contained in:
nemunaire 2023-07-09 19:05:58 +02:00
commit dc83efa868
8 changed files with 45 additions and 34 deletions

View file

@ -58,7 +58,7 @@ func SpeedySyncDeep(i Importer) (errs SyncReport) {
for tid, theme := range themes {
DeepSyncProgress = 3 + uint8(tid)*themeStep
seerrs := SyncExercices(i, theme, exceptions[theme.Path])
ex_exceptions, seerrs := SyncExercices(i, theme, exceptions[theme.Path])
for _, seerr := range seerrs {
errs.Themes[theme.Name] = append(errs.Themes[theme.Name], seerr.Error())
}
@ -72,13 +72,13 @@ func SpeedySyncDeep(i Importer) (errs SyncReport) {
log.Printf("Speedy synchronization in progress: %d/255 - doing Theme %q, Exercice %q: %q\n", DeepSyncProgress, theme.Name, exercice.Title, exercice.Path)
DeepSyncProgress = 3 + uint8(tid)*themeStep + uint8(eid)*exerciceStep
flagsBindings, ferrs := SyncExerciceFlags(i, exercice, exceptions[theme.Path])
flagsBindings, ferrs := SyncExerciceFlags(i, exercice, ex_exceptions[eid])
for _, ferr := range ferrs {
errs.Themes[theme.Name] = append(errs.Themes[theme.Name], ferr.Error())
}
DeepSyncProgress += exerciceStep / 2
_, herrs := SyncExerciceHints(i, exercice, flagsBindings, exceptions[theme.Path])
_, herrs := SyncExerciceHints(i, exercice, flagsBindings, ex_exceptions[eid])
for _, herr := range herrs {
errs.Themes[theme.Name] = append(errs.Themes[theme.Name], herr.Error())
}
@ -193,11 +193,13 @@ func EditDeepReport(errs *SyncReport, erase bool) {
// SyncThemeDeep performs a recursive synchronisation: from challenges to challenge items.
func SyncThemeDeep(i Importer, theme *fic.Theme, tid int, themeStep uint8, exceptions *CheckExceptions) (errs []error) {
var ex_exceptions map[int]*CheckExceptions
oneThemeDeepSync.Lock()
defer oneThemeDeepSync.Unlock()
DeepSyncProgress = 3 + uint8(tid)*themeStep
errs = SyncExercices(i, theme, exceptions)
ex_exceptions, errs = SyncExercices(i, theme, exceptions)
if exercices, err := theme.GetExercices(); err == nil && len(exercices) > 0 {
var exerciceStep uint8 = themeStep / uint8(len(exercices))
@ -205,14 +207,14 @@ func SyncThemeDeep(i Importer, theme *fic.Theme, tid int, themeStep uint8, excep
log.Printf("Deep synchronization in progress: %d/255 - doing Theme %q, Exercice %q: %q\n", DeepSyncProgress, theme.Name, exercice.Title, exercice.Path)
DeepSyncProgress = 3 + uint8(tid)*themeStep + uint8(eid)*exerciceStep
errs = append(errs, SyncExerciceFiles(i, exercice, exceptions)...)
errs = append(errs, SyncExerciceFiles(i, exercice, ex_exceptions[eid])...)
DeepSyncProgress += exerciceStep / 3
flagsBindings, ferrs := SyncExerciceFlags(i, exercice, exceptions)
flagsBindings, ferrs := SyncExerciceFlags(i, exercice, ex_exceptions[eid])
errs = append(errs, ferrs...)
DeepSyncProgress += exerciceStep / 3
_, herrs := SyncExerciceHints(i, exercice, flagsBindings, exceptions)
_, herrs := SyncExerciceHints(i, exercice, flagsBindings, ex_exceptions[eid])
errs = append(errs, herrs...)
}
}