Automatically calculate average temperature and store the result. #727

Closed
opened 2026-05-05 07:09:14 +00:00 by a22erigr · 7 comments
Collaborator

Description

At the moment tempSensor generates alot of data. This will become problematic when we launch the application on the server. The obvious solution would be to delete old data. This unfortunately can't be done because we need old data to generate average temperature for year/month.

What should be done

After each day (00:00) all of the previous days data should be used to calculate average. The average should be places in a new table. AvrageTempDay. After this is done all of the previus days temp data should be removed.

## Description At the moment tempSensor generates alot of data. This will become problematic when we launch the application on the server. The obvious solution would be to delete old data. This unfortunately can't be done because we need old data to generate average temperature for year/month. ## What should be done After each day (00:00) all of the previous days data should be used to calculate average. The average should be places in a new table. **_AvrageTempDay_**. After this is done all of the previus days temp data should be removed.
Collaborator

Do we want to keep the scheduling logic in the postgres DB (this would mean using pg_cron or similar) or in the application backend (asp.net extensions)? @a22erigr @c24danli

Do we want to keep the scheduling logic in the postgres DB (this would mean using pg_cron or similar) or in the application backend (asp.net extensions)? @a22erigr @c24danli
Author
Collaborator

Looking in to it

Looking in to it
Collaborator

As per this comment we will use pg_cron to schedule database tasks

As per this [comment](https://git.webug.se/Andras/BoundlessFlowCampus2K/issues/740#issuecomment-8763) we will use pg_cron to schedule database tasks
Author
Collaborator

@a24vinla wrote in #727 (comment):

As per this comment we will use pg_cron to schedule database tasks
YES we should use g_cron.

@a24vinla wrote in https://git.webug.se/Andras/BoundlessFlowCampus2K/issues/727#issuecomment-8767: > As per this [comment](https://git.webug.se/Andras/BoundlessFlowCampus2K/issues/740#issuecomment-8763) we will use pg_cron to schedule database tasks YES we should use g_cron.
Collaborator

I will change name of new table from AvrageTempDay to t_sensors_daily_average, if that is OK? @a22erigr @c24danli

I will change name of new table from AvrageTempDay to t_sensors_daily_average, if that is OK? @a22erigr @c24danli
Author
Collaborator

@a24vinla wrote in #727 (comment):

I will change name of new table from AvrageTempDay to t_sensors_daily_average, if that is OK? @a22erigr @c24danli

After a long and thorough discussion with the leadership we have decided that this decision is okay

@a24vinla wrote in https://git.webug.se/Andras/BoundlessFlowCampus2K/issues/727#issuecomment-9259: > I will change name of new table from AvrageTempDay to t_sensors_daily_average, if that is OK? @a22erigr @c24danli After a long and thorough discussion with the leadership we have decided that this decision is okay
a24vinla added reference 727-calculate-average-temperature-and-store-the-result 2026-05-11 13:55:44 +00:00
Author
Collaborator

Has been merged in #898

Has been merged in #898
Sign in to join this conversation.
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#727
No description provided.