import Models
from Models.AnalyticsModel import todays_analytics
from app import db


class LikeModel(Models.Base):
    __tablename__ = 'likes'

    user_id = db.Column(db.ForeignKey('user.id'), primary_key=True)
    user = db.relationship(
        "UserModel",
        foreign_keys=user_id
    )
    likes_id = db.Column(db.ForeignKey('user.id'), primary_key=True)
    likes = db.relationship(
        "UserModel",
        foreign_keys=likes_id
    )

    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        todays_analytics().likes_count += 1
