# HG changeset patch # User cavaliet # Date 1355507760 -3600 # Node ID 04f8cf193221bb13e96f93149576d5d0f03811e6 # Parent 581c7906ebb4040e88a8d6111da45a75d7896657 remove zero duration annotations parameter added in mashupbytag. diff -r 581c7906ebb4 -r 04f8cf193221 src/ldt/ldt/ldt_utils/views/json.py --- a/src/ldt/ldt/ldt_utils/views/json.py Fri Dec 14 17:48:30 2012 +0100 +++ b/src/ldt/ldt/ldt_utils/views/json.py Fri Dec 14 18:56:00 2012 +0100 @@ -93,6 +93,13 @@ escape_bool = False if escape_str: escape_bool = {'true': True, 'false': False, "0": False, "1": True}.get(escape_str.lower()) + # do we remove annotations from mashup if the have duration=0 ? (yes by default) + remove_zero_dur_str = request.REQUEST.get("removezeroduration") + remove_zero_dur = True + logging.debug("CC 1 " + str(remove_zero_dur)) + if remove_zero_dur_str: + remove_zero_dur = {'true': True, 'false': False, "0": False, "1": True}.get(remove_zero_dur_str.lower()) + logging.debug("CC 2 " + str(remove_zero_dur)) # We search s = request.REQUEST.get("tag") @@ -160,15 +167,16 @@ for res in highest_weighted: cur_in = res["start_ts"] cur_out = cur_in + res["duration"] - if tc_in<=cur_in and cur_out<=tc_out: + if tc_in<=cur_in and cur_out<=tc_out and ((not remove_zero_dur) or (remove_zero_dur and res["duration"]>0.0)): #mashup_list["items"].append(res["iri_id"] + ", " + res["element_id"] + ", " + str(res["start_ts"]) + ", " + str(res["duration"]) + ", " + str(res["weight"])) mashup_list["items"].append(res["element_id"]) else: # no particular sorting for res in results: cur_in = float(res["start_ts"]) - cur_out = cur_in + float(res["duration"]) - if tc_in<=cur_in and cur_out<=tc_out: + dur = float(res["duration"]) + cur_out = cur_in + dur + if tc_in<=cur_in and cur_out<=tc_out and ((not remove_zero_dur) or (remove_zero_dur and dur>0.0)): mashup_list["items"].append(res["element_id"]) mashup_dict["lists"].append(mashup_list)