<commit_before>"""JSON endpoint for a Gittip widget.
"""
from gittip.participant import Participant

# ========================================================================== ^L

participant = Participant(path['participant_id'])
receiving = participant.get_dollars_receiving()

response.headers["Access-Control-Allow-Origin"] = "*"
response.body = {"receiving": str(receiving)}<commit_msg>Added my_tip to public.json if user is logged in #476<commit_after>"""JSON endpoint for a Gittip widget.
"""
from gittip.participant import Participant

# ========================================================================== ^L

participant = Participant(path['participant_id'])
receiving = participant.get_dollars_receiving()

output = {"receiving": str(receiving)}

# Generate my_tip key
# ========
# Display values:
# undefined - user is not authenticated
# null - user has never tipped this person
# 0.00 - user used to tip this person but now doesn't
# 3.00 - user tips this person this amount
if not user.ANON and user.id != path['participant_id']: 
	my_tip = Participant.get_tip_to(user, path['participant_id'])
	if my_tip == 0:
	    my_tip = "%0.2f" % 0.00
	output["my_tip"] = str(my_tip)

response.headers["Access-Control-Allow-Origin"] = "*"
response.body = output
{'fraction_non_alphanumeric': 0.23524783634933125, 'fraction_numerical': 0.011801730920535013, 'mean_word_length': 6.106145251396648, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1761830', 'n_tokens_mistral': 407, 'n_tokens_neox': 363, 'n_words': 99}