Sort surveys by promo first, then start_date
continuous-integration/drone/push Build is passing Details

This commit is contained in:
nemunaire 2021-03-01 18:50:39 +01:00
parent f3fd0be2b8
commit 2c20b9dc50
1 changed files with 3 additions and 3 deletions

View File

@ -15,11 +15,11 @@ func init() {
router.GET("/api/surveys", apiAuthHandler(
func(u *User, _ httprouter.Params, _ []byte) HTTPResponse {
if u == nil {
return formatApiResponse(getSurveys(fmt.Sprintf("WHERE shown = TRUE AND NOW() > start_availability AND promo = %d", currentPromo)))
return formatApiResponse(getSurveys(fmt.Sprintf("WHERE shown = TRUE AND NOW() > start_availability AND promo = %d ORDER BY start_availability ASC", currentPromo)))
} else if u.IsAdmin {
return formatApiResponse(getSurveys(""))
return formatApiResponse(getSurveys("ORDER BY promo DESC, start_availability ASC"))
} else {
return formatApiResponse(getSurveys(fmt.Sprintf("WHERE shown = TRUE AND promo = %d", u.Promo)))
return formatApiResponse(getSurveys(fmt.Sprintf("WHERE shown = TRUE AND promo = %d ORDER BY start_availability ASC", u.Promo)))
}
}))
router.POST("/api/surveys", apiHandler(func(_ httprouter.Params, body []byte) HTTPResponse {