<commit_before>import datetime
from projectconway.models import Base, DBSession
from sqlalchemy import Column, DateTime, Index, Integer, Sequence, String, and_, extract


class Run(Base):
    '''
    This class contains the logic necessary for the database to hold
    an instance of the Run table, in which a single run of the
    Game Of Life will be held.
    '''
    __tablename__ = "runs"

    id = Column(Integer, Sequence('run_id_seq'), primary_key=True)
    input_pattern = Column(String)
    time_slot = Column(DateTime)
    user_name = Column(String(50))

    def __init__(self, input_pattern, time_slot, user_name):
        '''
        Initialises an object to be input into
        the table.
        '''
        self.input_pattern = input_pattern
        self.time_slot = time_slot
        self.user_name = user_name

    def __repr__(self):
        '''
        Returns: a representation of the table object.
        '''
        return ("Run<Pattern=%s, Time Slot=%s, User Name=%s>" % (self.input_pattern, self.time_slot, self.user_name))

    @classmethod
    def get_time_slots_for_hour(cls, time_slot):
        """
        Returns the times slots for the same year, month, day, hour as a
        given datetime object
        """
        min_hour = time_slot.replace(minute=0, second=0, microsecond=0)
        max_hour = time_slot.replace(minute=0, second=0, microsecond=0) + datetime.timedelta(hours=1)
        now = datetime.datetime.now()

        runs_times =  DBSession.query(Run.time_slot).filter(and_(
            Run.time_slot < max_hour,
            Run.time_slot >= min_hour,
        )).all()

        slots = []
        for slot in range(0, 60, 5):
            t_slot = time_slot.replace(minute=slot, second=0, microsecond=0)
            if t_slot > now and t_slot not in runs_times:<commit_msg>Fixed issue in get_time_slots_for_hour<commit_after>import datetime
from projectconway.models import Base, DBSession
from sqlalchemy import Column, DateTime, Index, Integer, Sequence, String, and_, extract


class Run(Base):
    '''
    This class contains the logic necessary for the database to hold
    an instance of the Run table, in which a single run of the
    Game Of Life will be held.
    '''
    __tablename__ = "runs"

    id = Column(Integer, Sequence('run_id_seq'), primary_key=True)
    input_pattern = Column(String)
    time_slot = Column(DateTime)
    user_name = Column(String(50))

    def __init__(self, input_pattern, time_slot, user_name):
        '''
        Initialises an object to be input into
        the table.
        '''
        self.input_pattern = input_pattern
        self.time_slot = time_slot
        self.user_name = user_name

    def __repr__(self):
        '''
        Returns: a representation of the table object.
        '''
        return ("Run<Pattern=%s, Time Slot=%s, User Name=%s>" % (self.input_pattern, self.time_slot, self.user_name))

    @classmethod
    def get_time_slots_for_hour(cls, time_slot):
        """
        Returns the times slots for the same year, month, day, hour as a
        given datetime object
        """
        min_hour = time_slot.replace(minute=0, second=0, microsecond=0)
        max_hour = time_slot.replace(minute=0, second=0, microsecond=0) + datetime.timedelta(hours=1)
        now = datetime.datetime.now()

        runs_times = DBSession.query(Run.time_slot).filter(and_(
            Run.time_slot < max_hour,
            Run.time_slot >= min_hour,
        )).all()
        runs_times = [time[0] for time in runs_times]

        slots = []
        for slot in range(0, 60, 5):
            t_slot = time_slot.replace(minute=slot, second=0, microsecond=0)
            if t_slot > now and t_slot not in runs_times:
{'fraction_non_alphanumeric': 0.09806555615260612, 'fraction_numerical': 0.008328855454056958, 'mean_word_length': 2.693452380952381, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '2480793', 'n_tokens_mistral': 1138, 'n_tokens_neox': 1114, 'n_words': 322}