Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
83cb3d19
Commit
83cb3d19
authored
Jul 18, 2013
by
Ned Batchelder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add batch and sleep arguments so we can control the speed from the command line.
parent
3a49136f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
2 deletions
+17
-2
lms/djangoapps/courseware/management/commands/clean_history.py
+17
-2
No files found.
lms/djangoapps/courseware/management/commands/clean_history.py
View file @
83cb3d19
...
...
@@ -12,6 +12,7 @@ import datetime
import
json
import
logging
import
optparse
import
time
import
traceback
from
django.core.management.base
import
NoArgsCommand
...
...
@@ -25,11 +26,23 @@ class Command(NoArgsCommand):
option_list
=
NoArgsCommand
.
option_list
+
(
optparse
.
make_option
(
'--batch'
,
type
=
'int'
,
default
=
100
,
help
=
"Batch size, number of module_ids to examine in a transaction."
,
),
optparse
.
make_option
(
'--dry-run'
,
action
=
'store_true'
,
default
=
False
,
help
=
"Don't change the database, just show what would be done."
,
),
optparse
.
make_option
(
'--sleep'
,
type
=
'float'
,
default
=
0
,
help
=
"Seconds to sleep between batches."
,
),
)
def
handle_noargs
(
self
,
**
options
):
...
...
@@ -39,7 +52,7 @@ class Command(NoArgsCommand):
smhc
=
StudentModuleHistoryCleaner
(
dry_run
=
options
[
"dry_run"
],
)
smhc
.
main
()
smhc
.
main
(
batch_size
=
options
[
"batch"
],
sleep
=
options
[
"sleep"
]
)
class
StudentModuleHistoryCleaner
(
object
):
...
...
@@ -54,7 +67,7 @@ class StudentModuleHistoryCleaner(object):
self
.
next_student_module_id
=
0
self
.
last_student_module_id
=
0
def
main
(
self
,
batch_size
=
None
):
def
main
(
self
,
batch_size
=
None
,
sleep
=
0
):
"""Invoked from the management command to do all the work."""
batch_size
=
batch_size
or
self
.
BATCH_SIZE
...
...
@@ -74,6 +87,8 @@ class StudentModuleHistoryCleaner(object):
if
not
self
.
dry_run
:
self
.
commit
()
self
.
save_state
()
if
sleep
:
time
.
sleep
(
sleep
)
def
say
(
self
,
message
):
"""
...
...
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