diff --git a/apps/market/cron.py b/apps/market/cron.py index df27176c0f..6547507d9c 100644 --- a/apps/market/cron.py +++ b/apps/market/cron.py @@ -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): diff --git a/apps/market/tests/test_cron.py b/apps/market/tests/test_cron.py index 05eb6a3a1e..59d276ef32 100644 --- a/apps/market/tests/test_cron.py +++ b/apps/market/tests/test_cron.py @@ -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): diff --git a/scripts/crontab/crontab.tpl b/scripts/crontab/crontab.tpl index 5bce20a129..fe564785de 100644 --- a/scripts/crontab/crontab.tpl +++ b/scripts/crontab/crontab.tpl @@ -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