def get_recent_meeting(): """ Return the metadata for most recent meeting """ meeting_meta = dbclient.get_most_recent_meeting() if not meeting_meta: return utils.no_data_response("No meetings have been processed yet") return utils.responsify(meeting_meta)
def get_meetings(): """ Return the metadata for each meeting in the system """ # query all meetings_meta = dbclient.get_meeting_meta("*") if not meetings_meta: return utils.no_data_response("No meetings have been processed yet") return utils.responsify(meetings_meta)
def show(event,context): matches = [] for match in MatchInfoModel.scan(): matches.append({ 'match_id': match.match_id, 'home_team': match.home_team, 'away_team': match.away_team, 'start_time': match.start_time, 'bets_processed': match.bets_processed}) return responsify(status_code=200, body={'matches': matches})
def get_single_meeting(meeting_key): """ Return the metadata for a specific meeting in the system """ meeting_meta = dbclient.get_meeting_meta(meeting_key) if not meeting_meta: return utils.no_data_response( "No meetings matching the meeting_key {} have been processed yet", meeting_key) return utils.responsify(meeting_meta[0])
def get_meeting_prompting(meeting_key): """ Return who follows whom in a meetings """ events = dbclient.get_meeting_data(meeting_key) if not events: return utils.no_data_response("No speaking events for key {}", meeting_key) prompting = meeting_analysis.prompting(events) return utils.responsify(prompting)
def get_in_progress(participant_key): """ Return the meeting key of the in progress meeting for the given participant, or null otherwise """ query = {"participants": participant_key, "is_complete": False} meta = dbclient.query("meta", query) payload = None if meta: payload = meta[0]["meeting_key"] return utils.responsify(payload)
def show(event, context): bets = [] for bet in BetModel.scan(): bets.append({ 'bet_id': bet.bet_id, 'user_id': bet.user_id, 'bet_amount': bet.bet_amount, 'bet_for': bet.bet_for, 'bet_paid_status': bet.bet_paid_status, 'match_id': bet.match_id }) return responsify(status_code=200, body={'bets': bets})
def get_chunked_turns(meeting_key): """ Return the breakdown of speaking turns in n-minute chunks """ events = dbclient.get_meeting_data(meeting_key) n = str(request.args.get('n', default=5)) if not n.isdigit() or "." in n: return utils.no_data_response("Chunking value must be an integer!") chunks = meeting_analysis.chunked_speaking_turns(events, int(n)) return utils.responsify(chunks)
def show(event, context): users = [] for user in UserModel.scan(): users.append({'user_id': user.user_id, 'account_value': user.account_value, 'locked_value': user.locked_value}) users = sorted(users, key=lambda x: float(x['account_value']), reverse=True) for i, user in enumerate(users): user['standing'] = i + 1 return responsify(status_code=200, body={'users': users})
def get_meeting_speaking_time(meeting_key): """ Returns the breakdown of speaking time for each user in the given meeting in seconds """ events = dbclient.get_meeting_data(meeting_key) if not events: return utils.no_data_response( "No meetings matching the meeting_key {} have been processed yet", meeting_key) speaking_time = meeting_analysis.speaking_time(events) if not speaking_time: for part in _get_participants(meeting_key): speaking_time[part] = 0 return utils.responsify(speaking_time)
def get_total_minutes_spoken(): start_time_agg = dbclient.db["speaking_events"].aggregate([{ "$group": { "_id": None, "total": { "$sum": "$speaking_start" } } }]) start_time_sum = list(start_time_agg)[0]["total"] end_time_agg = dbclient.db["speaking_events"].aggregate([{ "$group": { "_id": None, "total": { "$sum": "$speaking_end" } } }]) end_time_sum = list(end_time_agg)[0]["total"] seconds_spoken = end_time_sum - start_time_sum return utils.responsify(int(seconds_spoken / 60))
def get_num_meetings(): """ Return the total number of meetings """ return utils.responsify(dbclient.count("meta", "*"))
def health(): return utils.responsify("OK!")
def get_num_participants(): """ Return the total number of unique participants """ return utils.responsify(dbclient.count("participants", "*"))
def get_total_turns_taken(): return utils.responsify(dbclient.count("data", "*"))