Skip to content

Commit

Permalink
Merge pull request #351 from aayushgauba/main
Browse files Browse the repository at this point in the history
fix:organization_filter for growerV2
  • Loading branch information
dadiorchen committed Jul 27, 2023
2 parents 91f70d1 + 513eba6 commit b66ad9f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
4 changes: 1 addition & 3 deletions server/infra/database/GrowerAccountRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ export default class GrowerAccountRepository extends BaseRepository<GrowerAccoun
}

if (filterObject.organization_id) {
result.where(`${this.tableName}.organization_id`, 'in', [
...filterObject.organization_id,
]);
result.where(`${this.tableName}.organization_id`, '=',`${filterObject.organization_id}`);
delete filterObject.organization_id;
}

Expand Down
4 changes: 2 additions & 2 deletions server/routers/growerAccountsRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ router.get(
limit: Joi.number().integer().min(1).max(1000),
offset: Joi.number().integer().min(0),
keyword: Joi.string(),
organization_id: Joi.array(),
organization_id: Joi.string().uuid(),
id: Joi.string().uuid(),
reference_id: Joi.number(),
person_id: Joi.string().uuid(),
Expand Down Expand Up @@ -138,7 +138,7 @@ router.get(
limit: Joi.number().integer().min(1).max(1000),
offset: Joi.number().integer().min(0),
keyword: Joi.string(),
organization_id: Joi.array(),
organization_id: Joi.string().uuid(),
id: Joi.string().uuid(),
reference_id: Joi.number(),
person_id: Joi.string().uuid(),
Expand Down
5 changes: 2 additions & 3 deletions server/routers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,8 @@ const queryFormatter = (req) => {
whereIns: whereIns?.length ? JSON.parse(whereIns) : [],
...others,
};

if (organization_id) {
query.organization_id = JSON.parse(organization_id);
if (req.query.organization_id) {
query.organization_id = req.query.organization_id;
}

if (req.query.captures_amount_min) {
Expand Down

0 comments on commit b66ad9f

Please sign in to comment.