38 lines
1.3 KiB
Python
38 lines
1.3 KiB
Python
from pkg.dash.func.info_func import *
|
|
from pkg.dash.app_init import app
|
|
from dash.dependencies import Input, Output
|
|
from dash import html
|
|
|
|
@app.callback(
|
|
[Output('manual-info-tooltip', 'children')],
|
|
[Input('update-button', 'n_clicks'),
|
|
Input('prob-start-input', 'value'),
|
|
Input('prob-end-input', 'value')]
|
|
)
|
|
def update_info_manual(n_clicks, prob_start, prob_end):
|
|
if n_clicks == 0:
|
|
return [html.Div("Click 'Manual Update' to see results.")]
|
|
|
|
tweet_count, days_to_next_friday = get_pace_params()
|
|
prob_start = int(prob_start) if prob_start is not None else 525
|
|
prob_end = int(prob_end) if prob_end is not None else 549
|
|
|
|
probability = calculate_tweet_probability(tweet_count, days_to_next_friday, prob_start, prob_end)
|
|
|
|
prob_low, prob_high = map(float, probability.split(" - "))
|
|
formatted_probability = f"{prob_low * 100:.2f}% - {prob_high * 100:.2f}%"
|
|
|
|
pace_table_rows = [
|
|
html.Tr([
|
|
html.Th(f"Probability ({prob_start}-{prob_end})", colSpan=2, style={'paddingRight': '10px'}),
|
|
html.Td(formatted_probability, colSpan=6, style={'paddingRight': '10px'})
|
|
])
|
|
]
|
|
pace_table = html.Table(pace_table_rows, style={
|
|
'width': '100%',
|
|
'textAlign': 'left',
|
|
'borderCollapse': 'collapse'
|
|
})
|
|
return [pace_table]
|
|
|