Skip to content

Commit

Permalink
feat: whereNotIn filtering, mpox intake (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
wvxcheung authored Aug 22, 2024
1 parent f71fcf0 commit a80b8ba
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions graphql/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ export class QuerySet {
if (step.filters.where) querySet.where(...step.filters.where);
if (step.filters.whereIn) querySet.whereIn(...step.filters.whereIn);
if (step.filters.whereNot) querySet.whereNot(...step.filters.whereNot);
if (step.filters.whereNotIn) querySet.whereNotIn(...step.filters.whereNotIn);
}
step.children.forEach((c) => {
const joinedF = typeof c.fk === 'string' ? c.fk : c.fk[0];
Expand Down
5 changes: 3 additions & 2 deletions graphql/api/utils/diagram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,18 @@ const recurseAuth = (plan: AuthQueryPlan, parent?: AuthNode) => {

if (
plan.filters &&
(plan.filters.where || plan.filters.whereNot || plan.filters.whereIn)
(plan.filters.where || plan.filters.whereNot || plan.filters.whereIn || plan.filters.whereNotIn)
) {
const filterName = (c: string) => {
if (c === 'whereIn') return 'where in';
if (c === 'whereNot') return 'where not';
if (c === 'whereNotIn') return 'where not in';
return c;
};
const cond_text = Object.keys(plan.filters || {})
.map((c) => {
if (typeof plan.filters !== 'undefined') {
const filter = plan.filters[c as 'where' | 'whereNot' | 'whereIn'];
const filter = plan.filters[c as 'where' | 'whereNot' | 'whereIn' | 'whereNotIn'];
return (
(filter &&
`${filterName(c).toUpperCase()}\\n${plan.table}.${
Expand Down
12 changes: 10 additions & 2 deletions graphql/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@ export const groups: { readonly [authGroup: string]: AuthFilters } = {
sites: {
where: ['healthReg', 'CSC'],
},
datasets: {
whereNot: ['datasetID', 'NML-WWMPOX'],
},
},
bccdc: {
sites: {
where: ['healthReg', 'Vancouver'],
},
datasets: {
whereIn: ['datasetID', ['BCCDC', 'NML-WWPCR']],
whereNot: ['datasetID', 'NML-WWMPOX'],
},
},
hnj: {
Expand All @@ -28,12 +32,16 @@ export const groups: { readonly [authGroup: string]: AuthFilters } = {
},
datasets: {
whereIn: ['datasetID', ['NML-WWPCR', 'NML-GXWW', 'onsite-GXWW']],
whereNot: ['datasetID', 'NML-WWMPOX'],
},
},
pho: {
sites:{
whereIn: ['healthReg', ['Dryden', 'Kenora']]
}
whereIn: ['healthReg', ['Dryden', 'Kenora', 'Toronto']]
},
datasets: {
whereNotIn: ['datasetID', ['NML-WWMPOX', 'OMECP']],
},
},
open: {
sites: {
Expand Down
1 change: 1 addition & 0 deletions graphql/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export type AuthFilter = {
readonly where?: [any, any];
readonly whereIn?: [any, any[]];
readonly whereNot?: [any, any];
readonly whereNotIn?: [any, any[]];
};

export type AuthFilters = {
Expand Down

0 comments on commit a80b8ba

Please sign in to comment.