EURODEO / e-soh-datastore-poc

E-SOH datastore PoCs
0 stars 0 forks source link

Clean up tables time_series and geo_point too #51

Open jo-asplin-met-no opened 1 year ago

jo-asplin-met-no commented 1 year ago

The cleanup function in postgresql.go deletes from table observation rows with obs times outside the current valid range.

This function should also delete rows from tables time_series and geo_point which no longer have any foreign key references to their id column. I.e. if the last observation that referred to a particular time series was just deleted, that time series can be removed (NOTE: the same time series (i.e. with the same metadata combo) may of course be reintroduced at a later point. Such a scenario will typically occur for sensors that are temporarily down for a period of more than a day.)

The motivation for cleaning up also time_series and geo_point is twofold:

  1. Saving resources (by keeping only relevant rows, i.e. rows associated with observations currently existing in the store).
  2. Increasing the consistency of the information returned by the GetTSAttrGroups method (more cleanup = more of the rows are relevant).