Skip to content

Commit

Permalink
Improved utility functions
Browse files Browse the repository at this point in the history
  • Loading branch information
TaaviE committed Nov 28, 2020
1 parent 472738d commit 8cd1ebc
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,21 @@
Contains functions that abstracts a few queries
This file requires database being initialized
"""
from datetime import datetime
# Cython
from functools import lru_cache
from logging import getLogger

import pyximport

from utility_standalone import get_user_id

pyximport.install()
import sentry_sdk
from sqlalchemy import and_

from config import Config
from main import db
from models.family_model import Family, FamilyGroup
from models.names_model import Name
from models.shuffles_model import Shuffle
from models.users_model import User
from datetime import datetime
from sqlalchemy import and_

import sentry_sdk
from logging import getLogger
from utility_standalone import get_user_id

getLogger().setLevel(Config.LOGLEVEL)
logger = getLogger()
Expand Down Expand Up @@ -95,6 +92,8 @@ def get_person_language_code(user_id: int) -> str:
def commit_object(obj: object) -> bool:
"""
Commits an object to the DB and catches the potential error
:param obj: The object to commit to the DB
"""
try:
db.session.add(obj)
Expand All @@ -103,5 +102,5 @@ def commit_object(obj: object) -> bool:
except Exception as e:
db.session.rollback()
sentry_sdk.capture_exception(e)
logger.error("Failed adding group")
logger.error("Failed adding an object to database")
return False

0 comments on commit 8cd1ebc

Please sign in to comment.