Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(backend): Toggle flow online or offline #3170

Merged
merged 8 commits into from
May 24, 2024
Merged

Conversation

DafyddLlyr
Copy link
Contributor

@DafyddLlyr DafyddLlyr commented May 20, 2024

What does this PR do?

  • Adds flows.status column, which can be one of "online" or "offline"
  • Adds flow_status_history audit table which could be used to check the status of a flow at a given point in time, and could be used to filter analytics if we wished to do so
  • Populates table to indicate that all flows are currently "online"
  • Adds trigger tack_flow_status_history() which has the following behaviour -
    • Called on UPDATE to flow.status or INSERT to flows
    • Closes "open" flow_status_history record, and opens new one with toggled status

Testing

  • Hasura introspection tests for table permissions
  • Gherkin integration tests for trigger behaviour

Next steps...

  • Simple toggle in Editor to control status
  • Restrict public access to flow based on status
  • Slack message on toggle (?)

Regression tests passing here - https://github.com/theopensystemslab/planx-new/actions/runs/9162033526

Copy link

github-actions bot commented May 20, 2024

🤖 Hasura Change Summary compared a subset of table metadata including permissions:

Tracked Tables (2)

Updated Tables (1)

  • public.flows permissions:

    insert select update delete
    api / /
    platformAdmin / /
    public /
    teamEditor / /
    7 added column permissions
    insert select update
    api ➕ status ➕ status
    platformAdmin ➕ status
    public
    teamEditor ➕ status

Copy link

github-actions bot commented May 20, 2024

Removed vultr server and associated DNS entries

@DafyddLlyr DafyddLlyr force-pushed the dp/flow-offline-online branch from eade504 to 940a2c0 Compare May 20, 2024 16:14
@DafyddLlyr DafyddLlyr changed the title feat(wip): Toggle flow online or offline feat(backend): Toggle flow online or offline May 20, 2024
@DafyddLlyr DafyddLlyr force-pushed the dp/flow-offline-online branch from 940a2c0 to 3856c52 Compare May 20, 2024 16:27
@DafyddLlyr DafyddLlyr requested a review from a team May 21, 2024 07:49
@DafyddLlyr DafyddLlyr marked this pull request as ready for review May 21, 2024 07:49
@DafyddLlyr
Copy link
Contributor Author

Copy link
Member

@jessicamcinchak jessicamcinchak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good & thorough (appreciate all the testing here), but a few questions around domain assumptions here!

Plus one more point I'm thinking about for "Next steps..."

  • Only write analytics records when URL does not have param ?analytics=false AND when flow status is "online" !
    • If we can just skip writing the tracking events altogether when flows are "offline", that should save us having to add joins to flow_status_history to the analytics views?
    • This would similarly assume that existing flows are online by default & new ones are offline I think?

@DafyddLlyr
Copy link
Contributor Author

Only write analytics records when URL does not have param ?analytics=false AND when flow status is "online"

This is an elegant and clever solution - very much on board! Much easier than a tricky join and actually matches the model we want and users would expect (analytics are collected for "online" services only).

Copy link
Member

@jessicamcinchak jessicamcinchak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most recent changes look good!

DafyddLlyr added a commit to theopensystemslab/planx-core that referenced this pull request May 21, 2024
Please see theopensystemslab/planx-new#3170 for
context.

This PR adds a helper method to toggle the status of the flow. This is
used in E2E tests, and will be called by Editors in the frontend.
@DafyddLlyr DafyddLlyr force-pushed the dp/flow-offline-online branch 2 times, most recently from eec4867 to 29a71ed Compare May 21, 2024 20:48
@DafyddLlyr DafyddLlyr force-pushed the dp/flow-offline-online branch from 8a462a6 to 88939f6 Compare May 24, 2024 07:55
@DafyddLlyr DafyddLlyr merged commit 8f0478b into main May 24, 2024
12 checks passed
@DafyddLlyr DafyddLlyr deleted the dp/flow-offline-online branch May 24, 2024 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants