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

working character checker for good name, party name and party address #2210

Closed
wants to merge 2 commits into from

Conversation

Tllew
Copy link
Contributor

@Tllew Tllew commented Sep 26, 2024

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

Comment on lines +107 to +110
goa = GoodOnApplication.objects.filter(
~Q(good__name__iregex=name_match_string)
& ~Q(application__status__status__in=CaseStatusEnum._terminal_statuses)
)
Copy link
Contributor

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?

Copy link
Contributor Author

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.
@Tllew Tllew force-pushed the LTD-5451-special-character-checker branch from c4db99b to 00eb1e6 Compare October 1, 2024 12:44
return entry

def get_id(self, entry):
return entry
Copy link
Contributor

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:
Copy link
Contributor

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):
Copy link
Contributor

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.

Copy link
Contributor

@currycoder currycoder left a 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
Copy link
Contributor

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,
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 column actually good_name instead of value?

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.

4 participants