Skip to content

Commit

Permalink
Merge pull request #6 from oduwsdl/DuplicateStoriesFix
Browse files Browse the repository at this point in the history
fix duplicate error caused by removing story once it is matched
  • Loading branch information
kritikagarg authored Jun 8, 2021
2 parents 7c937f8 + 852cc87 commit 78722f7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
9 changes: 4 additions & 5 deletions storygraph_bot/backbone.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,15 @@ def mapper(overlap_threshold, cachedstories_uri_dts, stories_uri_dts, cache_stor

overlap = sorted(overlap, key=lambda x: x['coeff'], reverse=True)
maxcoeff = overlap[0]['coeff']
chosensgtk_story_id = overlap[0]['sgtk_story_id']

if maxcoeff >= overlap_threshold:

if maxcoeff >= overlap_threshold:
chosensgtk_story_id = overlap[0]['sgtk_story_id']
new_graphs = sorted(list(stories_uri_dts[chosensgtk_story_id] - cs_uridt), reverse=True)
matched_stories.update({story_id: {'overlap': overlap, "new_graph_timestamps": new_graphs}})
stories_uri_dts[chosensgtk_story_id] = set()
else:
unmatched_stories.update({story_id: {'overlap': overlap}})

stories_uri_dts[chosensgtk_story_id] = set()

map_cachestories["matched_stories"] = matched_stories
map_cachestories["unmatched_stories"] = unmatched_stories
return(map_cachestories)
Expand Down
5 changes: 2 additions & 3 deletions storygraph_bot/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,12 @@ def dump_json_to_file(outfilename, dict_to_write, indent_flag=True, extra_params



def get_storygraph_stories(sgbot_path, start_datetime, end_datetime):

def get_storygraph_stories(sgbot_path, start_datetime, end_datetime):
data = {}
try:
cmd = (f'sgtk --pretty-print -o {sgbot_path}/tmp/current_storygraphdata.json maxgraph --cluster-stories-by="max_avg_degree" --cluster-stories --start-datetime="{start_datetime}" --end-datetime="{end_datetime}" > {sgbot_path}/tmp/console_output.log 2>&1')
a = os.system(cmd)
data = get_dict_frm_file( f"{sgbot_path}/tmp/current_storygraphdata.json" )
data = get_dict_frm_file(f'{sgbot_path}/tmp/current_storygraphdata.json')
except FileNotFoundError as e:
logger.error('Please install storygraph-toolkit: https://github.com/oduwsdl/storygraph-toolkit.git')

Expand Down

0 comments on commit 78722f7

Please sign in to comment.