mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-04-13 09:42:01 +00:00
change celery Task import and task initialization as per the new version of celery
This commit is contained in:
parent
0e4eb419ad
commit
89e51a2937
23 changed files with 35 additions and 35 deletions
|
@ -45,7 +45,7 @@ class MPopularityQuery(mongo.Document):
|
|||
return "%s - \"%s\"" % (self.email, self.query)
|
||||
|
||||
def queue_email(self):
|
||||
EmailPopularityQuery.delay(pk=self.pk)
|
||||
EmailPopularityQuery().delay(pk=self.pk)
|
||||
|
||||
@classmethod
|
||||
def ensure_all_sent(cls, queue=True):
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from celery.task import Task
|
||||
from celery import Task
|
||||
from utils import log as logging
|
||||
|
||||
class EmailPopularityQuery(Task):
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from celery.task import Task
|
||||
from celery import Task
|
||||
from django.contrib.auth.models import User
|
||||
from apps.feed_import.models import UploadedOPML, OPMLImporter
|
||||
from apps.reader.models import UserSubscription
|
||||
|
|
|
@ -46,7 +46,7 @@ def opml_upload(request):
|
|||
folders = opml_importer.try_processing()
|
||||
except TimeoutError:
|
||||
folders = None
|
||||
ProcessOPML.delay(request.user.pk)
|
||||
ProcessOPML().delay(request.user.pk)
|
||||
feed_count = opml_importer.count_feeds_in_opml()
|
||||
logging.user(request, "~FR~SBOPML upload took too long, found %s feeds. Tasking..." % feed_count)
|
||||
payload = dict(folders=folders, delayed=True, feed_count=feed_count)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from celery.task import Task
|
||||
from celery import Task
|
||||
from django.contrib.auth.models import User
|
||||
from apps.notifications.models import MUserFeedNotification
|
||||
from utils import log as logging
|
||||
|
|
|
@ -67,7 +67,7 @@ def twitter_connect(request):
|
|||
social_services.syncing_twitter = True
|
||||
social_services.save()
|
||||
|
||||
SyncTwitterFriends.delay(user_id=request.user.pk)
|
||||
SyncTwitterFriends().delay(user_id=request.user.pk)
|
||||
|
||||
logging.user(request, "~BB~FRFinishing Twitter connect")
|
||||
return {}
|
||||
|
@ -131,7 +131,7 @@ def facebook_connect(request):
|
|||
social_services.syncing_facebook = True
|
||||
social_services.save()
|
||||
|
||||
SyncFacebookFriends.delay(user_id=request.user.pk)
|
||||
SyncFacebookFriends().delay(user_id=request.user.pk)
|
||||
|
||||
logging.user(request, "~BB~FRFinishing Facebook connect")
|
||||
return {}
|
||||
|
|
|
@ -29,7 +29,7 @@ class LastSeenMiddleware(object):
|
|||
logging.user(request, "~FG~BBRepeat visitor: ~SB%s (%s)" % (
|
||||
request.user.profile.last_seen_on, ip))
|
||||
from apps.profile.tasks import CleanupUser
|
||||
CleanupUser.delay(user_id=request.user.pk)
|
||||
CleanupUser().delay(user_id=request.user.pk)
|
||||
elif settings.DEBUG:
|
||||
logging.user(request, "~FG~BBRepeat visitor (ignored): ~SB%s (%s)" % (
|
||||
request.user.profile.last_seen_on, ip))
|
||||
|
|
|
@ -161,7 +161,7 @@ class Profile(models.Model):
|
|||
def activate_premium(self, never_expire=False):
|
||||
from apps.profile.tasks import EmailNewPremium
|
||||
|
||||
EmailNewPremium.delay(user_id=self.user.pk)
|
||||
EmailNewPremium().delay(user_id=self.user.pk)
|
||||
|
||||
was_premium = self.is_premium
|
||||
self.is_premium = True
|
||||
|
@ -186,7 +186,7 @@ class Profile(models.Model):
|
|||
scheduled_feeds = []
|
||||
logging.user(self.user, "~SN~FMTasking the scheduling immediate premium setup of ~SB%s~SN feeds..." %
|
||||
len(scheduled_feeds))
|
||||
SchedulePremiumSetup.apply_async(kwargs=dict(feed_ids=scheduled_feeds))
|
||||
SchedulePremiumSetup().apply_async(kwargs=dict(feed_ids=scheduled_feeds))
|
||||
|
||||
UserSubscription.queue_new_feeds(self.user)
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import datetime
|
||||
from celery.task import Task
|
||||
from celery import Task
|
||||
from apps.profile.models import Profile, RNewUserQueue
|
||||
from utils import log as logging
|
||||
from apps.reader.models import UserSubscription, UserSubscriptionFolders
|
||||
|
|
|
@ -166,7 +166,7 @@ class SignupForm(forms.Form):
|
|||
RNewUserQueue.add_user(new_user.pk)
|
||||
|
||||
if new_user.email:
|
||||
EmailNewUser.delay(user_id=new_user.pk)
|
||||
EmailNewUser().delay(user_id=new_user.pk)
|
||||
|
||||
if getattr(settings, 'AUTO_PREMIUM_NEW_USERS', False):
|
||||
new_user.profile.activate_premium()
|
||||
|
|
|
@ -475,7 +475,7 @@ class UserSubscription(models.Model):
|
|||
logging.user(user, "~BB~FW~SBQueueing NewFeeds: ~FC(%s) %s" % (len(new_feeds), new_feeds))
|
||||
size = 4
|
||||
for t in (new_feeds[pos:pos + size] for pos in range(0, len(new_feeds), size)):
|
||||
NewFeeds.apply_async(args=(t,), queue="new_feeds")
|
||||
NewFeeds().apply_async(args=(t,), queue="new_feeds")
|
||||
|
||||
@classmethod
|
||||
def refresh_stale_feeds(cls, user, exclude_new=False):
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import datetime
|
||||
from celery.task import Task
|
||||
from celery import Task
|
||||
from utils import log as logging
|
||||
from django.contrib.auth.models import User
|
||||
from django.conf import settings
|
||||
|
|
|
@ -301,7 +301,7 @@ def load_feeds(request):
|
|||
if len(scheduled_feeds) > 0 and request.user.is_authenticated:
|
||||
logging.user(request, "~SN~FMTasking the scheduling immediate fetch of ~SB%s~SN feeds..." %
|
||||
len(scheduled_feeds))
|
||||
ScheduleImmediateFetches.apply_async(kwargs=dict(feed_ids=scheduled_feeds, user_id=user.pk))
|
||||
ScheduleImmediateFetches().apply_async(kwargs=dict(feed_ids=scheduled_feeds, user_id=user.pk))
|
||||
|
||||
starred_counts, starred_count = MStarredStoryCounts.user_counts(user.pk, include_total=True)
|
||||
if not starred_count and len(starred_counts):
|
||||
|
@ -410,7 +410,7 @@ def load_feeds_flat(request):
|
|||
if len(scheduled_feeds) > 0 and request.user.is_authenticated:
|
||||
logging.user(request, "~SN~FMTasking the scheduling immediate fetch of ~SB%s~SN feeds..." %
|
||||
len(scheduled_feeds))
|
||||
ScheduleImmediateFetches.apply_async(kwargs=dict(feed_ids=scheduled_feeds, user_id=user.pk))
|
||||
ScheduleImmediateFetches().apply_async(kwargs=dict(feed_ids=scheduled_feeds, user_id=user.pk))
|
||||
|
||||
flat_folders = []
|
||||
flat_folders_with_inactive = []
|
||||
|
|
|
@ -5,4 +5,4 @@ class Command(BaseCommand):
|
|||
option_list = BaseCommand.option_list
|
||||
|
||||
def handle(self, *args, **options):
|
||||
BackupMongo.apply()
|
||||
BackupMongo().apply()
|
|
@ -15,6 +15,6 @@ class Command(BaseCommand):
|
|||
|
||||
def handle(self, *args, **options):
|
||||
if options['broken']:
|
||||
TaskBrokenFeeds.apply()
|
||||
TaskBrokenFeeds().apply()
|
||||
else:
|
||||
TaskFeeds.apply()
|
||||
TaskFeeds().apply()
|
|
@ -561,7 +561,7 @@ class Feed(models.Model):
|
|||
|
||||
# for feed_ids in (feeds[pos:pos + queue_size] for pos in xrange(0, len(feeds), queue_size)):
|
||||
for feed_id in feeds:
|
||||
UpdateFeeds.apply_async(args=(feed_id,), queue='update_feeds')
|
||||
UpdateFeeds().apply_async(args=(feed_id,), queue='update_feeds')
|
||||
|
||||
@classmethod
|
||||
def drain_task_feeds(cls):
|
||||
|
@ -2250,7 +2250,7 @@ class Feed(models.Model):
|
|||
else:
|
||||
logging.debug(' ---> [%-30s] [%s] ~FB~SBQueuing pushed stories, last pushed %s...' % (self.log_title[:30], self.pk, latest_push_date_delta))
|
||||
self.set_next_scheduled_update()
|
||||
PushFeeds.apply_async(args=(self.pk, xml), queue='push_feeds')
|
||||
PushFeeds().apply_async(args=(self.pk, xml), queue='push_feeds')
|
||||
|
||||
# def calculate_collocations_story_content(self,
|
||||
# collocation_measures=TrigramAssocMeasures,
|
||||
|
@ -3047,7 +3047,7 @@ class MStarredStoryCounts(mongo.Document):
|
|||
|
||||
@classmethod
|
||||
def schedule_count_tags_for_user(cls, user_id):
|
||||
ScheduleCountTagsForUser.apply_async(kwargs=dict(user_id=user_id))
|
||||
ScheduleCountTagsForUser().apply_async(kwargs=dict(user_id=user_id))
|
||||
|
||||
@classmethod
|
||||
def count_for_user(cls, user_id, total_only=False):
|
||||
|
|
|
@ -3,7 +3,7 @@ import os
|
|||
import shutil
|
||||
import time
|
||||
import redis
|
||||
from celery.task import Task
|
||||
from celery import Task
|
||||
from celery.exceptions import SoftTimeLimitExceeded
|
||||
from utils import log as logging
|
||||
from utils import s3_utils as s3
|
||||
|
|
|
@ -49,7 +49,7 @@ class MUserSearch(mongo.Document):
|
|||
self.save()
|
||||
|
||||
def schedule_index_subscriptions_for_search(self):
|
||||
IndexSubscriptionsForSearch.apply_async(kwargs=dict(user_id=self.user_id),
|
||||
IndexSubscriptionsForSearch().apply_async(kwargs=dict(user_id=self.user_id),
|
||||
queue='search_indexer_tasker')
|
||||
|
||||
# Should be run as a background task
|
||||
|
@ -122,7 +122,7 @@ class MUserSearch(mongo.Document):
|
|||
|
||||
if not isinstance(feed_ids, list):
|
||||
feed_ids = [feed_ids]
|
||||
IndexFeedsForSearch.apply_async(kwargs=dict(feed_ids=feed_ids, user_id=user_id),
|
||||
IndexFeedsForSearch().apply_async(kwargs=dict(feed_ids=feed_ids, user_id=user_id),
|
||||
queue='search_indexer')
|
||||
|
||||
@classmethod
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from celery.task import Task
|
||||
from celery import Task
|
||||
|
||||
class IndexSubscriptionsForSearch(Task):
|
||||
|
||||
|
|
|
@ -474,7 +474,7 @@ class MSocialProfile(mongo.Document):
|
|||
|
||||
if followee.protected and user_id != self.user_id and not force:
|
||||
from apps.social.tasks import EmailFollowRequest
|
||||
EmailFollowRequest.apply_async(kwargs=dict(follower_user_id=self.user_id,
|
||||
EmailFollowRequest().apply_async(kwargs=dict(follower_user_id=self.user_id,
|
||||
followee_user_id=user_id),
|
||||
countdown=settings.SECONDS_TO_DELAY_CELERY_EMAILS)
|
||||
return
|
||||
|
@ -500,7 +500,7 @@ class MSocialProfile(mongo.Document):
|
|||
|
||||
if not force:
|
||||
from apps.social.tasks import EmailNewFollower
|
||||
EmailNewFollower.apply_async(kwargs=dict(follower_user_id=self.user_id,
|
||||
EmailNewFollower().apply_async(kwargs=dict(follower_user_id=self.user_id,
|
||||
followee_user_id=user_id),
|
||||
countdown=settings.SECONDS_TO_DELAY_CELERY_EMAILS)
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from bson.objectid import ObjectId
|
||||
from celery.task import Task
|
||||
from celery import Task
|
||||
from apps.social.models import MSharedStory, MSocialProfile, MSocialServices, MSocialSubscription
|
||||
from django.contrib.auth.models import User
|
||||
from utils import log as logging
|
||||
|
|
|
@ -621,7 +621,7 @@ def mark_story_as_shared(request):
|
|||
})
|
||||
if source_user_id:
|
||||
shared_story.set_source_user_id(int(source_user_id))
|
||||
UpdateRecalcForSubscription.delay(subscription_user_id=request.user.pk,
|
||||
UpdateRecalcForSubscription().delay(subscription_user_id=request.user.pk,
|
||||
shared_story_id=str(shared_story.id))
|
||||
logging.user(request, "~FCSharing ~FM%s: ~SB~FB%s" % (story.story_title[:20], comments[:30]))
|
||||
else:
|
||||
|
@ -659,13 +659,13 @@ def mark_story_as_shared(request):
|
|||
if post_to_services:
|
||||
for service in post_to_services:
|
||||
if service not in shared_story.posted_to_services:
|
||||
PostToService.delay(shared_story_id=str(shared_story.id), service=service)
|
||||
PostToService().delay(shared_story_id=str(shared_story.id), service=service)
|
||||
|
||||
if shared_story.source_user_id and shared_story.comments:
|
||||
EmailStoryReshares.apply_async(kwargs=dict(shared_story_id=str(shared_story.id)),
|
||||
EmailStoryReshares().apply_async(kwargs=dict(shared_story_id=str(shared_story.id)),
|
||||
countdown=settings.SECONDS_TO_DELAY_CELERY_EMAILS)
|
||||
|
||||
EmailFirstShare.apply_async(kwargs=dict(user_id=request.user.pk))
|
||||
EmailFirstShare().apply_async(kwargs=dict(user_id=request.user.pk))
|
||||
|
||||
if format == 'html':
|
||||
stories = MSharedStory.attach_users_to_stories(stories, profiles)
|
||||
|
@ -812,7 +812,7 @@ def save_comment_reply(request):
|
|||
story_feed_id=feed_id,
|
||||
story_title=shared_story.story_title)
|
||||
|
||||
EmailCommentReplies.apply_async(kwargs=dict(shared_story_id=str(shared_story.id),
|
||||
EmailCommentReplies().apply_async(kwargs=dict(shared_story_id=str(shared_story.id),
|
||||
reply_id=str(reply.reply_id)),
|
||||
countdown=settings.SECONDS_TO_DELAY_CELERY_EMAILS)
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from celery.task import Task
|
||||
from celery import Task
|
||||
from apps.statistics.models import MStatistics
|
||||
from apps.statistics.models import MFeedback
|
||||
# from utils import log as logging
|
||||
|
|
Loading…
Add table
Reference in a new issue