Skip to content

Commit 983c829

Browse files
committed
replace the view ocpp_tag_activity (steve-community#1219)
1 parent 68a2c66 commit 983c829

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
-- came with https://github.com/steve-community/steve/issues/1219
2+
CREATE OR REPLACE VIEW ocpp_tag_activity AS
3+
select `o`.*,
4+
count(`t`.`id_tag`) AS `active_transaction_count`,
5+
case when count(`t`.`id_tag`) > 0 then 1 else 0 end AS `in_transaction`,
6+
case when `o`.`max_active_transaction_count` = 0 then 1 else 0 end AS `blocked`
7+
from `ocpp_tag` `o` left join `transaction` `t` on (
8+
`o`.`id_tag` = `t`.`id_tag` and
9+
`t`.`stop_timestamp` is null and
10+
`t`.`stop_value` is null)
11+
group by
12+
`o`.`ocpp_tag_pk`,
13+
`o`.`id_tag`,
14+
`o`.`parent_id_tag`,
15+
`o`.`expiry_date`,
16+
`o`.`max_active_transaction_count`,
17+
`o`.`note`;

0 commit comments

Comments
 (0)