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 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_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 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)