def add_comment(comment, user, channel_id, video_id, parent_id): if not user or not channel_id or not video_id: return None video = _video_key(channel_id, video_id) comment = CommentModel( parent=video, comment=comment, user=user, channel_id=channel_id, video_id=video_id, parent_id=int(parent_id) ) comment.put() fastcounter.incr(video_comment_counter(channel_id, video_id)) return comment
def timed(*args, **kw): if not configs.BENCHMARK: return fn(*args, **kw) start = time.time() result = fn(*args, **kw) end = time.time() fastcounter.incr("Function_%s_NumCalls" % name, 1, 3600) fastcounter.incr("Function_%s_TotalMicroSeconds" % name, int((end - start) * 1000000 + 0.5), 3600) return result
def dislike_video(key, channel_id, video_id, delta=1): history = video_dislike_history_counter(key, channel_id, video_id) if fastcounter.get_count(history) > 0: return fastcounter.incr(history) fastcounter.incr(video_dislike_counter(channel_id, video_id), delta)
def view_video(channel_id, video_id): fastcounter.incr(video_view_counter(channel_id, video_id))
def like_comment(channel_id, video_id, comment_id, delta=1): fastcounter.incr(comment_like_counter(channel_id, video_id, comment_id))