Skip to content

Commit 904767c

Browse files
committed
fix(monitors): misc style and quick start updates
1 parent ec9c26d commit 904767c

11 files changed

Lines changed: 71 additions & 19 deletions

File tree

testgen/commands/run_quick_start.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import logging
2+
import math
23
import random
34
from datetime import datetime
45
from typing import Any
@@ -116,6 +117,19 @@ def _get_quick_start_params_mapping(iteration: int = 0) -> dict:
116117
}
117118

118119

120+
def _metric_cumulative_shift(iteration: int) -> tuple[float, float]:
121+
"""Compute cumulative metric shifts at a given iteration for Metric_Trend monitors.
122+
123+
Returns (discount_shift, price_shift) — the total shift from baseline
124+
that should be applied to the underlying data at this iteration.
125+
Uses composite sine waves for organic-looking oscillation patterns.
126+
"""
127+
i = iteration
128+
discount = -1.0 + 1.8 * math.sin(2 * math.pi * i / 14 + math.pi) + 0.7 * math.sin(2 * math.pi * i / 6 + math.pi + 0.5)
129+
price = 80 * math.sin(2 * math.pi * i / 16) + 40 * math.sin(2 * math.pi * i / 7 + 0.3) + 100
130+
return discount, price
131+
132+
119133
def _get_monitor_params_mapping(run_date: datetime, iteration: int = 0) -> dict:
120134
# Volume: linear growth with jitter, spike at specific iteration for anomaly
121135
if iteration == 37:
@@ -126,6 +140,12 @@ def _get_monitor_params_mapping(run_date: datetime, iteration: int = 0) -> dict:
126140
# Freshness: update every other iteration, late update for anomaly
127141
is_update_suppliers_iter = (iteration % 2 == 0 and iteration != 38) or iteration == 39
128142

143+
# Metrics: compute deltas for discount and price shifts
144+
curr_discount, curr_price = _metric_cumulative_shift(iteration)
145+
prev_discount, prev_price = _metric_cumulative_shift(iteration - 1) if iteration > 1 else (0.0, 0.0)
146+
discount_delta = round(curr_discount - prev_discount, 3)
147+
price_delta = round(curr_price - prev_price, 2)
148+
129149
return {
130150
**_get_settings_params_mapping(),
131151
"ITERATION_NUMBER": iteration,
@@ -137,6 +157,8 @@ def _get_monitor_params_mapping(run_date: datetime, iteration: int = 0) -> dict:
137157
"IS_CREATE_RETURNS_TABLE_ITER": iteration == 32,
138158
"IS_DELETE_CUSTOMER_ITER": iteration in (18, 22, 34),
139159
"IS_UPDATE_SUPPLIERS_ITER": is_update_suppliers_iter,
160+
"DISCOUNT_DELTA": discount_delta,
161+
"PRICE_DELTA": price_delta,
140162
}
141163

142164

testgen/template/quick_start/initial_data_seeding.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,14 @@ VALUES
8282
'0ea85e17-acbe-47fe-8394-9970725ad37d'::UUID,
8383
'823a1fef-9b6d-48d5-9d0f-2db9812cc318'::UUID,
8484
'Metric_Trend', '{PROJECT_SCHEMA}', 'f_ebike_sales', 'Average Discount',
85-
'AVG(discount_amount)', NULL, NULL, 0, 500, 'Y'),
85+
'AVG(discount_amount)', NULL, NULL, 15, 25, 'Y'),
8686

8787
-- Average Product Price
8888
('a1b2c3d4-3333-4000-8000-000000000003'::UUID,
8989
'0ea85e17-acbe-47fe-8394-9970725ad37d'::UUID,
9090
'823a1fef-9b6d-48d5-9d0f-2db9812cc318'::UUID,
9191
'Metric_Trend', '{PROJECT_SCHEMA}', 'd_ebike_products', 'Average Product Price',
92-
'AVG(price)', NULL, NULL, 0, 10000, 'Y'),
92+
'AVG(price)', NULL, NULL, 1000, 1500, 'Y'),
9393

9494
-- Max Discount
9595
('a1b2c3d4-2006-4000-8000-000000000006'::UUID,

testgen/template/quick_start/run_monitor_iteration.sql

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@ WHERE product_id IN (
7070
-- TG-ENDIF
7171

7272

73+
-- Metric_Trend variation: shift discount averages and product prices each iteration
74+
UPDATE demo.f_ebike_sales
75+
SET discount_amount = GREATEST(0, discount_amount + {DISCOUNT_DELTA});
76+
77+
UPDATE demo.d_ebike_products
78+
SET price = GREATEST(50, price + {PRICE_DELTA});
79+
80+
7381
-- TG-IF IS_DELETE_CUSTOMER_COL_ITER
7482
ALTER TABLE demo.d_ebike_customers
7583
DROP COLUMN occupation,

testgen/ui/components/frontend/js/components/select.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,12 @@ const Select = (/** @type {Properties} */ props) => {
8585
optionsFilter.val = event.target.value;
8686
};
8787

88-
const showPortal = (/** @type Event */ event) => {
89-
event.stopPropagation();
90-
event.stopImmediatePropagation();
91-
opened.val = getValue(props.disabled) ? false : true;
92-
};
88+
// Reset filtering when closed
89+
van.derive(() => {
90+
if (!opened.val) {
91+
optionsFilter.val = '';
92+
}
93+
});
9394

9495
van.derive(() => {
9596
const currentOptions = getValue(options);
@@ -116,7 +117,12 @@ const Select = (/** @type {Properties} */ props) => {
116117
class: () => `flex-column fx-gap-1 text-caption tg-select--label ${getValue(props.disabled) ? 'disabled' : ''}`,
117118
style: () => `width: ${props.width ? getValue(props.width) + 'px' : 'auto'}; ${getValue(props.style)}`,
118119
'data-testid': getValue(props.testId) ?? '',
119-
onclick: showPortal,
120+
onclick: (/** @type Event */ event) => {
121+
event.stopPropagation();
122+
event.stopImmediatePropagation();
123+
// Should toggle open/close unless disabled
124+
opened.val = getValue(props.disabled) ? false : !opened.val;
125+
},
120126
},
121127
span(
122128
{ class: 'flex-row fx-gap-1', 'data-testid': 'select-label' },
@@ -145,6 +151,9 @@ const Select = (/** @type {Properties} */ props) => {
145151
'data-testid': 'select-input',
146152
},
147153
() => {
154+
// Hack to display value again when closed
155+
// For some reason, it goes away when opened
156+
opened.val;
148157
return div(
149158
{ class: 'tg-select--field--content', 'data-testid': 'select-input-display' },
150159
valueIcon.val

testgen/ui/components/frontend/js/components/tree.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,8 @@ stylesheet.replace(`
508508
}
509509
510510
.tg-tree--row.selected {
511-
background-color: #06a04a17;
511+
background-color: var(--sidebar-item-hover-color);
512+
color: var(--primary-color);
512513
font-weight: 500;
513514
}
514515

testgen/ui/components/frontend/js/pages/notification_settings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ const NotificationSettings = (/** @type Properties */ props) => {
233233
{
234234
title: newNotificationItemForm.isEdit.val
235235
? span({ class: 'notifications--editing' }, 'Edit Notification')
236-
: 'Add Notification',
236+
: span({ class: 'text-green' }, 'Add Notification'),
237237
testId: 'notification-item-editor',
238238
expanded: newNotificationItemForm.isEdit.val,
239239
},

testgen/ui/components/frontend/js/pages/schedule_list.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ const ScheduleList = (/** @type Properties */ props) => {
7474
return div(
7575
{ id: domId, class: 'flex-column fx-gap-2', style: 'height: 100%; overflow-y: auto;' },
7676
ExpansionPanel(
77-
{title: 'Add Schedule', testId: 'scheduler-cron-editor'},
77+
{title: span({ class: 'text-green' }, 'Add Schedule'), testId: 'scheduler-cron-editor'},
7878
div(
7979
{ class: 'flex-row fx-gap-2' },
8080
() => Select({

testgen/ui/components/frontend/js/pages/table_monitoring_trends.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ const ChartLegend = (legendGroups) => {
687687
Object.entries(legendGroups).map(([groupName, { items }]) =>
688688
div(
689689
{ class: 'chart-legend-group' },
690-
span({ class: 'chart-legend-group-label' }, groupName),
690+
span({ class: `chart-legend-group-label ${groupName ? '' : 'hidden'}` }, groupName),
691691
...items.map(item =>
692692
div(
693693
{ class: 'chart-legend-item' },
@@ -725,6 +725,7 @@ stylesheet.replace(`
725725
display: flex;
726726
flex-wrap: wrap;
727727
gap: 36px;
728+
row-gap: 8px;
728729
padding: 12px 16px;
729730
border-top: 1px solid var(--border-color);
730731
background: var(--dk-dialog-background);

testgen/ui/queries/profiling_queries.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ def get_tables_by_condition(
195195
WHERE test_active = 'Y'
196196
AND column_id IS NULL
197197
GROUP BY test_defs.table_groups_id,
198+
test_defs.schema_name,
198199
test_defs.table_name
199200
)
200201
""" if include_active_tests else ""}

testgen/ui/static/js/components/select.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,12 @@ const Select = (/** @type {Properties} */ props) => {
8585
optionsFilter.val = event.target.value;
8686
};
8787

88-
const showPortal = (/** @type Event */ event) => {
89-
event.stopPropagation();
90-
event.stopImmediatePropagation();
91-
opened.val = getValue(props.disabled) ? false : true;
92-
};
88+
// Reset filtering when closed
89+
van.derive(() => {
90+
if (!opened.val) {
91+
optionsFilter.val = '';
92+
}
93+
});
9394

9495
van.derive(() => {
9596
const currentOptions = getValue(options);
@@ -116,7 +117,12 @@ const Select = (/** @type {Properties} */ props) => {
116117
class: () => `flex-column fx-gap-1 text-caption tg-select--label ${getValue(props.disabled) ? 'disabled' : ''}`,
117118
style: () => `width: ${props.width ? getValue(props.width) + 'px' : 'auto'}; ${getValue(props.style)}`,
118119
'data-testid': getValue(props.testId) ?? '',
119-
onclick: showPortal,
120+
onclick: (/** @type Event */ event) => {
121+
event.stopPropagation();
122+
event.stopImmediatePropagation();
123+
// Should toggle open/close unless disabled
124+
opened.val = getValue(props.disabled) ? false : !opened.val;
125+
},
120126
},
121127
span(
122128
{ class: 'flex-row fx-gap-1', 'data-testid': 'select-label' },
@@ -145,6 +151,9 @@ const Select = (/** @type {Properties} */ props) => {
145151
'data-testid': 'select-input',
146152
},
147153
() => {
154+
// Hack to display value again when closed
155+
// For some reason, it goes away when opened
156+
opened.val;
148157
return div(
149158
{ class: 'tg-select--field--content', 'data-testid': 'select-input-display' },
150159
valueIcon.val

0 commit comments

Comments
 (0)