Skip to content

Commit

Permalink
🚑fix conversion of bool to map[string]interface{} by avoid keys named…
Browse files Browse the repository at this point in the history
… 'success' in iterations
  • Loading branch information
yedhink committed Apr 10, 2020
1 parent 59b2a69 commit 8701599
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions internal/server/api_location_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func LocDateFilter(q *Query, d map[string]interface{}, st *Storage, apiData map[
switch IsDate(q.Date) {
case true:
for key, value := range apiData {
if ValidDate(key, q.Date, st) {
if key != "success" && ValidDate(key, q.Date, st) {
// if loc length > 0 then only filterByLoc
if locExist == true {
d[key] = make(map[string]interface{}, len(q.Loc))
Expand Down Expand Up @@ -63,8 +63,10 @@ func (server *Server) Location(st *Storage) gin.HandlerFunc {
// just filter by loc parameter
case length > 0 && q.Date == "":
for key, value := range server.JsonData.All.Data {
d[key] = make(map[string]interface{}, len(q.Loc))
filterByLoc(value.(map[string]interface{}), d[key].(map[string]interface{}), q.Loc)
if key != "success" {
d[key] = make(map[string]interface{}, len(q.Loc))
filterByLoc(value.(map[string]interface{}), d[key].(map[string]interface{}), q.Loc)
}
}
// filter by both loc and date params
case length > 0 && q.Date != "":
Expand Down

0 comments on commit 8701599

Please sign in to comment.