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

24195 tweaks on filing queries #3166

Merged
merged 2 commits into from
Jan 8, 2025

Conversation

vysakh-menon-aot
Copy link
Collaborator

Issue #: /bcgov/entity#24195

Description of changes:

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the lear license (Apache 2.0).

@vysakh-menon-aot vysakh-menon-aot self-assigned this Jan 8, 2025
@@ -511,7 +511,6 @@ def json(self, slim=False):
'lastLedgerTimestamp': self.last_ledger_timestamp.isoformat(),
'lastAddressChangeDate': '',
'lastDirectorChangeDate': '',
'lastModified': self.last_modified.isoformat(),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

included in _slim_json

@@ -896,7 +896,7 @@ def get_filings_by_types(business_id: int, filing_types):
filter(Filing.business_id == business_id). \
filter(Filing._filing_type.in_(filing_types)). \
filter(Filing._status == Filing.Status.COMPLETED.value). \
order_by(desc(Filing.effective_date)). \
order_by(desc(Filing.transaction_id)). \
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

order with transaction_id for COMPLETED filing queries

@@ -80,7 +80,6 @@ def get_businesses(identifier: str):
recent_filing_json = CoreFiling.get_most_recent_filing_json(business.id, None, jwt)
if recent_filing_json:
business_json['submitter'] = recent_filing_json['filing']['header']['submitter']
business_json['lastModified'] = recent_filing_json['filing']['header']['date']
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not required to override. lastModified will be updated in entity-filer while processing a filing

if filing.transaction_id: # transaction_id will be None for the pending filings (intermediate state)
query = query.filter(Filing.transaction_id < filing.transaction_id)

return query.order_by(Filing.transaction_id.desc()).first()
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

order with transaction_id for COMPLETED filing queries

Copy link

sonarqubecloud bot commented Jan 8, 2025

max_filing = max_filing.filter(Filing._filing_sub_type == filing_sub_type)
max_filing = max_filing.subquery()
def get_most_recent_filing(business_id: str, filing_type: str = None, filing_sub_type: str = None):
"""Return the most recent filing.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Simplified and generalize this function

@vysakh-menon-aot vysakh-menon-aot merged commit 9f33aad into bcgov:main Jan 8, 2025
8 checks passed
@vysakh-menon-aot vysakh-menon-aot deleted the feature/24195-fix branch January 8, 2025 20:19
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