Skip to content

Commit 131b4df

Browse files
authored
fix: recreate correct view in new migration #1680
* fix: keyresult type check failing because of wrong case #1680 * fix: recreate correct view in new migration #1680
1 parent cb07879 commit 131b4df

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
DROP VIEW IF EXISTS EVALUATION_VIEW;
2+
3+
CREATE VIEW EVALUATION_VIEW AS
4+
SELECT
5+
row_number() OVER () AS row_id,
6+
o.id AS objective_id,
7+
o.team_id,
8+
o.quarter_id,
9+
o.state AS objective_state,
10+
kr.id AS key_result_id,
11+
kr.key_result_type,
12+
kr.baseline,
13+
kr.commit_value,
14+
kr.target_value,
15+
kr.stretch_goal,
16+
ci.value_metric,
17+
CASE
18+
WHEN UPPER(kr.key_result_type) = 'ORDINAL' THEN NULLIF(ci.zone, '')
19+
ELSE NULL
20+
END AS zone,
21+
ci.modified_on AS latest_check_in_date
22+
FROM objective o
23+
LEFT JOIN key_result kr
24+
ON kr.objective_id = o.id
25+
LEFT JOIN LATERAL (
26+
SELECT ci2.*
27+
FROM check_in ci2
28+
WHERE ci2.key_result_id = kr.id
29+
ORDER BY ci2.modified_on DESC
30+
LIMIT 1
31+
) ci ON TRUE
32+
WHERE o.state <> 'DRAFT';

0 commit comments

Comments
 (0)