From 2c20b9dc50a34837122e08b767f068532819acbf Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Mon, 1 Mar 2021 18:50:39 +0100 Subject: [PATCH] Sort surveys by promo first, then start_date --- surveys.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/surveys.go b/surveys.go index 5556c3e..71334bf 100644 --- a/surveys.go +++ b/surveys.go @@ -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 {