Closed mbarton closed 4 weeks ago
Cool thanks. I agree that in the context of the slow page load the cache doesn't make much difference - testing it locally it takes 1.5 seconds without the banners and 1.6 with.
I think I will still keep in it though just for the sake of the unauthenticated homepage.
I've raised a separate issue to look at the performance of the org summary page: https://github.com/rcpch/rcpch-audit-engine/issues/1092
The nice thing about a model is that you could potentially track who has seen the banner and who hasn't? So for example if they have already completed the audit you could hide the banner, or if you have read the notification we could stop showing it
I'm definitely up for the latter, the former feels quite use case specific where I'm trying to keep the banners implementation as general as possible
Fixes #1060 Fixes #1059 Fixes #882
Add banners using the Django admin, targeted to specific pages using a regular expression. Add arbitrary HTML to the banner.
Allows us to implement the guidance for the organisational audit in #1060 and #1059 generically. In particular you can target banners at specific users (eg the organisational audit CTA should only be shown to lead clinicians). RCPCH audit team members can always see banners.
Banners are a model in the database but are cached for 10 seconds to avoid introducing another database call on every page load. This might be overkilll though as our pages load from the DB pretty much every time anyway. Although this way at least the unauthenticated homepage doesn't hit the DB every time.
@eatyourpeas do you think a model and the Django admin is the right way to implement this? I'm wondering should the banner definitions just be in the codebase since we have a quick CD pipeline now? At least having it in the DB the team can change banners without raising a PR and being worried they'd break something.