Exemplo n.º 1
0
def remove_offered_training(id_slack, suggestion):
    session = SQLManager().get_session()
    response = session.query(OfferedTraining).filter_by(
        id_slack=id_slack, suggestion=suggestion).first()
    if response is not None:
        session.delete(response)
        session.commit()

    response = session.query(RequestedTraining).filter_by(
        id_slack=id_slack, suggestion=suggestion).first()
    if response is not None:
        session.delete(response)
        session.commit()
    session.close()
Exemplo n.º 2
0
def remove_string_from_db(id_slack, suggestion):
    session = SQLManager().get_session()
    suggestion = session.query(OfferedTraining).filter_by(
        id_slack=id_slack, suggestion=suggestion).first()
    if suggestion is not None:
        session.delete(suggestion)
        session.commit()
    session.close()
Exemplo n.º 3
0
def get_user(id_slack):
    session = SQLManager().get_session()
    response = session.query(User).filter_by(id_slack=id_slack).first()
    session.close()
    if response is not None:
        return response.team
    else:
        return None
Exemplo n.º 4
0
def get_unique_requested_trainings_with_quantity():
    session = SQLManager().get_session()
    response = session.query(RequestedTraining).all()
    session.close()
    cnt = Counter()

    for item in response:
        cnt[str(item)] += 1

    return cnt
Exemplo n.º 5
0
def get_offered_trainings():
    session = SQLManager().get_session()
    response = session.query(OfferedTraining).all()
    session.close()
    return response
Exemplo n.º 6
0
def get_unique_requested_trainings():
    session = SQLManager().get_session()
    response = session.query(RequestedTraining).all()
    session.close()
    unique = set([item.suggestion for item in response])
    return unique