<commit_before>"""
Likes model class
"""

from flickipedia.config import log, schema
from flickipedia.mysqlio import DataIOMySQL


class LikeModel(object):

    def __init__(self):
        super(LikeModel, self).__init__()

        self.io = DataIOMySQL()
        self.io.connect()

    def get_like(self, user_id, article_id, photo_id):
        """
        Retrieve
        """
        schema_obj = getattr(schema, 'Photo')
        res = self.io.session.query(schema_obj).filter(
            schema_obj.user_id == user_id,
            schema_obj.article_id == article_id,
            schema_obj.photo_id == photo_id,
        ).all()
        if len(res) > 0:
            return res[0]
        else:
            return None

    def insert_like(self, user_id, article_id, photo_id):
        return self.io.insert('Photo', user_id=user_id,
                              article_id=article_id, photo_id=photo_id)<commit_msg>add - interface to remove like rows<commit_after>"""
Likes model class
"""

from flickipedia.config import log, schema
from flickipedia.mysqlio import DataIOMySQL


class LikeModel(object):

    def __init__(self):
        super(LikeModel, self).__init__()

        self.io = DataIOMySQL()
        self.io.connect()

    def get_like(self, user_id, article_id, photo_id):
        """ Retrieve whether an object has been liked """
        schema_obj = getattr(schema, 'Photo')
        res = self.io.session.query(schema_obj).filter(
            schema_obj.user_id == user_id,
            schema_obj.article_id == article_id,
            schema_obj.photo_id == photo_id,
        ).all()
        if len(res) > 0:
            return res[0]
        else:
            return None

    def insert_like(self, user_id, article_id, photo_id):
        return self.io.insert('Like', user_id=user_id,
                              article_id=article_id, photo_id=photo_id)

    def delete_like(self, like_obj):
        return self.io.delete(like_obj)
{'fraction_non_alphanumeric': 0.10572012257405516, 'fraction_numerical': 0.0020429009193054137, 'mean_word_length': 2.297979797979798, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '486437', 'n_tokens_mistral': 614, 'n_tokens_neox': 603, 'n_words': 131}