chime-experiment / Daily_validation

Daily validation notebook
0 stars 0 forks source link

feat(viewer): Revision selection and back-end rewrite #25

Closed ketiltrout closed 4 months ago

ketiltrout commented 4 months ago

This is a fairly extensive re-write with the following goals:

Additionally, there's been a bit of tidying up

Removing front-loading

Closes #19

As first written, the viewer used to find all opinions for a user when they first logged in. This data was shoved into the rendered HTML template (in a very non-JSON-y way, for unknown reasons). The only benefit of doing this was that the client never had to contact the server again (except if the user wanted to update their opinion).

Fine in theory, if there are only a few opinions for a user (which was true when the viewer was first written), but causes more-and-more slowdown as opinions accumulate over time.

In place of this, the client now side-loads opinions for a CSD (for all available revisions) by sending a fetch request to the server, which returns the data in JSON (see fetch_csd in the server, though most of the work is done in csd_data; and also set_csd in the client).

The downside here is there is a delay when switching CSDs in the viewer as the viewer has to wait for the server to return the data, but I don't find this delay noticable in practice.

Specific server-side changes:

Specific client-side changes:

Pipeline revision selection

Closes #20

The fixed global _REVISION has been removed. In its place, the viewer now will dynamically figure out which revisions to load/display:

Specific changes:

Other changes

I've removed the script_name and base_path vars which were an unnecessary attempt to tell the client where to send requests: the client doesn't need this; it already knows the URL it's using. More evidence that these are not needed: they were broken when we transitioned the viewer to gunicorn (both ended up as "") but the client didn't notice or care).

This PR breaks up the update_opinion function in the server, which isn't technically necessary, and only done in anticipation of the category handling stuff.

ketiltrout commented 4 months ago

I've left the test-version running here (with only a few CSDs available) if you want to test it: https://bao.chimenet.ca/daily-test/view

ketiltrout commented 4 months ago

I've realised that the CSD selection buttons don't update as they should when revision change happens in the UI. I don't think this is a big enough problem to fix in this PR (since it only affects the CSD you're currently on when you revision switch - as soon as you navigate to another CSD things are fixed), but I've made an issue for it (#26) and I'll deal with it in a subsequent fix.

ketiltrout commented 4 months ago

I think the code all seems fine. The test viewer seems to work without issue, so I think this is stable enough to deploy.

This is incredibly minor, but in safari the buttons change shape depending on whether or not there's an opinion-based colour being set.

Hmm. I'm changing the border property. Maybe I can just change the border colour without affecting the rest of the border styling.

ljgray commented 4 months ago

Hmm. I'm changing the border property. Maybe I can just change the border colour without affecting the rest of the border styling.

If it doesn't end up being something simple to debug, I don't think it should block us from deploying this update

ketiltrout commented 4 months ago

In the end, I just disabled webkit styling from those buttons. So they look consistent, at least.