Skip to content

Commit 5b39c39

Browse files
authored
Merge pull request #139 from andrewm4894/sql-optimize-timestamp
Optimize SQL a little more
2 parents a460dab + e45bb70 commit 5b39c39

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

metrics/defaults/defaults.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ model_configs:
2020
contamination: 0.01
2121
model_combination_method: 'mean' # method to combine model scores, 'mean', 'min' or 'max'.
2222
train_max_n: 2500 # max number of observations for training a model.
23+
train_metric_timestamp_max_days_ago: 30
2324
train_min_n: 14 # min number of observations for training a model.
2425
score_max_n: 25 # max n to pull for scoring to avoid pulling more than needed.
26+
score_metric_timestamp_max_days_ago: 7
2527
preprocess_params:
2628
diff_n: 1 # 1 will use diff, 0 will use raw metric values.
2729
smooth_n: 3 # how much smoothing to apply in preprocessing.

metrics/defaults/sql/score.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ where
1818
metric_batch = '{{ metric_batch }}'
1919
and
2020
metric_type in ('metric', 'score')
21+
and
22+
metric_timestamp >= date('now', '-{{ score_metric_timestamp_max_days_ago }} day')
2123
{% if score_exclude_metrics is defined %}
2224
and
2325
-- Exclude the specified metrics

metrics/defaults/sql/train.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ where
1616
metric_batch = '{{ metric_batch }}'
1717
and
1818
metric_type = 'metric'
19+
and
20+
metric_timestamp >= date('now', '-{{ train_metric_timestamp_max_days_ago }} day')
1921
{% if train_exclude_metrics is defined %}
2022
and
2123
-- Exclude the specified metrics

0 commit comments

Comments
 (0)