<commit_before># -*- coding: utf-8 -*-


from flask import Flask, render_template, request, redirect, url_for
from shot import redis_server
from datetime import date
import time


app = Flask(__name__)
app.debug = True


FORMAT_CALENDAR = '%d.%m.%Y'


FORMAT_DATETIME = '%Y-%m-%d %H:%M:%S.%f'


def convert_to_date(date_to_convert, format):
    tm = time.strptime(date_to_convert, format)
    return date(*tm[:3])


def check_date(date_to_check, date_from, date_to):
    date_from = convert_to_date(date_from, FORMAT_CALENDAR)
    date_to = convert_to_date(date_to, FORMAT_CALENDAR)
    if date_from > date_to:
        return False
    return date_to >= convert_to_date(date_to_check, FORMAT_DATETIME) >= date_from


@app.route('/', methods=['GET'])
def index():
    keys = redis_server.keys()
    redis_server.hdel('hothsot', keys)

    hotshots = []
    for key in keys:
        hotshots.append(redis_server.hgetall(key))
    return render_template('index.html', hotshots=hotshots)


@app.route('/hotshots', methods=['POST'])
def hotshots():

    if request.method == 'POST':

        date_from = request.form.get('date_from')
        date_to = request.form.get('date_to')

        if date_from and date_to:
            keys = redis_server.keys()

            keys = [ key for key in keys if check_date(key, date_from, date_to) ]

            hotshots = []

            for key in keys:
                hotshots.append(redis_server.hgetall(key))

            return render_template('index.html', hotshots=hotshots)
    return redirect(url_for('index'))


if __name__ == "__main__":
    app.run(host='127.0.0.1', port=6500)<commit_msg>changes in view and add sort<commit_after># -*- coding: utf-8 -*-


from flask import Flask, render_template, request, redirect, url_for
from shot import redis_server
from datetime import date
import time


app = Flask(__name__)
app.debug = True


FORMAT_CALENDAR = '%d.%m.%Y'


FORMAT_DATETIME = '%Y-%m-%d %H:%M:%S.%f'


def convert_to_date(date_to_convert, format):
    tm = time.strptime(date_to_convert, format)
    return date(*tm[:3])


def check_date(date_to_check, date_from, date_to):
    date_from = convert_to_date(date_from, FORMAT_CALENDAR)
    date_to = convert_to_date(date_to, FORMAT_CALENDAR)
    if date_from > date_to:
        return False
    return date_to >= convert_to_date(date_to_check, FORMAT_DATETIME) >= date_from


def get_hotshots(date_filter=False, date_from=None, date_to=None):
    keys = redis_server.keys()

    if date_filter:
        keys = [ key for key in keys if check_date(key, date_from, date_to) ]

    hotshots = []
    for key in keys:
        hotshots.append(redis_server.hgetall(key))
    hotshots.sort(reverse=True)

    return hotshots


@app.route('/', methods=['GET'])
def index():
    hotshots = get_hotshots()
    return render_template('index.html', hotshots=hotshots)


@app.route('/hotshots', methods=['POST'])
def hotshots():

    if request.method == 'POST':

        date_from = request.form.get('date_from')
        date_to = request.form.get('date_to')

        if date_from and date_to:
            hotshots = get_hotshots(True, date_from, date_to)

            return render_template('index.html', hotshots=hotshots)

    return redirect(url_for('index'))


if __name__ == "__main__":
    app.run(host='127.0.0.1', port=6500)
{'fraction_non_alphanumeric': 0.1272563176895307, 'fraction_numerical': 0.007220216606498195, 'mean_word_length': 3.586206896551724, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '7000808', 'n_tokens_mistral': 1186, 'n_tokens_neox': 1133, 'n_words': 245}