Skip to content

Commit 0f41e1d

Browse files
authored
Merge pull request ytgov#102 from icefoganalytics/main
Fixing ILIKE
2 parents c716ca7 + c802f89 commit 0f41e1d

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

api/src/routes/hazard-router.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ hazardRouter.get("/", async (req: Request, res: Response) => {
3535
countQuery.where("location_code", location);
3636
}
3737
if (!isNil(category)) {
38-
listQuery.whereILike("categories", `%${category}%`);
39-
countQuery.whereILike("categories", `%${category}%`);
38+
listQuery.whereRaw(`"categories" like '%${category}%'`);
39+
countQuery.whereRaw(`"categories" like '%${category}%'`);
4040
}
4141

4242
const count = await countQuery.count("* as count").first();

api/src/services/incident-service.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ export class IncidentService {
2626
.innerJoin("incident_types", "incident_types.id", "incidents.incident_type_id")
2727
.innerJoin("incident_statuses", "incident_statuses.code", "incidents.status_code")
2828
.innerJoin("departments", "departments.code", "incidents.department_code")
29-
.whereRaw(`"incidents"."id" IN (SELECT "incident_id" FROM "incident_users_view" WHERE "user_email" = ?)`, [email])
29+
.whereRaw(`"incidents"."id" IN (SELECT "incident_id" FROM "incident_users_view" WHERE LOWER("user_email") = ?)`, [
30+
email.toLowerCase(),
31+
])
3032
.whereNot("incident_types.name", "inspection")
3133
.modify(where)
3234
.count("* as count")
@@ -46,7 +48,9 @@ export class IncidentService {
4648
.innerJoin("incident_statuses", "incident_statuses.code", "incidents.status_code")
4749
.innerJoin("departments", "departments.code", "incidents.department_code")
4850
.innerJoin("locations", "incidents.location_code", "locations.code")
49-
.whereRaw(`"incidents"."id" IN (SELECT "incident_id" FROM "incident_users_view" WHERE "user_email" = ?)`, [email])
51+
.whereRaw(`"incidents"."id" IN (SELECT "incident_id" FROM "incident_users_view" WHERE LOWER("user_email") = ?)`, [
52+
email.toLowerCase(),
53+
])
5054
.whereNot("incident_types.name", "inspection")
5155
.select<Incident>(
5256
"incidents.*",
@@ -110,14 +114,14 @@ export class IncidentService {
110114

111115
async getByReportingEmail(email: string): Promise<Incident[]> {
112116
return db<Incident>("incidents")
113-
.whereILike("incident_users_view.user_email", email.toLowerCase())
114117
.where("incident_users_view.reason", "reporter")
115118
.whereNotIn("status_code", ["Closed", "Dup", "NoAct"])
116119
.whereNot("incident_types.name", "inspection")
117120
.innerJoin("incident_users_view", "incidents.id", "incident_users_view.incident_id")
118121
.innerJoin("incident_types", "incident_types.id", "incidents.incident_type_id")
119122
.innerJoin("incident_statuses", "incident_statuses.code", "incidents.status_code")
120123
.innerJoin("departments", "departments.code", "incidents.department_code")
124+
.whereRaw(`LOWER("incident_users_view"."user_email") = '${email.toLowerCase()}'`)
121125
.select(
122126
"incidents.*",
123127
"incident_types.name as incident_type_name",
@@ -129,14 +133,14 @@ export class IncidentService {
129133

130134
async getBySupervisorEmail(email: string): Promise<Incident[]> {
131135
return db<Incident>("incidents")
132-
.whereILike("incident_users_view.user_email", email.toLowerCase())
133136
.where("incident_users_view.reason", "supervisor")
134137
.whereNot("incident_types.name", "inspection")
135138
.whereNotIn("status_code", ["Closed", "Dup", "NoAct"])
136139
.innerJoin("incident_users_view", "incidents.id", "incident_users_view.incident_id")
137140
.innerJoin("incident_types", "incident_types.id", "incidents.incident_type_id")
138141
.innerJoin("incident_statuses", "incident_statuses.code", "incidents.status_code")
139142
.innerJoin("departments", "departments.code", "incidents.department_code")
143+
.whereRaw(`LOWER("incident_users_view"."user_email") = '${email.toLowerCase()}'`)
140144
.select(
141145
"incidents.*",
142146
"incident_types.name as incident_type_name",

web/src/components/report/ReportListPage.vue

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,16 @@
2020
<v-col cols="12" md="2">
2121
<HazardUrgencySelect v-model="urgency" label="Urgency" clearable />
2222
</v-col>
23-
<v-col cols="12" md="3">
23+
<v-col cols="12" md="4" class="d-flex">
2424
<LocationSelect v-model="location" label="Location" clearable />
25-
</v-col>
26-
<v-col cols="12" md="auto" class="d-flex justify-end">
2725
<v-btn
2826
icon="mdi-table-arrow-down"
29-
class="my-0"
27+
class="my-0 ml-3"
3028
size="50"
3129
title="Export to CSV"
32-
variant="tonal"
30+
variant="flat"
3331
color="primary"
34-
@click="csvExportClick"
35-
></v-btn>
32+
@click="csvExportClick"></v-btn>
3633
</v-col>
3734
</v-row>
3835

@@ -125,7 +122,7 @@ async function csvExportClick() {
125122
status: status.value,
126123
urgency: urgency.value,
127124
location: location.value,
128-
})
125+
});
129126
}
130127
131128
function updatePage(newPage) {

0 commit comments

Comments
 (0)