Skip to content

Commit

Permalink
Merge pull request #7 from AplinkosMinisterija/refactor
Browse files Browse the repository at this point in the history
Refactor
  • Loading branch information
LWangllix authored Sep 21, 2023
2 parents f97055b + 866ca27 commit fbb8d7a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions services/hydroPowerPlants.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,24 +262,24 @@ export default class hydroPowerPlantsService extends moleculer.Service {
SELECT COUNT(*)
FROM events e
WHERE e.hydro_power_plant_id = hpp.id
AND e.time BETWEEN DATE_TRUNC('day', CURRENT_DATE) AND (DATE_TRUNC('day', CURRENT_DATE) + INTERVAL '2 day' - INTERVAL '1 second')
AND ((e.upper_basin >= hpp.upper_basin_max OR e.upper_basin <= hpp.lower_basin_min)
AND e.time BETWEEN DATE_TRUNC('day', CURRENT_DATE) AND (DATE_TRUNC('day', CURRENT_DATE) + INTERVAL '1 day' - INTERVAL '1 second')
AND ((e.upper_basin > hpp.upper_basin_max OR e.upper_basin < hpp.lower_basin_min)
OR e.lower_basin < hpp.lower_basin_min)
) AS today,
(
SELECT COUNT(*)
FROM events e
WHERE e.hydro_power_plant_id = hpp.id
AND e.time BETWEEN DATE_TRUNC('day', CURRENT_DATE) - INTERVAL '1 week' AND (DATE_TRUNC('day', CURRENT_DATE) + INTERVAL '2 day' - INTERVAL '1 second')
AND ((e.upper_basin >= hpp.upper_basin_max OR e.upper_basin <= hpp.lower_basin_min)
AND e.time BETWEEN DATE_TRUNC('day', CURRENT_DATE) - INTERVAL '1 week' AND (DATE_TRUNC('day', CURRENT_DATE) + INTERVAL '1 day' - INTERVAL '1 second')
AND ((e.upper_basin > hpp.upper_basin_max OR e.upper_basin < hpp.lower_basin_min)
OR e.lower_basin < hpp.lower_basin_min)
) AS week,
(
SELECT COUNT(*)
FROM events e
WHERE e.hydro_power_plant_id = hpp.id
AND e.time BETWEEN DATE_TRUNC('day', CURRENT_DATE) - INTERVAL '1 month' AND (DATE_TRUNC('day', CURRENT_DATE) + INTERVAL '2 day' - INTERVAL '1 second')
AND ((e.upper_basin >= hpp.upper_basin_max OR e.upper_basin <= hpp.lower_basin_min)
AND e.time BETWEEN DATE_TRUNC('day', CURRENT_DATE) - INTERVAL '1 month' AND (DATE_TRUNC('day', CURRENT_DATE) + INTERVAL '1 day' - INTERVAL '1 second')
AND ((e.upper_basin > hpp.upper_basin_max OR e.upper_basin < hpp.lower_basin_min)
OR e.lower_basin < hpp.lower_basin_min)
) AS month,
(
Expand Down

0 comments on commit fbb8d7a

Please sign in to comment.