Skip to content

Commit

Permalink
add response to the admin get surveys API
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Vitanov committed Jul 23, 2024
1 parent f425958 commit 414d2fd
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions driver/web/apis_admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"io/ioutil"
"log"
"net/http"
"sort"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -250,6 +251,12 @@ func (h AdminAPIsHandler) getSurveys(l *logs.Log, r *http.Request, claims *token
return l.HTTPResponseErrorAction(logutils.ActionGet, model.TypeSurvey, nil, err, http.StatusInternalServerError, true)
}

surveys := surveysToSurveyRequests(resData)

sort.Slice(surveys, func(i, j int) bool {
return surveys[i].DateCreated.After(surveys[j].DateCreated)
})

rdata, err := json.Marshal(resData)
if err != nil {
return l.HTTPResponseErrorAction(logutils.ActionMarshal, logutils.TypeResponseBody, nil, err, http.StatusInternalServerError, false)
Expand Down

0 comments on commit 414d2fd

Please sign in to comment.