Add date option to RFC Editor index mirroring script so one can
control what the publication cut off date is, also fix crash problem with some old RFCs not having a page count - Legacy-Id: 4907
This commit is contained in:
parent
4aef9182d2
commit
9c6fd95eab
|
@ -14,6 +14,18 @@ from django.core import management
|
|||
management.setup_environ(settings)
|
||||
|
||||
|
||||
from optparse import OptionParser
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option("-d", dest="skip_date",
|
||||
help="To speed up processing skip RFCs published before this date (default is one year ago)", metavar="YYYY-MM-DD")
|
||||
|
||||
options, args = parser.parse_args()
|
||||
|
||||
skip_date = datetime.date.today() - datetime.timedelta(days=365)
|
||||
if options.skip_date:
|
||||
skip_date = datetime.datetime.strptime(options.skip_date, "%Y-%m-%d").date()
|
||||
|
||||
from ietf.sync.rfceditor import *
|
||||
|
||||
syslog.syslog("Updating document metadata from RFC index from %s" % QUEUE_URL)
|
||||
|
@ -25,6 +37,6 @@ if len(data) < MIN_INDEX_RESULTS:
|
|||
syslog.syslog("Not enough results, only %s" % len(data))
|
||||
sys.exit(1)
|
||||
|
||||
changed = update_docs_from_rfc_index(data)
|
||||
changed = update_docs_from_rfc_index(data, skip_older_than_date=skip_date)
|
||||
for c in changed:
|
||||
syslog.syslog(c)
|
||||
|
|
|
@ -273,7 +273,6 @@ def parse_index(response):
|
|||
return data
|
||||
|
||||
|
||||
#skip_older_than_date = date.today() - timedelta(days=365)
|
||||
def update_docs_from_rfc_index(data, skip_older_than_date=None):
|
||||
std_level_mapping = {
|
||||
"Standard": StdLevelName.objects.get(slug="std"),
|
||||
|
@ -347,7 +346,7 @@ def update_docs_from_rfc_index(data, skip_older_than_date=None):
|
|||
if abstract and abstract != doc.abstract:
|
||||
changed_attributes["abstract"] = abstract
|
||||
|
||||
if int(pages) != doc.pages:
|
||||
if pages and int(pages) != doc.pages:
|
||||
changed_attributes["pages"] = int(pages)
|
||||
|
||||
if std_level_mapping[current_status] != doc.std_level:
|
||||
|
|
Loading…
Reference in a new issue