# Path: suma/core/services/interfaces/stat.py
# class IStatService(Interface):
#     def add_click(self, link_id, ip=None, referer=None):
#         pass
# 
#     def get_counter_by_link_id(self, link_id):
#         pass
# 
# Path: suma/core/models/stat.py
# class Stat(Base, CreatedColumn):
#     link_id = Column(ForeignKey(Link.id), nullable=False)
#     link = relationship(Link, backref=backref('stats'))
#     referer = Column(Unicode)
#     ip = Column(INET)
# 
# class ClickCounter(Base):
#     id = Column(ForeignKey(Link.id), primary_key=True, nullable=False)
#     link = relationship(Link, backref=backref('_clicks', uselist=False, lazy='joined'))
#     counter = Column(BigInteger, default=1)


from types import IntType, LongType
from suma.core.services.interfaces import IStatService
from zope.interface import implementer
from suma.core.models import Stat, ClickCounter
from structlog import get_logger
from sqlalchemy.exc import IntegrityError
log = get_logger()


@implementer(IStatService)
class StatService(object):


# Path: suma/core/services/interfaces/stat.py
# class IStatService(Interface):
#     def add_click(self, link_id, ip=None, referer=None):
#         pass
# 
#     def get_counter_by_link_id(self, link_id):
#         pass
# 
# Path: suma/core/models/stat.py
# class Stat(Base, CreatedColumn):
#     link_id = Column(ForeignKey(Link.id), nullable=False)
#     link = relationship(Link, backref=backref('stats'))
#     referer = Column(Unicode)
#     ip = Column(INET)
# 
# class ClickCounter(Base):
#     id = Column(ForeignKey(Link.id), primary_key=True, nullable=False)
#     link = relationship(Link, backref=backref('_clicks', uselist=False, lazy='joined'))
#     counter = Column(BigInteger, default=1)


# Path: suma/core/services/stat.py
from types import IntType, LongType
from suma.core.services.interfaces import IStatService
from zope.interface import implementer
from suma.core.models import Stat, ClickCounter
from structlog import get_logger
from sqlalchemy.exc import IntegrityError

log = get_logger()


@implementer(IStatService)
class StatService(object):


    def __init__(self, dbsession):