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 {