Skip to content

Commit

Permalink
precision for created_after variable
Browse files Browse the repository at this point in the history
  • Loading branch information
prytoegrian authored and nitishm committed May 14, 2019
1 parent d277e54 commit 4178ff3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 14 deletions.
10 changes: 1 addition & 9 deletions internal/endpoints/attack.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package endpoints

import (
"net/http"
"net/url"
"vegeta-server/models"

"github.com/gin-gonic/gin"
Expand Down Expand Up @@ -40,16 +39,9 @@ func (e *Endpoints) GetAttackByIDEndpoint(c *gin.Context) {

// GetAttackEndpoint implements a handler for the GET /api/v1/attack endpoint
func (e *Endpoints) GetAttackEndpoint(c *gin.Context) {
var err error
filterMap := make(models.FilterParams)
filterMap["status"] = c.DefaultQuery("status", "")
b := c.DefaultQuery("created_before", "")
filterMap["created_before"], err = url.QueryUnescape(b)
if err != nil {
ginErrBadRequest(c, err)
return
}

filterMap["created_before"] = c.DefaultQuery("created_before", "")
filterMap["created_after"] = c.DefaultQuery("created_after", "")
resp := e.dispatcher.List(
//models.StatusFilter(status),
Expand Down
4 changes: 1 addition & 3 deletions models/attack.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ func CreationBeforeFilter(d string) Filter {
if d == "" {
return true
}

const layoutUser = "2006-01-02 15:04:05"
t, err := time.ParseInLocation(layoutUser, d, time.Local)
// If parsing failed, don't filter
Expand All @@ -77,8 +76,7 @@ func CreationAfterFilter(d string) Filter {
return true
}
const layoutUser = "2006-01-02 15:04:05"
t, err := time.Parse(layoutUser, d)

t, err := time.ParseInLocation(layoutUser, d, time.Local)
// If parsing failed, don't filter
if err != nil {
return true
Expand Down
4 changes: 2 additions & 2 deletions models/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func dataBefore() []testAll {
},
args: argsAll{
filterParams: FilterParams{
"created_before": "2020-02-05",
"created_before": "2020-02-05 01:00:02",
},
},
want: []AttackDetails{
Expand Down Expand Up @@ -269,7 +269,7 @@ func dataAfter() []testAll {
},
args: argsAll{
filterParams: FilterParams{
"created_after": "2020-05-17",
"created_after": "2020-05-17 01:02:03",
},
},
want: []AttackDetails{
Expand Down

0 comments on commit 4178ff3

Please sign in to comment.