open-sauced / app

🍕 Insights into your entire open source ecosystem.
https://pizza.new
Apache License 2.0
412 stars 221 forks source link

Bug: Metrics take a minute to update on Workspace creation #2986

Open isabensusan opened 6 months ago

isabensusan commented 6 months ago

Describe the bug

During a demo with the Appwrite team, we had the situation where Tessa setup her workspace on the call, but when she finished setup and went to take a look at her dashboard, all metrics where at 0. She had to do a hard refresh to start seeing the correct numbers.

@bdougie mentioned this was a recurring issue

image

Suggested solution

Can we setup a loading or indexing state? UI wise we should:

Copy for a potential toast

Title: We're fetching your data Content: This shouldn't take longer than 5 minutes. If it does, try doing a hard refresh on the page or open a support ticket

Where support ticket opens up a bug in the repo (or a discussion?)

image

Steps to reproduce

  1. Create a new workspace
  2. Add repositories (preferably, some you haven't used in other workspaces before)
  3. Click on Update Workspace
  4. Navigate to the dashboard and see the metrics at 0

Browsers

No response

Additional context (Is this in dev or production?)

No response

Code of Conduct

Contributing Docs

github-actions[bot] commented 6 months ago

Thanks for the issue, our team will look into it as soon as possible! If you would like to work on this issue, please wait for us to decide if it's ready. The issue will be ready to work on once we remove the "needs triage" label.

To claim an issue that does not have the "needs triage" label, please leave a comment that says ".take". If you have any questions, please reach out to us on Discord or follow up on the issue itself.

For full info on how to contribute, please check out our contributors guide.

nickytonline commented 6 months ago

We'd have to start in the API to surface an indexing state, so that the UI can respond accordingly.

jpmcb commented 6 months ago

Can we setup a loading or indexing state?

...

We'd have to start in the API to surface an indexing state

On the API side, there's nothing to load or index. It should be all almost immediately available since we're aggregating all this data in real time from buckets of events we already have. If I make a workspace with some repos, that workspace is successfully created, all that data should be there on the next workspace call.

I think I know what the problem is: the http-cache headers are probably kicking in which is why you won't see an update unless you hard refresh / clear you local-storage / cookies. We definitly want the http-cache headers ... but if there was a way that the client could ignore those caches on certain scenarios, that would be super ideal.

Otherwise, we'd have to start exploring lifting the caching out of the http layer and into the API.

nickytonline commented 6 months ago

I think you can pass additional headers in a fetch call to ignore the cache, but I wonder if it makes sense to use the http cache for this particular scenario. But we also use the useSWR hook. It looks like we can pass the useSWR fetcher headers as arguments. See https://github.com/vercel/swr/discussions/545