-
-
Notifications
You must be signed in to change notification settings - Fork 218
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
SQL Repeat Record Report & Case Data Report #29029
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
b506f4f
SQLRepeatRecordReport
kaapstorm 42cb272
⚖ Test are_repeat_records_migrated
kaapstorm a4629c1
♻ Use quickcache to avoid N+1 query problem
kaapstorm be898b7
⚖ Test num queries for SQLRepeatRecordReport
kaapstorm 087e7e3
Repeat record report tasks support SQL
kaapstorm 56e3a17
⚖ Update tests for Repeat Record Report tasks
kaapstorm f9a9302
Duck type for ReferCaseRepeater
kaapstorm 2142e55
Merge branch 'master' into nh/rep/report
kaapstorm cca491a
Use `enumerate(..., start=1)`
kaapstorm 94a1b0a
Return None instead of raising IndexError
kaapstorm 923453d
Add test. Fix IDs.
kaapstorm 89ba6db
Drop bad type hint
kaapstorm 365c159
Update tests
kaapstorm e6b7c9a
Merge branch 'master' into nh/rep/report
kaapstorm 57be9cf
Merge branch 'master' into nh/rep/report
kaapstorm 9c6c06f
Don't include docs if we don't need them
kaapstorm e686887
We don't need `None`
kaapstorm 550e93d
Drop fragile test
kaapstorm db0a110
Estimate count
kaapstorm 027dc4f
Update test with renamed functions
kaapstorm 171cbe7
Fix report link in Data Forwarding page
kaapstorm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,9 +20,11 @@ | |
) | ||
from corehq.form_processor.utils.general import should_use_sql_backend | ||
from corehq.motech.repeaters.dbaccessors import ( | ||
get_repeat_records_by_payload_id, | ||
iter_repeat_records_by_repeater, | ||
get_couch_repeat_record_ids_by_payload_id, | ||
get_sql_repeat_records_by_payload_id, | ||
iter_repeat_record_ids_by_repeater, | ||
) | ||
from corehq.motech.repeaters.models import SQLRepeatRecord | ||
from corehq.sql_db.util import get_db_aliases_for_partitioned_query | ||
from corehq.toggles import DISABLE_CASE_UPDATE_RULE_SCHEDULED_TASK | ||
from corehq.util.decorators import serial_task | ||
|
@@ -224,8 +226,13 @@ def delete_old_rule_submission_logs(): | |
|
||
|
||
@task(serializer='pickle') | ||
def task_operate_on_payloads(record_ids, domain, action=''): | ||
return operate_on_payloads(record_ids, domain, action, | ||
def task_operate_on_payloads( | ||
record_ids: List[str], | ||
domain: str, | ||
action, # type: Literal['resend', 'cancel', 'requeue'] # 3.8+ | ||
use_sql: bool, | ||
): | ||
return operate_on_payloads(record_ids, domain, action, use_sql, | ||
task=task_operate_on_payloads) | ||
|
||
|
||
|
@@ -234,24 +241,35 @@ def task_generate_ids_and_operate_on_payloads( | |
payload_id: Optional[str], | ||
repeater_id: Optional[str], | ||
domain: str, | ||
action: str = '', | ||
action, # type: Literal['resend', 'cancel', 'requeue'] # 3.8+ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. F821 undefined name 'Literal' |
||
use_sql: bool, | ||
) -> dict: | ||
repeat_record_ids = _get_repeat_record_ids(payload_id, repeater_id, domain) | ||
return operate_on_payloads(repeat_record_ids, domain, action, | ||
repeat_record_ids = _get_repeat_record_ids(payload_id, repeater_id, domain, | ||
use_sql) | ||
return operate_on_payloads(repeat_record_ids, domain, action, use_sql, | ||
task=task_generate_ids_and_operate_on_payloads) | ||
|
||
|
||
def _get_repeat_record_ids( | ||
payload_id: Optional[str], | ||
repeater_id: Optional[str], | ||
domain: str, | ||
use_sql: bool, | ||
) -> List[str]: | ||
if not payload_id and not repeater_id: | ||
return [] | ||
if payload_id: | ||
results = get_repeat_records_by_payload_id(domain, payload_id) | ||
if use_sql: | ||
records = get_sql_repeat_records_by_payload_id(domain, payload_id) | ||
return [r.id for r in records] | ||
else: | ||
return get_couch_repeat_record_ids_by_payload_id(domain, payload_id) | ||
else: | ||
results = iter_repeat_records_by_repeater(domain, repeater_id) | ||
ids = [x['id'] for x in results] | ||
|
||
return ids | ||
if use_sql: | ||
queryset = SQLRepeatRecord.objects.filter( | ||
domain=domain, | ||
repeater_stub__repeater_id=repeater_id, | ||
) | ||
return [r['id'] for r in queryset.values('id')] | ||
else: | ||
return list(iter_repeat_record_ids_by_repeater(domain, repeater_id)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
F821 undefined name 'Literal'