Skip to content

Commit

Permalink
feat: add reference_id as a valid field for growers query
Browse files Browse the repository at this point in the history
  • Loading branch information
gwynndp committed Apr 19, 2023
1 parent fe2003b commit a92728a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 10 additions & 1 deletion server/infra/database/GrowerAccountRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ export default class GrowerAccountRepository extends BaseRepository<GrowerAccoun
delete filterObject.id;
}

if (filterObject.reference_id) {
result.where(
`${this.tableName}.reference_id`,
'=',
filterObject.reference_id,
);
delete filterObject.reference_id;
}

if (filterObject.first_name) {
result.where(
`${this.tableName}.first_name`,
Expand Down Expand Up @@ -357,7 +366,7 @@ export default class GrowerAccountRepository extends BaseRepository<GrowerAccoun
.select(
knex.raw(`
COUNT(${this.tableName}.id) AS count
FROM ${this.tableName}
FROM ${this.tableName}
`),
)
.where((builder) => this.filterWhereBuilder(filter, builder))
Expand Down
2 changes: 2 additions & 0 deletions server/routers/growerAccountsRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ router.get(
keyword: Joi.string(),
organization_id: Joi.array(),
id: Joi.string().uuid(),
reference_id: Joi.number(),
person_id: Joi.string().uuid(),
device_identifier: Joi.string(),
first_name: Joi.string(),
Expand Down Expand Up @@ -139,6 +140,7 @@ router.get(
keyword: Joi.string(),
organization_id: Joi.array(),
id: Joi.string().uuid(),
reference_id: Joi.number(),
person_id: Joi.string().uuid(),
device_identifier: Joi.string(),
first_name: Joi.string(),
Expand Down

0 comments on commit a92728a

Please sign in to comment.