bug 631695, Migrate approval data to log_activity
This commit is contained in:
Родитель
7d997c2984
Коммит
b8563c0b03
|
@ -22,12 +22,11 @@ from bandwagon.models import Collection
|
|||
from cake.models import Session
|
||||
from devhub.models import ActivityLog, LegacyAddonLog
|
||||
from editors.models import EventLog
|
||||
from files.models import TestResultCache
|
||||
from files.models import Approval, File, TestResultCache
|
||||
from reviews.models import Review
|
||||
from sharing import SERVICES_LIST
|
||||
from stats.models import AddonShareCount, Contribution
|
||||
from users.models import UserProfile
|
||||
from versions.models import Version
|
||||
|
||||
log = commonware.log.getLogger('z.cron')
|
||||
|
||||
|
@ -166,6 +165,45 @@ def _migrate_editor_eventlog(items, **kw):
|
|||
log.warning("Couldn't find review for %d" % item.changed_id)
|
||||
|
||||
|
||||
# TODO(davedash): remove aftr /editors is on zamboni
|
||||
@cronjobs.register
|
||||
def migrate_approvals():
|
||||
a = MigrationTracker('approvals')
|
||||
id = a.get() or 0
|
||||
|
||||
items = Approval.objects.filter(pk__gt=id).values_list('id', flat=True)
|
||||
|
||||
for chunk in chunked(items, 100):
|
||||
_migrate_approvals(chunk)
|
||||
a.set(chunk[-1])
|
||||
|
||||
|
||||
@task
|
||||
def _migrate_approvals(items, **kw):
|
||||
log.info('[%s@%s] Migrating approval items' %
|
||||
(len(items), _migrate_approvals.rate_limit))
|
||||
for item in Approval.objects.filter(pk__in=items):
|
||||
try:
|
||||
args = (item.reviewtype, item.addon, item.file.version)
|
||||
except File.DoesNotExist:
|
||||
log.warning("Couldn't find file for approval %d" % item.id)
|
||||
continue
|
||||
|
||||
kw = dict(user=item.user, created=item.created)
|
||||
if item.action == amo.STATUS_PUBLIC:
|
||||
amo.log(amo.LOG.APPROVE_VERSION, *args, **kw)
|
||||
elif item.action == amo.STATUS_LITE:
|
||||
amo.log(amo.LOG.PRELIMINARY_VERSION, *args, **kw)
|
||||
elif item.action == amo.STATUS_NULL:
|
||||
amo.log(amo.LOG.REJECT_VERSION, *args, **kw)
|
||||
elif item.action in (amo.STATUS_PENDING, amo.STATUS_NOMINATED):
|
||||
amo.log(amo.LOG.ESCALATE_VERSION, *args, **kw)
|
||||
elif item.action == amo.STATUS_UNREVIEWED:
|
||||
amo.log(amo.LOG.RETAIN_VERSION, *args, **kw)
|
||||
else:
|
||||
log.warning('Unknown action: %d' % item.action)
|
||||
|
||||
|
||||
@cronjobs.register
|
||||
def dissolve_outgoing_urls():
|
||||
"""Over time, some outgoing.m.o URLs have been encoded several times in the
|
||||
|
|
|
@ -135,21 +135,30 @@ class DELETE_FILE_FROM_VERSION:
|
|||
format = _(u'File {0} deleted from {version} of {addon}.')
|
||||
|
||||
|
||||
# TODO(davedash): When editor tools exist
|
||||
class APPROVE_VERSION:
|
||||
id = 21
|
||||
format = _(u'{addon} {version} approved.')
|
||||
keep = True
|
||||
|
||||
|
||||
# TODO(davedash): When editor tools exist
|
||||
class PRELIMINARY_VERSION:
|
||||
id = 42
|
||||
format = _(u'{addon} {version} given preliminary review.')
|
||||
keep = True
|
||||
|
||||
|
||||
class REJECT_VERSION:
|
||||
id = 43
|
||||
format = _(u'{addon} {version} rejected.')
|
||||
keep = True
|
||||
|
||||
|
||||
class RETAIN_VERSION:
|
||||
id = 22
|
||||
format = _(u'{addon} {version} retained.')
|
||||
keep = True
|
||||
|
||||
|
||||
# TODO(davedash): When editor tools exist
|
||||
class ESCALATE_VERSION:
|
||||
id = 23
|
||||
# L10n: {0.version} is the version of an addon.
|
||||
|
@ -157,7 +166,6 @@ class ESCALATE_VERSION:
|
|||
keep = True
|
||||
|
||||
|
||||
# TODO(davedash): When editor tools exist
|
||||
class REQUEST_VERSION:
|
||||
id = 24
|
||||
# L10n: {0.version} is the version of an addon.
|
||||
|
@ -284,7 +292,7 @@ LOGS = (CREATE_ADDON, EDIT_PROPERTIES, EDIT_DESCRIPTIONS, EDIT_CATEGORIES,
|
|||
ADD_RECOMMENDED_CATEGORY, REMOVE_RECOMMENDED_CATEGORY, ADD_RECOMMENDED,
|
||||
REMOVE_RECOMMENDED, ADD_APPVERSION, CUSTOM_TEXT, CUSTOM_HTML,
|
||||
CHANGE_USER_WITH_ROLE, CHANGE_LICENSE, CHANGE_POLICY, CHANGE_ICON,
|
||||
APPROVE_REVIEW, DELETE_REVIEW,)
|
||||
APPROVE_REVIEW, DELETE_REVIEW, PRELIMINARY_VERSION, REJECT_VERSION)
|
||||
LOG_BY_ID = dict((l.id, l) for l in LOGS)
|
||||
LOG = AttributeDict((l.__name__, l) for l in LOGS)
|
||||
LOG_KEEP = [l.id for l in LOGS if hasattr(l, 'keep')]
|
||||
|
|
Загрузка…
Ссылка в новой задаче