qa: Refactor gitlab use
This commit is contained in:
parent
c31f76e9c3
commit
d4cad767eb
7 changed files with 145 additions and 54 deletions
31
qa/api/qa.go
31
qa/api/qa.go
|
@ -75,17 +75,44 @@ func qaCommentHandler(c *gin.Context) {
|
|||
c.Next()
|
||||
}
|
||||
|
||||
type QAQuery struct {
|
||||
*fic.QAQuery
|
||||
ForgeLink string `json:"forge_link,omitempty"`
|
||||
}
|
||||
|
||||
func getExerciceQA(c *gin.Context) {
|
||||
exercice := c.MustGet("exercice").(*fic.Exercice)
|
||||
|
||||
qa, err := exercice.GetQAQueries()
|
||||
qas, err := exercice.GetQAQueries()
|
||||
if err != nil {
|
||||
log.Println("Unable to GetQAQueries: ", err.Error())
|
||||
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"errmsg": fmt.Sprintf("Unable to list QA entries: %s", err.Error())})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, qa)
|
||||
forgelink, err := GitLab_getExerciceId(exercice)
|
||||
if err != nil {
|
||||
log.Println("Unable to make request to admin:", err.Error())
|
||||
c.JSON(http.StatusOK, qas)
|
||||
return
|
||||
}
|
||||
|
||||
var res []*QAQuery
|
||||
for _, qa := range qas {
|
||||
if qa.Exported != nil {
|
||||
res = append(res, &QAQuery{
|
||||
qa,
|
||||
gitlabBaseURL + "/" + forgelink + fmt.Sprintf("/-/issues/%d", *qa.Exported),
|
||||
})
|
||||
} else {
|
||||
res = append(res, &QAQuery{
|
||||
qa,
|
||||
"",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, res)
|
||||
}
|
||||
|
||||
func exportQA(c *gin.Context) {
|
||||
|
|
Reference in a new issue