generator: Can perform synchronous generation
This commit is contained in:
parent
ec98e521dc
commit
1769938205
13 changed files with 214 additions and 81 deletions
|
@ -12,6 +12,7 @@ import (
|
|||
"strconv"
|
||||
"time"
|
||||
|
||||
"srs.epita.fr/fic-server/admin/generation"
|
||||
"srs.epita.fr/fic-server/admin/sync"
|
||||
"srs.epita.fr/fic-server/libfic"
|
||||
"srs.epita.fr/fic-server/settings"
|
||||
|
@ -47,6 +48,7 @@ func declareSettingsRoutes(router *gin.RouterGroup) {
|
|||
apiNextSettingsRoutes.DELETE("", deleteNextSettings)
|
||||
|
||||
router.POST("/reset", reset)
|
||||
router.POST("/full-generation", fullGeneration)
|
||||
|
||||
router.GET("/prod", func(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, IsProductionEnv)
|
||||
|
@ -80,6 +82,21 @@ func NextSettingsHandler(c *gin.Context) {
|
|||
c.Next()
|
||||
}
|
||||
|
||||
func fullGeneration(c *gin.Context) {
|
||||
resp, err := generation.FullGeneration()
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"errmsg": err.Error(),
|
||||
})
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
v, _ := io.ReadAll(resp.Body)
|
||||
c.JSON(resp.StatusCode, gin.H{
|
||||
"errmsg": v,
|
||||
})
|
||||
}
|
||||
|
||||
func getROSettings(c *gin.Context) {
|
||||
syncMtd := "Disabled"
|
||||
if sync.GlobalImporter != nil {
|
||||
|
|
Reference in a new issue