-
Notifications
You must be signed in to change notification settings - Fork 2
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
working character checker for good name, party name and party address #2210
Conversation
goa = GoodOnApplication.objects.filter( | ||
~Q(good__name__iregex=name_match_string) | ||
& ~Q(application__status__status__in=CaseStatusEnum._terminal_statuses) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this also be extended to Good
? we can may be ask them to edit if possible or archive and create new ones before they are used on an application preventing this further?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did start with good but wanted this particular script to be a bit more focused on the "in flight" ones that would potentially cause issues going forward
as this is hopefully somewhat reusable this query should be able to be modified to good, though we may need a new child class to format it correctly
…elds or load this into pandas to interogate a bit better.
c4db99b
to
00eb1e6
Compare
return entry | ||
|
||
def get_id(self, entry): | ||
return entry |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this need to be entry.id
?
} | ||
|
||
def write_to_csv(self): | ||
with open(f"{self.filename}.csv", "w", newline="") as csvfile: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is better you take the complete filename good_names.csv
so that it is clear that the output is csv
id = self.get_id(entry) | ||
if not self.unique_result.get(id): | ||
value = self.get_value(entry) | ||
if match := self.check_regex(value): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
walrus operator, perhaps first usage in lite.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of comments inline
value = self.get_value(entry) | ||
if match := self.check_regex(value): | ||
results.append(self.format_results(entry, match)) | ||
self.unique_result[id] = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is just storing a flat single value, could it be a set instead e.g.
self.unique_matches = set()
...
self.unique_matches.add(match)
"org_name": data.application.organisation.name, | ||
"good_id": data.good.id, | ||
"reference_code": data.application.reference_code, | ||
"value": data.good.name, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this column actually good_name
instead of value
?
Attempt to scan the system for a value with special characters
Hopefully a little reusable, if not it could potentially just go as a script in confluence
The idea is to give it a queryset and it should be able to check a value based on a regex
Mostly just used to build the CSVs I presented to the support chat during investigation.
LTD-5451