Skip to content

Commit

Permalink
feat: add grower_reference_id as a filter field for verify
Browse files Browse the repository at this point in the history
  • Loading branch information
gwynndp committed Apr 22, 2023
1 parent b6bea8c commit 3a8b1cc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions server/infra/database/CaptureRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export default class CaptureRepository extends BaseRepository<Capture> {
);
delete filterObject.reference_id;
}

if (filterObject.grower_reference_id) {
result.where(
`treetracker.grower_account.reference_id`,
Expand Down
21 changes: 21 additions & 0 deletions server/infra/database/RawCaptureRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,15 @@ export default class RawCaptureRepository extends BaseRepository<RawCapture> {
delete filterObject.reference_id;
}

if (filterObject.grower_reference_id) {
result.where(
`treetracker.grower_account.reference_id`,
'=',
filterObject.grower_reference_id,
);
delete filterObject.grower_reference_id;
}

if (filterObject.organization_id) {
result.where(`field_data.session.organization_id`, 'in', [
...filterObject.organization_id,
Expand Down Expand Up @@ -152,6 +161,12 @@ export default class RawCaptureRepository extends BaseRepository<RawCapture> {
'=',
'field_data.wallet_registration.id',
)
.leftJoin(
'treetracker.grower_account',
'field_data.wallet_registration.grower_account_id',
'=',
'treetracker.grower_account.id',
)
.leftJoin(
'field_data.device_configuration',
'field_data.session.device_configuration_id',
Expand Down Expand Up @@ -202,6 +217,12 @@ export default class RawCaptureRepository extends BaseRepository<RawCapture> {
'=',
'field_data.wallet_registration.id',
)
.leftJoin(
'treetracker.grower_account',
'field_data.wallet_registration.grower_account_id',
'=',
'treetracker.grower_account.id',
)
.leftJoin(
'field_data.device_configuration',
'field_data.session.device_configuration_id',
Expand Down
2 changes: 2 additions & 0 deletions server/routers/rawCapturesRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ router.get(
status: Joi.string().allow('unprocessed', 'approved', 'rejected'),
bulk_pack_file_name: Joi.string(),
grower_account_id: Joi.string().uuid(),
grower_reference_id: Joi.number(),
organization_id: Joi.array(),
startDate: Joi.string().regex(/^\d{4}-\d{2}-\d{2}$/),
endDate: Joi.string().regex(/^\d{4}-\d{2}-\d{2}$/),
Expand Down Expand Up @@ -76,6 +77,7 @@ router.get(
status: Joi.string().allow('unprocessed', 'approved', 'rejected'),
bulk_pack_file_name: Joi.string(),
grower_account_id: Joi.string().uuid(),
grower_reference_id: Joi.number(),
organization_id: Joi.array(),
startDate: Joi.string().regex(/^\d{4}-\d{2}-\d{2}$/),
endDate: Joi.string().regex(/^\d{4}-\d{2}-\d{2}$/),
Expand Down

0 comments on commit 3a8b1cc

Please sign in to comment.