Skip to content

Commit

Permalink
flipped grouping to work and added numbers to test
Browse files Browse the repository at this point in the history
  • Loading branch information
KonstanceH committed Mar 7, 2025
1 parent 08822de commit aedc6d4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/handlers/adminapi/office_users.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ var officeUserFilterConverters = map[string]func(string) func(*pop.Query){
"search": func(content string) func(*pop.Query) {
return func(query *pop.Query) {
firstSearch, lastSearch, emailSearch := fmt.Sprintf("%%%s%%", content), fmt.Sprintf("%%%s%%", content), fmt.Sprintf("%%%s%%", content)
query.Where("office_users.status = 'APPROVED' AND (office_users.first_name ILIKE ? OR office_users.last_name ILIKE ? OR office_users.email ILIKE ?", firstSearch, lastSearch, emailSearch)
query.Where("(office_users.first_name ILIKE ? OR office_users.last_name ILIKE ? OR office_users.email ILIKE ?) AND office_users.status = 'APPROVED'", firstSearch, lastSearch, emailSearch)
}
},
"email": func(content string) func(*pop.Query) {
Expand Down
6 changes: 4 additions & 2 deletions pkg/handlers/adminapi/office_users_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ func (suite *HandlerSuite) TestIndexOfficeUsersHandler() {
LastName: "Jolie",
Email: "laraCroft@mail.mil",
Status: &status,
Telephone: "555-555-5555",
},
},
}, []roles.RoleType{roles.RoleTypeTOO})
Expand All @@ -158,6 +159,7 @@ func (suite *HandlerSuite) TestIndexOfficeUsersHandler() {
LastName: "Bob",
Email: "bigBob@mail.mil",
Status: &status,
Telephone: "555-555-5555",
},
},
}, []roles.RoleType{roles.RoleTypeTIO})
Expand All @@ -168,6 +170,7 @@ func (suite *HandlerSuite) TestIndexOfficeUsersHandler() {
LastName: "Cage",
Email: "conAirKilluh@mail.mil",
Status: &status,
Telephone: "555-555-5555",
},
},
}, []roles.RoleType{roles.RoleTypeServicesCounselor})
Expand Down Expand Up @@ -243,8 +246,7 @@ func (suite *HandlerSuite) TestIndexOfficeUsersHandler() {
okResponse = response.(*officeuserop.IndexOfficeUsersOK)
suite.Len(okResponse.Payload, 1)

respPhone := *okResponse.Payload[0].Email
suite.Equal(phoneSearch, respPhone[0:len(phoneSearch)])
respPhone := *okResponse.Payload[0].Telephone
suite.Equal(phoneSearch, respPhone[0:len(phoneSearch)])

// firstName search
Expand Down

0 comments on commit aedc6d4

Please sign in to comment.