727-calculate-average-temperature-and-store-the-result #898
No reviewers
Labels
No labels
_CRITICAL_
API
app
backEnd
Blocked-waiting-for-further-changes
bug
bug-only-on-server-for-mobile-not-webpage
Bug-Report-After-Merge
cleanup
close
design
duplicate
enhancement
feature request
frontEnd
further-changes-needed
future-problem-not-fixint-this-period
help wanted
invalid
last-week-issue-to-fix
library
low-priority
needs input
needs review
not-implemented.
project documentation
question
research
reviewed
Script
security
SQL
style
Team 1
Team 2
team leaders
test-creation
testing
topLevel
unassigned
Under-review
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Andras/BoundlessFlowCampus2K!898
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "727-calculate-average-temperature-and-store-the-result"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What has been done
Done on Windows 11
Created function that takes average temperature of each sensor from previous day, adds the averages to a separate table (one row per sensor), then deletes all rows in the original table. I also scheduled the function to run at midnight every day using pg_cron.
To make sure that the t_sensors_tempSensorMockup rows actually gets deleted even if this job doesn't run one day, we simply delete all rows after getting the average for the previous day.
How to test
Since you shouldn't have to review this at midnight, I suggest changing "0 0 * * * " on line 23 in /DockerCompose/init_sql/03-sensors-cron-jobs.sql to " * * * * * ", meaning it will run every minute. The postgres docker shows logs when a scheduled job is ran, but you should also check the tables in the sensors database to make sure that the scheduled job/function work.
If you are having trouble building the postgres image, make sure to purge and remove previous postgres images and their volumes.
Review on #898
Whats done
Tested on Windows 11 using Firefox
Inspected following files: 00-general-configuration.sql, 01-sensors.sql, 03-sensors-cron-jobs.sql
Conclusion