def testPage(id):
    print(id)
    courtTable = StakesKleros.getCourtInfoTable()
    return render_template('graphs.html',
                           last_update=Config.get('updated'),
                           treemapJurorsGraph=treeMapGraph(courtTable),
                           treemapStakedGraph=treeGraph())
def graphsMaker():
    Visitor().addVisit('graphs')
    courtTable = StakesKleros.getCourtInfoTable()
    sjGraph = stakesJurorsGraph()
    return render_template('graphs.html',
                           last_update=Config.get('updated'),
                           stakedPNKgraph=sjGraph,
                           disputesgraph=disputesGraph(),
                           disputeCourtgraph=disputesbyCourtGraph(),
                           disputeCreatorgraph=disputesbyCreatorGraph(),
                           treemapJurorsGraph=treeMapGraph(courtTable),
                           treemapStakedGraph=treeMapGraph(
                               courtTable, 'Total Staked'))
def odds():
    Visitor().addVisit('odds')
    pnkStaked = 100000
    if request.method == 'POST':
        # Form being submitted; grab data from form.
        try:
            pnkStaked = int(request.form['pnkStaked'])
        except Exception:
            pnkStaked = 100000

    return render_template(
        'odds.html',
        last_update=Config.get('updated'),
        pnkStaked=pnkStaked,
        courtChances=StakesKleros.getAllCourtChances(pnkStaked))
def index():
    Visitor().addVisit('dashboard')
    tokenSupply = float(Config().get('token_supply'))
    drawnJurors = len(Juror.list())
    retention = Juror.retention() / drawnJurors
    adoption = len(Juror.adoption())
    ruledCases = Dispute().ruledCases
    openCases = Dispute().openCases
    mostActiveCourt = Dispute.mostActiveCourt()
    if mostActiveCourt:
        mostActiveCourt = Court(
            id=int(list(mostActiveCourt.keys())[0])).map_name
    else:
        mostActiveCourt = "No new cases in the last 7 days"
    pnkPrice = float(Config.get('PNKprice'))
    courtTable = StakesKleros.getCourtInfoTable()
    pnkStaked = courtTable['General']['Total Staked']
    activeJurors = courtTable['General']['Jurors']

    return render_template(
        'main.html',
        last_update=Config.get('updated'),
        disputes=Dispute.query.order_by(Dispute.id.desc()).first().id,
        activeJurors=activeJurors,
        jurorsdrawn=drawnJurors,
        retention=retention,
        adoption=adoption,
        most_active_court=mostActiveCourt,
        cases_closed=ruledCases,
        cases_rulling=openCases,
        tokenSupply=tokenSupply,
        pnkStaked=pnkStaked,
        pnkStakedPercent=pnkStaked / tokenSupply,
        ethPrice=float(Config.get('ETHprice')),
        pnkPrice=pnkPrice,
        pnkPctChange=float(Config.get('PNKpctchange24h')) / 100,
        pnkVol24=float(Config.get('PNKvolume24h')),
        pnkCircSupply=float(Config.get('PNKcirculating_supply')),
        courtTable=courtTable)