mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-08-05 16:58:59 +00:00
28 lines
949 B
Python
28 lines
949 B
Python
![]() |
import time
|
||
|
from django.conf import settings
|
||
|
from apps.rss_feeds.models import MStory, Feed
|
||
|
|
||
|
db = settings.MONGODB
|
||
|
batch = 0
|
||
|
start = 0
|
||
|
for f in xrange(start, Feed.objects.latest('pk').pk):
|
||
|
if f < batch*100000: continue
|
||
|
start = time.time()
|
||
|
try:
|
||
|
cp1 = time.time() - start
|
||
|
# if feed.active_premium_subscribers < 1: continue
|
||
|
stories = MStory.objects.filter(story_feed_id=f, story_hash__exists=False)\
|
||
|
.only('id', 'story_feed_id', 'story_guid')
|
||
|
cp2 = time.time() - start
|
||
|
count = 0
|
||
|
for story in stories:
|
||
|
count += 1
|
||
|
db.newsblur.stories.update({"_id": story.id}, {"$set": {
|
||
|
"story_hash": story.feed_guid_hash
|
||
|
}})
|
||
|
cp3 = time.time() - start
|
||
|
print "%s: %3s stories (%s/%s/%s)" % (f, count, round(cp1, 2), round(cp2, 2), round(cp3, 2))
|
||
|
except Exception, e:
|
||
|
print " ***> (%s) %s" % (f, e)
|
||
|
|