Removing obsolete clean_out_addonpremium task (bug 918852)
This commit is contained in:
Родитель
07a0cf8a4f
Коммит
e32c96ac1d
|
@ -3,32 +3,12 @@ from datetime import datetime, timedelta
|
|||
import commonware.log
|
||||
import cronjobs
|
||||
|
||||
from django.conf import settings
|
||||
from django.db.models import Count
|
||||
|
||||
from addons.models import Addon, AddonUser
|
||||
import amo
|
||||
from amo.utils import chunked, send_mail_jinja
|
||||
from market.models import AddonPremium, Refund
|
||||
from amo.utils import chunked
|
||||
from devhub.models import ActivityLog
|
||||
|
||||
log = commonware.log.getLogger('z.cron')
|
||||
|
||||
DAYS_OLD = 1
|
||||
|
||||
|
||||
@cronjobs.register
|
||||
def clean_out_addonpremium(days=DAYS_OLD):
|
||||
"""Clean out premiums if the addon is not premium."""
|
||||
old = datetime.now() - timedelta(days=days)
|
||||
objs = AddonPremium.objects.filter(addon__premium_type=amo.ADDON_FREE,
|
||||
created__lt=old)
|
||||
log.info('Deleting %s old addonpremiums.' % objs.count())
|
||||
for obj in objs:
|
||||
log.info('Delete addonpremium %s which was created on %s' %
|
||||
(obj.addon_id, obj.created))
|
||||
obj.delete()
|
||||
|
||||
|
||||
@cronjobs.register
|
||||
def mkt_gc(**kw):
|
||||
|
|
|
@ -1,39 +1,15 @@
|
|||
from datetime import datetime, timedelta
|
||||
from datetime import datetime
|
||||
|
||||
from nose.tools import eq_
|
||||
|
||||
import amo
|
||||
import amo.tests
|
||||
|
||||
from addons.models import Addon
|
||||
from devhub.models import ActivityLog
|
||||
from market.cron import clean_out_addonpremium, mkt_gc
|
||||
from market.models import AddonPremium
|
||||
from market.cron import mkt_gc
|
||||
from users.models import UserProfile
|
||||
|
||||
|
||||
class TestCronDeletes(amo.tests.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
for x in xrange(0, 3):
|
||||
addon = Addon.objects.create(type=amo.ADDON_EXTENSION)
|
||||
premium = AddonPremium.objects.create(addon=addon)
|
||||
premium.update(created=datetime.today() -
|
||||
timedelta(days=x, seconds=5))
|
||||
|
||||
def test_delete(self):
|
||||
eq_(AddonPremium.objects.count(), 3)
|
||||
clean_out_addonpremium(days=2)
|
||||
eq_(AddonPremium.objects.count(), 2)
|
||||
clean_out_addonpremium(days=1)
|
||||
eq_(AddonPremium.objects.count(), 1)
|
||||
|
||||
def test_doesnt_delete(self):
|
||||
Addon.objects.all().update(premium_type=amo.ADDON_PREMIUM)
|
||||
clean_out_addonpremium(days=1)
|
||||
eq_(AddonPremium.objects.count(), 3)
|
||||
|
||||
|
||||
class TestGarbage(amo.tests.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
|
|
@ -57,7 +57,6 @@ HOME=/tmp
|
|||
30 6 * * * %(z_cron)s deliver_hotness
|
||||
40 7 * * * %(z_cron)s update_compat_info_for_fx4
|
||||
45 7 * * * %(django)s dump_apps
|
||||
55 7 * * * %(z_cron)s clean_out_addonpremium
|
||||
|
||||
# Collect visitor stats from Google Analytics once per day.
|
||||
50 10 * * * %(z_cron)s update_google_analytics --settings=settings_local_mkt
|
||||
|
|
Загрузка…
Ссылка в новой задаче