-
Notifications
You must be signed in to change notification settings - Fork 17
Open
Description
Currently the code to apply min age filter runs like this
curr_result = filter_centers_by_age_limit(self._call_api(url),
min_age_limt)The potential problem with this is that the filter is coupled with the api call, hence making changes or places where the code is branched like the following case
if min_age_limt:
curr_result = filter_centers_by_age_limit(self._call_api(url),
min_age_limt)
else:
curr_result = self._call_api(url)becomes difficult and has chances of introduction of errors.
Proposal: change the structure so that the code for filter only works on the received data and does not need to make the api call. The fetch is going to happen first anyways since the API itself not going to apply any filter and return all the data always (at least for now). The code would then look like
curr_result = self._call_api(url)
if min_age_limt:
curr_result = filter_centers_by_age_limit(curr_result, min_age_limt)
if some_other_filter:
curr_result = some_other_filter_function(curr_result, *kwargs)Please let me know if this is something that can make the code better, and I will make the changes in a separate PR.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels