Replies: 4 comments 7 replies
-
I'm pleasantly surprised that the entire productions flows table is currently 4.7MB in a csv. It should be smaller than that with binary json fields. |
Beta Was this translation helpful? Give feedback.
-
this overall sounds good, and feasible!! i'm wondering if it's worth prioritizing a third column on the snapshot approach for portals makes a lot of sense to me. i think the alternative assumption that users publish portals/subflows individually would only get more complicated down the line if we introduced more roles & permissions - like, what if you want to publish your local council's flow, but it relies on a subflow that is published in another team that you can't access individually? snapshotting seems like a good way to bypass those questions for now. in order to snapshot accurately, i think the new columns will need default/initial values, is that assumed whne you mention adding new fields? let's say i'm editing a parent flow, and it has a single portal, and that portal is also being edited by someone else. when i "publish" the parent, it should snapshot the last published version of the portal, right? This way we don't capture any edits-in-progress in the subflow. I think this means that the new fields should be initially populated with the current flow values & now() so that the first user-initiated publish button click queries them. make sense? i think there's also postgres extensions for jsonb compression that might be quick wins and require minimal extra config, but would have to refresh/research a bit in that area. |
Beta Was this translation helpful? Give feedback.
-
We'll need two "preview" urls. One for previewing editor changes and one for end users to see published flows. |
Beta Was this translation helpful? Give feedback.
-
Rebooting this discusson thread in light of this Trello ticket: https://trello.com/c/lSkxf408/1572-decide-which-functionality-is-still-outstanding-to-be-able-to-enable-the-publish-button-in-production Recap of how publish works now (disabled on .uk domain):
Proposal for production mvp:
Sandbox for testing against full-sized flow content at #683 // https://683.planx.pizza Any other ideas or current painpoints we want to smooth out before enabling on prod that this doesn't address yet? |
Beta Was this translation helpful? Give feedback.
-
Add a 'publish button' in the editor
Problem
We need a way to be able to edit flows without the content changes going live immediately. We could edit them in staging and then migrate the data to production but this adds a lot of complexity with ensuring that the code is going to be compatible with the content.
Potential solution
If there was a publish button, it would allow admins to edit content and these new changes would not be visible in the frontend until someone clicks publish. The downside is this behaves a bit like trying to have multiple people edit and save the same textfile on your desktop, rather than something more flexible like branches in git. It might be enough for now though?
We could add two fields to
flows
, namedpublished_at:timestamp
andpublished_data:jsonb
Move this dataMerged* function out of the
editor.planx.uk
codebase and into an express endpoint e.g.flows/:flowId/publish
inapi.planx.uk
*
.dataMerged(flowId)
loads a flow, searches for any external portals inside it, then loads those flows too. It does this recursively until it's loaded all of the sub-flows. It then replaces all of the external portal nodes with the actual flows, flattening everything into a single flow object.How it works
At
2021-06-14T11:16:00
, an editor is working on flowxxx-xxx-xxx
in the editorpublished_data
andpublished_at
is set to2021-06-14T11:16:00
The editor can now show "published 0 minutes ago"... or whatever! (not important RN)
The frontend would simply request
flows.published_data
from hasura, and not need to worry about doing any recursive flattening operations like it does now.Thoughts
publishing sub flows too
Right now this behaves like a snapshot operation of whatever the current state of a flow is and all of its subflows. I think that needing to open subflows and publish them individually too would become too much a mental burden on the editors. Very happy to discuss if you think I'm wrong here though.
dedicated table
These publish operations should probably be stored in a separate table rather being extra fields in flows e.g.
published_flows
Then you'd have the has_one relationshipflows.published_flow_id
->published_flows.id
, and in hasura you could still callflow.published_data
, which would return the associatedpublished_flow
's data JSONB field.Then you'd have the belongs_to relationship
published_flows.flow_id
->flows.id
, and in hasura you could still callflow.published_flow.data
, which would return the associatedpublished_flow
's data JSONB field.It would give you the opportunity to add more fields like
publisher_id
(user_id),comments
(commit notes),flow_version
etc.Explained further in #482 (reply in thread)
storing the published data elsewhere?
this
published_data
data could become quite large, spitballing here but ~1-5MB? You could remove it and just store thepublished_at
field.This is probably not necessary now but then you could cache the initial response of the
/publish
endpoint with a CDN like cloudflare, using a timestamp in the URL.When publishing you'd call this instead, notice the added timestamp param in the url
https://api.editor.planx.uk/flows/xxx-xxx-xxx/publish/2021-06-14T11:16:00
When loading the flow in the frontend you'd know the
flow.id (xxx-xxx-xxx)
andflow.published_at (2021-06-14T11:16:00)
so you could recreate the same URL and call it, but this time instead of publishing the flow, it would be loading a static JSON response directly from the CDN cache.or, store s3 URL of json file
Alternatively instead of storing
published_data:jsonb
you could save the response to a file in s3 and either make the filename deterministic based on the timestamp like the CDN method aboveor store the url to that file in the database as something like
published_url:text
, then when you load the frontend you'd query whatflow.published_url
is and load that file directly from s3.Beta Was this translation helpful? Give feedback.
All reactions