mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00
Adding new celery command line option to fetch feeds. Will be used to fetch feeds on a cronjob.
This commit is contained in:
parent
0805c7fc04
commit
852b6a5441
1 changed files with 30 additions and 0 deletions
30
apps/rss_feeds/management/commands/task_feeds.py
Normal file
30
apps/rss_feeds/management/commands/task_feeds.py
Normal file
|
@ -0,0 +1,30 @@
|
|||
from django.core.management.base import BaseCommand
|
||||
from django.conf import settings
|
||||
from apps.rss_feeds.models import Feed
|
||||
from optparse import make_option
|
||||
from apps.rss_feeds.tasks import RefreshFeed
|
||||
import datetime
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
option_list = BaseCommand.option_list + (
|
||||
make_option("-f", "--feed", default=None),
|
||||
make_option("-F", "--force", dest="force", action="store_true"),
|
||||
make_option('-V', '--verbose', action='store_true',
|
||||
dest='verbose', default=False, help='Verbose output.'),
|
||||
)
|
||||
|
||||
def handle(self, *args, **options):
|
||||
settings.LOG_TO_STREAM = True
|
||||
now = datetime.datetime.now()
|
||||
|
||||
feeds = Feed.objects.filter(next_scheduled_update__lte=now).order_by('?')
|
||||
|
||||
if options['force']:
|
||||
feeds = Feed.objects.all()
|
||||
|
||||
print " ---> Tasking %s feeds..." % feeds.count()
|
||||
|
||||
for f in feeds:
|
||||
RefreshFeed.apply_async(args=(f.pk,))
|
||||
|
Loading…
Add table
Reference in a new issue