sync: Introduce repochecker-ack.txt to support check exceptions

This commit is contained in:
nemunaire 2022-10-29 17:03:57 +02:00
parent edde9f885d
commit fb368d79d1
17 changed files with 283 additions and 106 deletions

View file

@ -110,6 +110,14 @@ func ExerciceHandler(c *gin.Context) {
c.AbortWithStatusJSON(http.StatusNotFound, gin.H{"errmsg": "Exercice not found"})
return
}
theme, err = exercice.GetTheme()
if err != nil {
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"errmsg": "Unable to find the attached theme."})
return
}
c.Set("theme", theme)
}
c.Set("exercice", exercice)

View file

@ -52,8 +52,10 @@ func declareSyncRoutes(router *gin.RouterGroup) {
apiSyncDeepRoutes.POST("", func(c *gin.Context) {
theme := c.MustGet("theme").(*fic.Theme)
exceptions := sync.LoadException(sync.GlobalImporter, theme)
var st []string
for _, se := range sync.SyncThemeDeep(sync.GlobalImporter, theme, 0, 250) {
for _, se := range sync.SyncThemeDeep(sync.GlobalImporter, theme, 0, 250, exceptions) {
st = append(st, se.Error())
}
sync.EditDeepReport(&sync.SyncReport{Themes: map[string][]string{theme.Name: st}}, false)
@ -68,7 +70,8 @@ func declareSyncRoutes(router *gin.RouterGroup) {
apiSyncRoutes.POST("/fixurlids", fixAllURLIds)
apiSyncRoutes.POST("/themes", func(c *gin.Context) {
c.JSON(http.StatusOK, sync.SyncThemes(sync.GlobalImporter))
_, errs := sync.SyncThemes(sync.GlobalImporter)
c.JSON(http.StatusOK, errs)
})
apiSyncThemesRoutes := apiSyncRoutes.Group("/themes/:thid")
@ -130,25 +133,29 @@ func declareSyncRoutes(router *gin.RouterGroup) {
func declareSyncExercicesRoutes(router *gin.RouterGroup) {
router.POST("/exercices", func(c *gin.Context) {
theme := c.MustGet("theme").(*fic.Theme)
c.JSON(http.StatusOK, sync.SyncExercices(sync.GlobalImporter, theme))
exceptions := sync.LoadException(sync.GlobalImporter, theme)
c.JSON(http.StatusOK, sync.SyncExercices(sync.GlobalImporter, theme, exceptions))
})
apiSyncExercicesRoutes := router.Group("/exercices/:eid")
apiSyncExercicesRoutes.Use(ExerciceHandler)
apiSyncExercicesRoutes.POST("", func(c *gin.Context) {
theme, exists := c.Get("theme")
if !exists {
c.AbortWithStatusJSON(http.StatusNotImplemented, gin.H{"errmsg": "You should sync exercice only through a theme."})
return
}
theme := c.MustGet("theme").(*fic.Theme)
exceptions := sync.LoadException(sync.GlobalImporter, theme)
exercice := c.MustGet("exercice").(*fic.Exercice)
_, _, errs := sync.SyncExercice(sync.GlobalImporter, theme.(*fic.Theme), exercice.Path, nil)
_, _, errs := sync.SyncExercice(sync.GlobalImporter, theme, exercice.Path, nil, exceptions)
c.JSON(http.StatusOK, errs)
})
apiSyncExercicesRoutes.POST("/files", func(c *gin.Context) {
exercice := c.MustGet("exercice").(*fic.Exercice)
c.JSON(http.StatusOK, sync.SyncExerciceFiles(sync.GlobalImporter, exercice))
theme := c.MustGet("theme").(*fic.Theme)
exceptions := sync.LoadException(sync.GlobalImporter, theme)
c.JSON(http.StatusOK, sync.SyncExerciceFiles(sync.GlobalImporter, exercice, exceptions))
})
apiSyncExercicesRoutes.POST("/fixurlid", func(c *gin.Context) {
exercice := c.MustGet("exercice").(*fic.Exercice)
@ -167,13 +174,20 @@ func declareSyncExercicesRoutes(router *gin.RouterGroup) {
})
apiSyncExercicesRoutes.POST("/hints", func(c *gin.Context) {
exercice := c.MustGet("exercice").(*fic.Exercice)
_, errs := sync.SyncExerciceHints(sync.GlobalImporter, exercice, sync.ExerciceFlagsMap(sync.GlobalImporter, exercice))
theme := c.MustGet("theme").(*fic.Theme)
exceptions := sync.LoadException(sync.GlobalImporter, theme)
_, errs := sync.SyncExerciceHints(sync.GlobalImporter, exercice, sync.ExerciceFlagsMap(sync.GlobalImporter, exercice), exceptions)
c.JSON(http.StatusOK, errs)
})
apiSyncExercicesRoutes.POST("/flags", func(c *gin.Context) {
exercice := c.MustGet("exercice").(*fic.Exercice)
_, errs := sync.SyncExerciceFlags(sync.GlobalImporter, exercice)
_, herrs := sync.SyncExerciceHints(sync.GlobalImporter, exercice, sync.ExerciceFlagsMap(sync.GlobalImporter, exercice))
theme := c.MustGet("theme").(*fic.Theme)
exceptions := sync.LoadException(sync.GlobalImporter, theme)
_, errs := sync.SyncExerciceFlags(sync.GlobalImporter, exercice, exceptions)
_, herrs := sync.SyncExerciceHints(sync.GlobalImporter, exercice, sync.ExerciceFlagsMap(sync.GlobalImporter, exercice), exceptions)
c.JSON(http.StatusOK, append(errs, herrs...))
})
}
@ -214,8 +228,10 @@ func autoSync(c *gin.Context) {
}
}
exceptions := sync.LoadException(sync.GlobalImporter, theme)
var st []string
for _, se := range sync.SyncThemeDeep(sync.GlobalImporter, theme, 0, 250) {
for _, se := range sync.SyncThemeDeep(sync.GlobalImporter, theme, 0, 250, exceptions) {
st = append(st, se.Error())
}
sync.EditDeepReport(&sync.SyncReport{Themes: map[string][]string{theme.Name: st}}, false)