<commit_before>#!flask/bin/python
import json, sqlite3

def get_latest_temperatures():
    query = """SELECT * FROM TEMPERATURE ORDER BY TIMESTAMP DESC LIMIT 100;""";
    conn = sqlite3.connect('temperature.db')
    cur = conn.cursor()
    cur.execute(query)

    ts_list = []
    temp_list = []

    for row in cur:
        id, temp, timestamp = row
        temp_list += [temp, ]
        ts_list += [timestamp, ]

    cur.close()
    conn.close()

    response = {'ts_list' : ts_list, 'temp_list' : temp_list}

    return response


def get_oven_temperature():
    """Get oven temperature (celsius) through hardware magic

    @return: float
    """
    past_temp = get_latest_temperatures()
    latest_temp = past_temp['temp_list'][0]
    return latest_temp

def get_oven_state():
    """Get state of oven

    @return: One of ["on", "off", "error"]
    """
    return "error"


def main():
    print get_oven_temperature()
    print get_latest_temperatures()<commit_msg>timestamps now in epoch millis<commit_after>#!flask/bin/python
import json, sqlite3, time, datetime

def get_latest_temperatures():
    query = """SELECT ID, TEMPERATURE, TIMESTAMP FROM TEMPERATURE ORDER BY TIMESTAMP DESC LIMIT 100;""";
    conn = sqlite3.connect('temperature.db')
    cur = conn.cursor()
    cur.execute(query)

    ts_list = []
    temp_list = []

    for row in cur:
        id, temp, timestamp = row
        # print type(timestamp)
        # timestamp = time.mktime(timestamp.timetuple())
        epochmills = time.mktime(datetime.datetime.strptime(timestamp, "%Y-%m-%d %H:%M:%S").timetuple())
        print epochmills
        temp_list += [temp, ]
        ts_list += [epochmills, ]

    cur.close()
    conn.close()

    response = {'ts_list' : ts_list, 'temp_list' : temp_list}

    return response


def get_oven_temperature():
    """Get oven temperature (celsius) through hardware magic

    @return: float
    """
    past_temp = get_latest_temperatures()
    latest_temp = past_temp['temp_list'][0]
    return latest_temp

def get_oven_state():
    """Get state of oven

    @return: One of ["on", "off", "error"]
    """
    return "error"


def main():
    print get_oven_temperature()
    print get_latest_temperatures()
{'fraction_non_alphanumeric': 0.12859712230215828, 'fraction_numerical': 0.00539568345323741, 'mean_word_length': 3.143389199255121, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3783869', 'n_tokens_mistral': 747, 'n_tokens_neox': 711, 'n_words': 180}