def save_and_commit_workout(workout, user, identifier):
    workout.user_id = user.id

    try:
        source = Source(workout=workout)
        source.name = "strava"
        source.remote_identifier = identifier

        session.add(workout)
        session.add(source)

        session.commit()
    except Exception:
        raise SyncWorkerException("strava")
def has_synced_workout(identifier, service):
    query = Source.by_name_and_identifier(service, identifier)
    return query.count() > 0