Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply age filter using min_age_booking #495

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,15 +364,10 @@ def correct_schema(sessions):


def filter_centers_by_age(resp, min_age_booking):
if min_age_booking >= 45:
center_age_filter = 45
else:
center_age_filter = 18

if "centers" in resp:
for center in list(resp["centers"]):
for session in list(center["sessions"]):
if session['min_age_limit'] != center_age_filter:
if session['min_age_limit'] > min_age_booking:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It displays centers for both 45+ and 18+. This will not work in a scenario where min_age_booking is above 45 and if the location you are searching for opens up slots for only 18+, it will try to book that and throw an error. Refer this

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dosen't 18+ means anyone above 18? or is those centers only for 18-45 only. If 18+ centers is only for 18-45 then, then this will end up with the error for person aboue 45. But that opens up a new question then what does 40+ (and other age classes) mean? 40-45?

But if 18+ means anyone above 18, then in the current function filter_centers_by_age (in the main branch) will filter out 40+ sessions for a person with age 42. Also, if this is the case I don't think we need the function filter_centers_by_age altogether as the viable_options function clearly filters the sessions based on age.

Can you clarify if booking a 18+ session for a person with age above 45 will result in an error? If not can I remove the filter_centers_by_age function altogether and add it to this PR?

Copy link
Collaborator

@Nakul93 Nakul93 Jun 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dosen't 18+ means anyone above 18? or is those centers only for 18-45 only. If 18+ centers is only for 18-45 then, then this will end up with the error for person aboue 45. But that opens up a new question then what does 40+ (and other age classes) mean? 40-45?

No it doesn't. CoWIN has 2 age grps 18-44 and 45+(and now 40-44 is also there which is very rare)

But if 18+ means anyone above 18, then in the current function filter_centers_by_age (in the main branch) will filter out 40+ sessions for a person with age 42. Also, if this is the case I don't think we need the function filter_centers_by_age altogether as the viable_options function clearly filters the sessions based on age.

filter_centers_by_age prints the available centers according to age and then viable option filters them according to dose_no,fee_type and min slots. So no we can't remove it since viable options will not filter by age. Are you suggesting we should merge these 2 functions.

Can you clarify if booking a 18+ session for a person with age above 45 will result in an error? If not can I remove the filter_centers_by_age function altogether and add it to this PR?

Yes it does give you an error

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it doesn't. CoWIN has 2 age grps 18-44 and 45+(and now 40-44 is also there which is very rare)

I disagree with this. This is the data I got from the Ernakulam (Kerala) district data for the date 08-07-2021 for number of session and min_age_limit for each session.

{
  "age 45": 67,
  "age 40": 44,
  "age 18": 11
}

So, I think in some regions there are more age ranges. Also as mentioned here, there are other age limits too.

So no we can't remove it since viable options will not filter by age

I think the function filters according to age as seen in this line. But if there is a problem like the error you mentioned is there with age classes, I accept that a filter like filter_centers_by_age function is needed . But then why is theviable_options function again filtering based on age?

But even as such the issue #494 still exists but I am closing this PR.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I saw that the age group filters on portal end are still 18-44 and 45+. 40+ is actually for 40-44 and is displayed under 18-44
image
They should actually have a field for max age as well, then it would be easier to filter them out.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the function filters according to age as seen in this line. But if there is a problem like the error you mentioned is there with age classes, I accept that a filter like filter_centers_by_age function is needed . But then why is theviable_options function again filtering based on age?

I agree, there is no point in filtering out by age again in viable options since we are already doing that in filter_centers_by_age func

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like there are very few centers like these with these varying age grp restrictions. So as of now we can hold off this PR and keep issue #494 open.
We probably need to see the min and max limit of every age group and accordingly need to implement the logic

center["sessions"].remove(session)
if (len(center["sessions"]) == 0):
resp["centers"].remove(center)
Expand Down