Skip to content
This repository was archived by the owner on May 4, 2021. It is now read-only.

Commit 2f404bd

Browse files
authoredJul 19, 2019
Merge pull request #63 from openstax/fix_clue_responses
Fix some CLUes never getting calculated due to overwritten responses
2 parents 2411a2f + 57ff279 commit 2f404bd

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed
 

‎sparfa_server/tasks/calcs.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -215,22 +215,22 @@ def calculate_clues():
215215
"""Calculate all CLUes"""
216216
calculations = BLSCHED.fetch_clue_calculations()
217217
while calculations:
218-
response_uuids = [response['response_uuid']
218+
trial_uuids = set(response['trial_uuid']
219219
for calculation in calculations
220-
for response in calculation['responses']]
220+
for response in calculation['responses'])
221221

222222
with transaction() as session:
223223
# Skip calculations with unknown responses and responses that we can't lock immediately
224224
responses = session.query(Response).filter(
225-
Response.uuid.in_(response_uuids)
225+
Response.trial_uuid.in_(trial_uuids)
226226
).with_for_update(key_share=True, skip_locked=True).all()
227-
responses_by_uuid = {}
227+
responses_by_trial_uuid = {}
228228
for response in responses:
229-
responses_by_uuid[response.uuid] = response
229+
responses_by_trial_uuid[response.trial_uuid] = response
230230

231231
calculations_by_ecosystem_uuid = defaultdict(list)
232232
for calc in calculations:
233-
if all(resp['response_uuid'] in responses_by_uuid for resp in calc['responses']):
233+
if all(resp['trial_uuid'] in responses_by_trial_uuid for resp in calc['responses']):
234234
calculations_by_ecosystem_uuid[calc['ecosystem_uuid']].append(calc)
235235

236236
ecosystem_matrices = session.query(EcosystemMatrix).filter(
@@ -252,7 +252,7 @@ def calculate_clues():
252252
for calculation in ecosystem_calculations
253253
for student_uuid in calculation['student_uuids']
254254
],
255-
responses=[responses_by_uuid[response['response_uuid']]
255+
responses=[responses_by_trial_uuid[response['trial_uuid']]
256256
for calculation in ecosystem_calculations
257257
for response in calculation['responses']]
258258
)

0 commit comments

Comments
 (0)
This repository has been archived.