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

Remove call to archive to get s3 runs #428

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions temba/flows/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1983,7 +1983,7 @@ def _get_run_batches(self, flows, responded_only):
logger.info(f"Results export #{self.id} for org #{self.org.id}: fetching runs from archives to export...")

# firstly get runs from archives
from temba.archives.models import Archive
# from temba.archives.models import Archive

# get the earliest created date of the flows being exported
earliest_created_on = None
Expand All @@ -1995,15 +1995,15 @@ def _get_run_batches(self, flows, responded_only):
where = {"flow__uuid__in": flow_uuids}
if responded_only:
where["responded"] = True
records = Archive.iter_all_records(self.org, Archive.TYPE_FLOWRUN, after=earliest_created_on, where=where)
# records = Archive.iter_all_records(self.org, Archive.TYPE_FLOWRUN, after=earliest_created_on, where=where)
seen = set()

for record_batch in chunk_list(records, 1000):
matching = []
for record in record_batch:
seen.add(record["id"])
matching.append(record)
yield matching
# for record_batch in chunk_list(records, 1000):
# matching = []
# for record in record_batch:
# seen.add(record["id"])
# matching.append(record)
# yield matching

# secondly get runs from database
runs = FlowRun.objects.filter(flow__in=flows).order_by("modified_on").using("readonly")
Expand Down
6 changes: 3 additions & 3 deletions temba/flows/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -4063,7 +4063,7 @@ def test_export_results(self, mr_mocks):
# make sure that we trigger logger
log_info_threshold.return_value = 1

with self.assertNumQueries(45):
with self.assertNumQueries(44):
workbook = self._export(flow, group_memberships=[devs])

self.assertEqual(len(captured_logger.output), 3)
Expand Down Expand Up @@ -4309,7 +4309,7 @@ def msg_event_time(run, text):
)

# test without msgs or unresponded
with self.assertNumQueries(43):
with self.assertNumQueries(42):
workbook = self._export(flow, include_msgs=False, responded_only=True, group_memberships=(devs,))

tz = self.org.timezone
Expand Down Expand Up @@ -4375,7 +4375,7 @@ def msg_event_time(run, text):
)

# test export with a contact field
with self.assertNumQueries(45):
with self.assertNumQueries(44):
workbook = self._export(
flow,
include_msgs=False,
Expand Down
Loading