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

CM-69: Develop logic for handling custom filters for benefit plan - BE #6

Merged
merged 9 commits into from Jun 2, 2023

Conversation

sniedzielski
Copy link
Contributor

@sniedzielski sniedzielski commented Jun 1, 2023

TICKET: https://openimis.atlassian.net/browse/CM-69

related PR: openimis/openimis-be-core_py#185

PR provides the implementation of wizard interface for BenefitPlan instances.

NOTE: Tests are failing due to lack of merging such PR from core module openimis/openimis-be-core_py#181

@sniedzielski
Copy link
Contributor Author

@dborowiecki You can start checking PR

@sniedzielski sniedzielski marked this pull request as ready for review June 2, 2023 10:04
:return: A list of named tuples representing the definition of how to create filters.
:rtype: List[namedtuple]
"""
logger.info('starting loading definition of custom filter')
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this definition loaded multuple times or only during setup? If the former then this kind of log may bloat logger and it's not essential, you could change it to to debug or simply remove it. I don't see value other then information that function was invoked.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It could be loaded multiple times. I think this log is a redundant one.

if benefit_plan:
self.__process_schema_and_build_tuple(benefit_plan, tuple_type, list_of_tuple_with_definitions)
else:
logger.info('There is no benefit plan with such id')
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this should be a info. Rather a warning, also if you received invalid ID it's perfectly fine to just throw exeption in here. Returning empty list might be misleading as in fact we have filters definitions, but input data is invalid.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to the using get() in QuerySet

else:
logger.info('There is no benefit plan with such id')
else:
logger.info('Id of benefit plan is not provided')
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, it's not really information log. Information log is used to (among others) to track important events or milestones in the system's execution. They should be used sparingly and contain essential information to avoid cluttering the log files.

logger.info('There is no benefit plan with such id')
else:
logger.info('Id of benefit plan is not provided')
logger.info('Output is prepared with definition how to build filters')
Copy link
Contributor

Choose a reason for hiding this comment

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

This also can be removed

Comment on lines 74 to 77
else:
logger.info('There are no properties provided in schema from that benefit plan')
else:
logger.info('There is no schema provided in benefit plan')
Copy link
Contributor

Choose a reason for hiding this comment

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

Those logs could be warning instead of info. While I believe that this shouldn't raise exeption (as benefit plan exists), warning could be added. It's because empty schema is possible in the system (at least now), however we cannot use it for custom filters and it should be changed (therefore warning for the developer that will look into an issue with empty custom filters).

filter=self.FILTERS_BASED_ON_FIELD_TYPE[property['type']],
type=property['type']
)
list_of_tuple_with_definitions.append(tuple_with_definition)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is similar case to the one in core module. I think it'll be bettet to simply return new defintiions instead of appending them to the list from outside context.

Comment on lines 63 to 64
if schema:
if 'properties' in schema:
Copy link
Contributor

Choose a reason for hiding this comment

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

When log (see next comments) will be changed, this can also be simplified to single check
if schema and 'properties' in schema:
...

Comment on lines 66 to 67
for key in properties:
property = properties[key]
Copy link
Contributor

Choose a reason for hiding this comment

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

you can iterate on dict.items() instead of taking keys and then loading values

@sniedzielski
Copy link
Contributor Author

@dborowiecki Please re-check PR

@dborowiecki dborowiecki merged commit 32140f1 into develop Jun 2, 2023
2 checks passed
@dragos-dobre dragos-dobre deleted the CM-69 branch October 18, 2023 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants