-
-
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
Changes from 11 commits
b506f4f
42cb272
a4629c1
be898b7
087e7e3
56e3a17
f9a9302
2142e55
cca491a
94a1b0a
923453d
89ba6db
365c159
e6b7c9a
57be9cf
9c6c06f
e686887
550e93d
db0a110
027dc4f
171cbe7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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, | ||
get_couch_repeat_records_by_payload_id, | ||
get_sql_repeat_records_by_payload_id, | ||
iter_repeat_records_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,37 @@ 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: | ||
records = get_couch_repeat_records_by_payload_id(domain, payload_id) | ||
return [r._id for r in records] | ||
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: | ||
records = iter_repeat_records_by_repeater(domain, repeater_id) | ||
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. Does this query use 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. 👍 9c6c06f |
||
return [r._id for r in records] |
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'