mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00
Adding days arg to popular stories to grab even more.
This commit is contained in:
parent
7f42a7ae10
commit
619efc8b83
1 changed files with 4 additions and 4 deletions
|
@ -1155,11 +1155,11 @@ class MSharedStory(mongo.Document):
|
|||
story.save()
|
||||
|
||||
@classmethod
|
||||
def collect_popular_stories(cls, cutoff=None):
|
||||
def collect_popular_stories(cls, cutoff=None, days=1):
|
||||
from apps.statistics.models import MStatistics
|
||||
shared_stories_count = sum(json.decode(MStatistics.get('stories_shared')))
|
||||
cutoff = cutoff or max(math.floor(.05 * shared_stories_count), 3)
|
||||
today = datetime.datetime.now() - datetime.timedelta(days=1)
|
||||
today = datetime.datetime.now() - datetime.timedelta(days=days)
|
||||
|
||||
map_f = """
|
||||
function() {
|
||||
|
@ -1194,11 +1194,11 @@ class MSharedStory(mongo.Document):
|
|||
return stories, cutoff
|
||||
|
||||
@classmethod
|
||||
def share_popular_stories(cls, cutoff=None, verbose=True):
|
||||
def share_popular_stories(cls, cutoff=None, days=None, verbose=True):
|
||||
publish_new_stories = False
|
||||
popular_profile = MSocialProfile.objects.get(username='popular')
|
||||
popular_user = User.objects.get(pk=popular_profile.user_id)
|
||||
shared_stories_today, cutoff = cls.collect_popular_stories(cutoff=cutoff)
|
||||
shared_stories_today, cutoff = cls.collect_popular_stories(cutoff=cutoff, days=days)
|
||||
for guid, story_info in shared_stories_today.items():
|
||||
story, _ = MStory.find_story(story_info['feed_id'], story_info['guid'])
|
||||
if not story:
|
||||
|
|
Loading…
Add table
Reference in a new issue