geeksforsocialchange / PlaceCal

Bring your community together
https://placecal.org
GNU Affero General Public License v3.0
17 stars 8 forks source link

Give quicker feedback when adding a new calendar #1502

Open aaaaargZombies opened 2 years ago

aaaaargZombies commented 2 years ago

User story

As an admin I need add a calendar and see if the import is successful so that I can keep track of what stage of the process I am at and try to figure out any issues / relax and have confidence that placeCal is working.

It should also be quick - just added a calendar that took 20 mins to show up

Acceptance criteria

Implementation notes & questions

Noted in #1501

I just went through this with Georgie actually and yes our "time to see result of your import" is far too long. I think it is deffo a new ticket tho!

Implementation plan

To be written by the developer

ivan-kocienski-gfsc commented 2 years ago

The problem is that you can't tell if a calendar will import successfully without importing the calendar. The best you can hope for is to put together some heuristics that try to make a best guess. You may suggest that we could do the import in request immediately upon calendar save but they can take a very long time which is why they are background jobs.

So there are no easy solutions.

I would suggest finding a way to better explain to a user the process/state of a calendar

kimadactyl commented 2 years ago

This can be done but it's a bit of javascript:

  1. New calendar imports get run immediately rather than waiting for the queue cron to run
  2. A lil javascript spinner shows you the current state of the job
  3. When its done the page reloads
kimadactyl commented 1 year ago

Came up today after a calendar took ages to show up - i think the new longer cron period is exacerbating this

ivan-kocienski-gfsc commented 1 year ago

Okay so a solution may be to make the calendar importer more modular with two parts:

Remote Event Scanner (a better name would be nice here)

All the code that tries to read a remote URL, fetch and parse the event data into a common format is here, it has no notion of any of the rails stuff- so no "calendar" object, no partners and no tags or anything like that. Just takes a URL and returns a payload with something like

{
  "importer_wanted": "",
  "importer_used": "ical",
  "events": [  ]
}

This can then be exposed in a (very private) API endpoint that just takes a URL and returns the JSON in an ajax type thing.

The Importer Worker

Wraps the thing above and does all the nasty rails stuff

Thoughts

It will be a lot faster as a lot of the calendar importers' time is taken up with database stuff (especially that weird versioning gem we use). But also it won't be perfect as the events that come back haven't been resolved onto the calling users calendar/partner.