<commit_before>from app import app
from flask import request, render_template, redirect, url_for
from flask.ext.paginate import Pagination
from attrdict import AttrDict
from urllib import quote_plus
import requests, json, re

import string

RESULTS_PER_PAGE = 25

@app.route('/', methods=['GET','POST'])
@app.route('/#search', methods=['GET','POST'])
def search():
    if request.method == 'POST':
        search_value = request.form.getlist('search')[0]
        search_value = quote_plus(search_value)
        print search_value # value of the search query

        if (len(request.form.getlist('page')) > 0):
            result = query(search_value, int(request.form.getlist('page')[0]))
        else:
            result = query(search_value)

        if is_EIN(search_value):
            org = result['organization']

            # redirect
            ein = parse_EIN(search_value)
            return redirect(url_for('ein_results', ein=ein))

        else:
            filings = result['filings']
            num_results = result['total_results']

            print 'Search yielded ' + str(num_results) + ' result(s).'

            results_for_html = []
            for i in range(0, min(RESULTS_PER_PAGE,num_results)-1):
                org = filings[i]['organization']
                result_for_html = {
                    'name': org['name'],
                    'ein': org['ein'],
                    'city': org['city'],
                    'state': org['state'],
                    'tax_prd': filings[i]['tax_prd']
                }
                results_for_html.append(result_for_html)

                # print - delete me when ur done
                print org['name']
                print org['ein']
                print org['city']
                print org['state']
                print filings[i]['tax_prd']
                print ''

            print len(results_for_html) == 0
            if (len(request.form.getlist('page')) > 0):
                page = int(request.form.getlist('page')[0])
            else:
                page = 1
            pagination = Pagination(page=page, total=num_results, search=False,
                                    per_page=RESULTS_PER_PAGE)

            return render_template('index.html', results=results_for_html,<commit_msg>pagination fixed for off-by-one, tested<commit_after>from app import app
from flask import request, render_template, redirect, url_for
from flask.ext.paginate import Pagination
from attrdict import AttrDict
from urllib import quote_plus
import requests, json, re

import string

RESULTS_PER_PAGE = 25

@app.route('/', methods=['GET','POST'])
@app.route('/#search', methods=['GET','POST'])
def search():
    if request.method == 'POST':
        search_value = request.form.getlist('search')[0]
        search_value = quote_plus(search_value)
        print search_value # value of the search query

        if (len(request.form.getlist('page')) > 0):
            result = query(search_value, int(request.form.getlist('page')[0]))
        else:
            result = query(search_value)

        if is_EIN(search_value):
            org = result['organization']

            # redirect
            ein = parse_EIN(search_value)
            return redirect(url_for('ein_results', ein=ein))

        else:
            filings = result['filings']
            num_results = result['total_results']

            print 'Search yielded ' + str(num_results) + ' result(s).'

            results_for_html = []
            for i in range(0, len(filings)):
                org = filings[i]['organization']
                result_for_html = {
                    'name': org['name'],
                    'ein': org['ein'],
                    'city': org['city'],
                    'state': org['state'],
                    'tax_prd': filings[i]['tax_prd']
                }
                results_for_html.append(result_for_html)

                # print - delete me when ur done
                print org['name']
                print org['ein']
                print org['city']
                print org['state']
                print filings[i]['tax_prd']
                print ''

            print len(results_for_html) == 0
            if (len(request.form.getlist('page')) > 0):
                page = int(request.form.getlist('page')[0])
            else:
                page = 1
            pagination = Pagination(page=page, total=num_results, search=False,
                                    per_page=RESULTS_PER_PAGE)

            return render_template('index.html', results=results_for_html,
{'fraction_non_alphanumeric': 0.12001742539751688, 'fraction_numerical': 0.004574166848181224, 'mean_word_length': 1.8735919899874844, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5232729', 'n_tokens_mistral': 1325, 'n_tokens_neox': 1237, 'n_words': 275}