backend
backend copied to clipboard
story exists, but doesn't show in search results
A user found a story at one point, but when returning to their query later couldn't find the same one, so they emailed us. The story id in question is 246740771. I can reproduce this in code . The final assertion in the code below fails, which doesn't seem right.
missing_stories_id = 246740771
# verify story exists by id
story = mc.story(missing_stories_id)
assert story['stories_id'] == missing_stories_id
# now try to find it via a query clause with a call to storyList
results = mc.storyList('stories_id:{}'.format(missing_stories_id))
assert len(results) == 1
Here's a longer example that similarly fails, but more closely matches what one might try to do in Explorer to locate the story.
missing_stories_id = 246740771
def matching_stories(q, fq):
last_id = 0
more_stories = True
stories = []
while more_stories:
page = mc.storyList(q, fq, last_processed_stories_id=last_id, rows=500, sort='processed_stories_id')
if len(page) == 0:
more_stories = False
else:
stories += page
last_id = page[-1]['processed_stories_id']
return stories
# verify story exists by id
story = mc.story(missing_stories_id)
assert story['stories_id'] == missing_stories_id
# try to find based in search based on media sourece and data
import dateparser
from datetime import timedelta
pub_date = dateparser.parse(story['publish_date'])
day_before = pub_date - timedelta(days=1)
day_after = pub_date + timedelta(days=1)
stories = matching_stories("media_id:{}".format(story['media_id']), mc.publish_date_query(day_before, day_after))
story_ids = [s['stories_id'] for s in stories]
assert missing_stories_id in story_ids