Skip to content

Commit

Permalink
feat(dash-board): init dash app
Browse files Browse the repository at this point in the history
  • Loading branch information
bbortt committed Apr 1, 2024
1 parent f3bff02 commit 8d08221
Show file tree
Hide file tree
Showing 10 changed files with 971 additions and 6 deletions.
13 changes: 12 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: gradle/wrapper-validation-action@v2
dash-board:
name: 'App: dash-board'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install Dependencies
working-directory: apps/dash-board
run: poetry install
k6-report-ingress:
name: 'App: k6-report-ingress'
runs-on: ubuntu-latest
Expand Down Expand Up @@ -97,7 +108,7 @@ jobs:
timeout-minutes: 5
run: |
# Start the application in the background
java -jar "$(find build/artifacts -type f -name '*.jar' -not -name '*-plain.jar')" &
java --enable-preview -jar "$(find build/artifacts -type f -name '*.jar' -not -name '*-plain.jar')" &
APP_PID=$!
# Wait for the application to be ready
Expand Down
3 changes: 2 additions & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/poetry.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions .idea/runConfigurations/dash_board.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file added apps/dash-board/README.md
Empty file.
103 changes: 103 additions & 0 deletions apps/dash-board/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import dash
from dash import dcc, html

#
# load_dotenv()
#
#
# def get_db_connection():
# connection = psycopg2.connect(
# dbname=os.getenv('DB_NAME', 'k6_dashboard'),
# user=os.getenv('DB_USER', 'k6_dashboard'),
# password=os.getenv('DB_PASSWORD', 'KrPPCHdYSXz6wMct5tUK'),
# host=os.getenv('DB_HOST', 'localhost')
# )
# return connection
#
#
# def fetch_data(query, params=None):
# connection = get_db_connection()
# cursor = connection.cursor()
# if params:
# cursor.execute(query, params)
# else:
# cursor.execute(query)
# result = cursor.fetchall()
# cursor.close()
# connection.close()
# return result
#
#
# # Fetch unique test run IDs for dropdown options
# test_run_ids_query = "SELECT DISTINCT tags->>'testid' AS testid FROM samples WHERE metric = 'response_time';"
# test_run_ids = fetch_data(test_run_ids_query)
# test_run_id_options = [{'label': id[0], 'value': id[0]} for id in test_run_ids]
#
# app = dash.Dash('K6 Dashboard')
#
# app.layout = html.Div([
# html.H1('Response Time Visualization'),
# dcc.Dropdown(
# id='test-run-dropdown',
# options=test_run_id_options,
# value=test_run_id_options[0]['value'] if test_run_id_options else None
# ),
# dcc.Graph(id='response-time-graph')
# ])
#
# test_run_query = """
# SELECT ts, AVG(value) AS avg_response_time
# FROM samples
# WHERE metric = 'response_time' AND tags->>'testid' = %s
# GROUP BY ts
# ORDER BY ts;
# """
#
#
# # @app.callback(
# # Output('response-time-graph', 'figure'),
# # [Input('test-run-dropdown', 'value')]
# # )
# # def update_graph(selected_test_run_id):
# # print(f"Fetching data for test run ID: {selected_test_run_id}")
# #
# # data = fetch_data(test_run_query, (selected_test_run_id,))
# #
# # # Convert query results to a DataFrame
# # agg_df = pd.DataFrame(data, columns=['ts', 'avg_response_time'])
# #
# # print(f"Data fetched successfully. Rows: {len(agg_df)}")
# #
# # # Create a Plotly graph object for the average response times
# # figure = go.Figure(
# # data=[
# # go.Scatter(x=agg_df['ts'], y=agg_df['avg_response_time'], mode='lines+markers', name='Avg Response Time')],
# # layout=go.Layout(title='Average Response Time by Timestamp', xaxis_title='Timestamp', yaxis_title='Average Response Time')
# # )
# #
# # return figure
#
#
# if __name__ == '__main__':
# app.run_server(debug=True)

app = dash.Dash(__name__)

app.layout = html.Div([
html.H1('Hello Dash'),
dcc.Graph(
id='example-graph',
figure={
'data': [
{'x': [1, 2, 3], 'y': [4, 1, 2], 'type': 'bar', 'name': 'SF'},
{'x': [1, 2, 3], 'y': [2, 4, 5], 'type': 'bar', 'name': u'Montréal'},
],
'layout': {
'title': 'Dash Data Visualization'
}
}
)
])

if __name__ == '__main__':
app.run_server(debug=True)
10 changes: 10 additions & 0 deletions apps/dash-board/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
plugins {
id "base"
}


group = "io.github.bbortt.k6.dashboard"


dependencies {
}

0 comments on commit 8d08221

Please sign in to comment.