Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
MOOC packages by hacklab
django-courses
Commits
a1f871c8
Commit
a1f871c8
authored
Oct 02, 2020
by
Matheus Miranda
Browse files
Add user of iterator on queryset
parent
9c3c0fa8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
3 deletions
+4
-3
courses/reports/management/commands/generate_activities_actions.py
...eports/management/commands/generate_activities_actions.py
+4
-3
No files found.
courses/reports/management/commands/generate_activities_actions.py
View file @
a1f871c8
...
...
@@ -24,10 +24,8 @@ class Command(BaseCommand):
def
handle
(
self
,
*
args
,
**
options
):
answered_actions_ids
=
Action
.
objects
.
filter
(
verb
=
'answered'
).
values_list
(
'action_object_object_id'
,
flat
=
True
)
counter
=
0
# Create any missing Answer action
answers
=
Answer
.
objects
.
all
()
answers
=
Answer
.
objects
.
all
()
.
iterator
()
for
answer
in
answers
:
activity_id
=
answer
.
activity_id
...
...
@@ -35,6 +33,7 @@ class Command(BaseCommand):
verb
=
'answered'
if
str
(
answer
.
id
)
in
answered_actions_ids
:
print
(
'Skipped for answer id:'
,
answer
.
id
)
continue
timesince
=
djtimesince
(
answer
.
timestamp
).
encode
(
'utf8'
).
replace
(
b
'
\xc2\xa0
'
,
b
' '
).
decode
(
'utf8'
)
...
...
@@ -43,3 +42,5 @@ class Command(BaseCommand):
action_obj
=
action_tuple
[
0
][
1
]
action_obj
.
timestamp
=
answer
.
timestamp
action_obj
.
save
()
print
(
"Creating action for answer id:"
,
answer
.
id
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment