Closed ketiltrout closed 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
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.
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.
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
In the end, I just disabled webkit styling from those buttons. So they look consistent, at least.
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 (seefetch_csd
in the server, though most of the work is done incsd_data
; and alsoset_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:
fetch_csd
function is used to respond to these side-loading requests. Most of the actual data generation is implemented incsd_data
(which evolved from thecsd_vars
function and is also used after an opinion update to generate the data returned to the client).Specific client-side changes:
csd_list
global has been deleted (formerly a list of all available CSDs)opinions
global now holds the user's opinion for the current CSD only (indexed by revision), rather than all CSDs.vet_csd
function, which was used to validate numbers typed into the CSD box, has been deleted (the functionality is now handled by the server during the side-loading)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:DataRevision
and finds all revisions for which at least one rendered notebook exists. This ends up as theREVISIONS
global, and will remain fixed until server restart.REVISIONS
(i.e. it doesn't change unless a server restart happens) but, if the currently-viewed CSD has no rendered notebook for a particular revision, the corresponding revision button is disabled to indicate that.Specific changes:
rev
parameter) must be submitted with all requests now, and is provided in all responses. When not given a valid revision number, the server will default to the lowest available revision. Instances where a client's query data was stripped of "unimportant" data has now been unified into thestrip_query
function.update_ui
client function has been broken up into two parts:update_data
which updates the globals based on a server's response, anddraw_ui
which performs the document update based on the state of the globals.update_data
is called by side-loader callbacks, and in turn will calldraw_ui
, but thedraw_ui
function is also called by the revision selection buttons (via theirset_rev
function), which doesn't involve a side-load.Other changes
I've removed the
script_name
andbase_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.