727-calculate-average-temperature-and-store-the-result #898

Merged
a22erigr merged 2 commits from 727-calculate-average-temperature-and-store-the-result into team_2_week_5 2026-05-12 15:08:38 +00:00
Collaborator

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.

  • /DockerCompose/init_sql/01-sensors.sql
    • Added new daily average table
  • /DockerCompose/init_sql/03-sensors-cron-jobs.sql
    • Created function and scheduled it

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.

## 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. + /DockerCompose/init_sql/01-sensors.sql + Added new daily average table + /DockerCompose/init_sql/03-sensors-cron-jobs.sql + Created function and scheduled it ## 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.
a24hamrh approved these changes 2026-05-12 12:32:09 +00:00
a24hamrh left a comment
Collaborator

Review on #898

Whats done

Tested on Windows 11 using Firefox

  • App starts
    • Checked the postgres docker logs for when a scheduled job is ran.
    • Added a Temperature card and it showed temperature.

Inspected following files: 00-general-configuration.sql, 01-sensors.sql, 03-sensors-cron-jobs.sql

  • all
    • Indentation/code styling
      • Indentation is ok
    • Naming convention
      • Naming convention is followed
    • Comments
      • Comments follows standard and are plenty
    • General code quality
      • The general code quality is good

Conclusion

  • The temperature functions run according to the scheduling in 03-sensors-cron-jobs.sql and works as intended.
# Review on #898 ## Whats done ### Tested on Windows 11 using Firefox + App starts + Checked the postgres docker logs for when a scheduled job is ran. + Added a Temperature card and it showed temperature. ### Inspected following files: 00-general-configuration.sql, 01-sensors.sql, 03-sensors-cron-jobs.sql + all + Indentation/code styling + Indentation is ok + Naming convention + Naming convention is followed + Comments + Comments follows standard and are plenty + General code quality + The general code quality is good ## Conclusion + The temperature functions run according to the scheduling in 03-sensors-cron-jobs.sql and works as intended.
a22erigr merged commit eae0f5e00f into team_2_week_5 2026-05-12 15:08:38 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Andras/BoundlessFlowCampus2K!898
No description provided.