Fixed "answered" API error
This commit is contained in:
parent
79ced40470
commit
9de713fc6a
|
@ -156,9 +156,6 @@ func Answered(userID string) []JournalRequest {
|
|||
AND "lastStatus" = 'Answered'
|
||||
ORDER BY "asOf" DESC`,
|
||||
userID)
|
||||
if err == sql.ErrNoRows {
|
||||
return make([]JournalRequest, 0)
|
||||
}
|
||||
if err != nil {
|
||||
log.Print(err)
|
||||
return nil
|
||||
|
@ -177,6 +174,9 @@ func ByID(userID, reqID string) (*JournalRequest, bool) {
|
|||
&req.RequestID, &req.Text, &req.AsOf, &req.LastStatus,
|
||||
)
|
||||
if err != nil {
|
||||
if err == sql.ErrNoRows {
|
||||
return nil, true
|
||||
}
|
||||
log.Print(err)
|
||||
return nil, false
|
||||
}
|
||||
|
|
|
@ -83,6 +83,10 @@ func requestGet(c *routing.Context) error {
|
|||
if !ok {
|
||||
return sendError(c, errors.New("error retrieving request"))
|
||||
}
|
||||
if request == nil {
|
||||
c.Response.WriteHeader(404)
|
||||
return nil
|
||||
}
|
||||
return sendJSON(c, request)
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,14 @@ var routes = Routes{
|
|||
requestAdd,
|
||||
false,
|
||||
},
|
||||
// Must be above GetRequestByID
|
||||
Route{
|
||||
"GetAnsweredRequests",
|
||||
http.MethodGet,
|
||||
"/api/request/answered",
|
||||
requestsAnswered,
|
||||
false,
|
||||
},
|
||||
Route{
|
||||
"GetRequestByID",
|
||||
http.MethodGet,
|
||||
|
@ -77,13 +85,6 @@ var routes = Routes{
|
|||
requestGetNotes,
|
||||
false,
|
||||
},
|
||||
Route{
|
||||
"GetAnsweredRequests",
|
||||
http.MethodGet,
|
||||
"/api/request/answered",
|
||||
requestsAnswered,
|
||||
false,
|
||||
},
|
||||
// keep this route last
|
||||
Route{
|
||||
"StaticFiles",
|
||||
|
|
Loading…
Reference in New Issue
Block a user