<commit_before>import pymysql
import time

class Entity:

    qodbc_table = None
    mysql_table = None
    field_map = ()
    update_fields = ()
    custom_mysql_fields = ()
    last_entry_datetime = None
    company_file = 0

    def __init__(self, qodbc, mysql, company_file=0, last_modified=None):
        self.qodbc = qodbc
        self.mysql = mysql
        self.company_file = company_file or self.company_file
        self.last_entry_datetime = last_modified or self.last_entry_datetime or self.get_last_modified() or '2001-01-01 00:00:00'

    def append_custom_data(self, toRaw):
        return toRaw

    def sync(self):
        data = self.get_latest_data_from_quickbooks()
        data = self.append_custom_data(data)
        self.write_batch(data)

    def write_batch(self, data):
        for record in data:
            self.write_record(record)

    def write_record(self, record):
        try:
            insert = self.build_mysql_insert(record)
            print(record)
            print(insert)
            self.mysql.insert(insert)
        except pymysql.Error as error:
            print("exception handled")
            self.log_query_error(str(error), str(record), insert)

    def get_last_modified(self):
        query = "SELECT MAX(time_modified) as max_date FROM " + self.mysql_table + " WHERE company_file=" + self.company_file<commit_msg>dont get stuck on entries that were entered in the future by time lords<commit_after>import pymysql
import time

class Entity:

    qodbc_table = None
    mysql_table = None
    field_map = ()
    update_fields = ()
    custom_mysql_fields = ()
    last_entry_datetime = None
    company_file = 0

    def __init__(self, qodbc, mysql, company_file=0, last_modified=None):
        self.qodbc = qodbc
        self.mysql = mysql
        self.company_file = company_file or self.company_file
        self.last_entry_datetime = last_modified or self.last_entry_datetime or self.get_last_modified() or '2001-01-01 00:00:00'

    def append_custom_data(self, toRaw):
        return toRaw

    def sync(self):
        data = self.get_latest_data_from_quickbooks()
        data = self.append_custom_data(data)
        self.write_batch(data)

    def write_batch(self, data):
        for record in data:
            self.write_record(record)

    def write_record(self, record):
        try:
            insert = self.build_mysql_insert(record)
            print(record)
            print(insert)
            self.mysql.insert(insert)
        except pymysql.Error as error:
            print("exception handled")
            self.log_query_error(str(error), str(record), insert)

    def get_last_modified(self):
        query = "SELECT MAX(time_modified) as max_date FROM " + self.mysql_table + " WHERE company_file=" + self.company_file + " AND time_created <= NOW() + INTERVAL 4 HOUR"
{'fraction_non_alphanumeric': 0.08640674394099052, 'fraction_numerical': 0.011591148577449948, 'mean_word_length': 2.7083333333333335, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, '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': '5076102', 'n_tokens_mistral': 895, 'n_tokens_neox': 856, 'n_words': 198}