winds-mobi / winds-mobi-client-js

Real-time weather observations: web client
https://winds.mobi
GNU Affero General Public License v3.0
2 stars 3 forks source link

Not able to zoom onto 5d graph #8

Closed MichalBryxi closed 2 months ago

MichalBryxi commented 2 months ago

Steps to reproduce

1) GOTO: https://winds.mobi/stations/map/holfuy-1804 2) Click on "wind" tab 3) Try to select: "Zoom: 5d" 4) Observe that nothing has happened

Expected behaviour

Screenshots

5days

ysavary commented 2 months ago

Thank you for describing this problem precisely. I think the reason is that there is not 5 days of data stored in mongodb for providers that have a high update rate like Holfuy because we are simply using capped collection with a maximum documents and size: https://github.com/winds-mobi/winds-mobi-providers/blob/main/winds_mobi_provider/provider.py#L80

We could create a background process that cleans up the measurement collections based on time, but that's not a priority currently in my opinion.

ysavary commented 2 months ago

I took a look in measurements collections:

winds> db["holfuy-1293"].stats()
{
  capped: true,
  max: 5000,
  maxSize: 500224,
  sharded: false,

  size: 500214,
  count: 4134,
  storageSize: 204800,
  totalIndexSize: 94208,
  totalSize: 299008,
  indexSizes: { _id_: 94208 },
  avgObjSize: 121,
}

Holfuy collections are reaching the capped limits of a size of 500K and a max of 5000 records.

When I started winds.mobi, capped collections were the only way to limit the size of a collection. Today, mongodb recommends to use TTL index. But:

  1. it's not possible to change capped limits before mongo 6 and we are still on mongo 4.4
  2. it's not possible to un-cap a collection, we have to clone then delete the original collection

I think that I'll write a mongosh script that clone all the capped collections to new regular collections with a TTL index.

ysavary commented 2 months ago

@MichalBryxi

Here is the PR: https://github.com/winds-mobi/winds-mobi-providers/pull/98

MichalBryxi commented 2 months ago

Spanish village to me :) , but 🙇🏾 for addressing this issue. Now it seems like it's re-collecting the data as all the weather stations seems to have "only" ~1.5 days of data.

Thanks for the quick fix. I think I can just close this one.

ysavary commented 2 months ago

seems to have "only" ~1.5 days of data.

Yes, unfortunately, I had an issue during the migration. I tested the mongosh script locally but when I ran it in production the timing was different and monodb expires the measurements earlier. I lost all the measurements 😢 Well, history is rebuilding now.