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

PLU-309: [TILES-ATOMIC-INCREMENT-4] backend implementation for increment/decrement row value #835

Open
wants to merge 2 commits into
base: fix/tiles/update-operator
Choose a base branch
from

Conversation

pregnantboy
Copy link
Contributor

@pregnantboy pregnantboy commented Dec 24, 2024

TL;DR

Add backend implementation for 'add' and 'subtract' operations for Tiles update row action

What changed?

  • Modified patchTableRow to handle mathematical operations
    • added tests
    • error handling for invalid numeric operations
  • Updated column metadata for tiles action to maintain column ordering
    • Fixed variable sorting logic for null order values

How to test?

  1. Create a tile with a few columns and values that are both numbers and strings
  2. Test updating cells using:
    • normal updates (set as)
    • adding
    • subtracting
    • mixed
  3. Verify error handling by:
    • Attempting math operations on non-numeric values (both original values and operands)
  4. Check that columns maintain their order in the UI

Regression test

  1. Check that existing tiles update rows are still working

Copy link
Contributor Author

@datadog-opengovsg
Copy link

datadog-opengovsg bot commented Dec 24, 2024

Datadog Report

Branch report: feat/tiles/update-operator-backend
Commit report: 4e5afd5
Test service: plumber

✅ 0 Failed, 736 Passed, 0 Skipped, 2m 18.89s Total Time

@pregnantboy pregnantboy changed the title feat: add backend logic to perform atomic increment/decrement PLU-309: [TILES-ATOMIC-INCREMENT-4] enhance multirow-multicol UI with custom styles and operators Dec 24, 2024
Copy link

linear bot commented Dec 24, 2024

@pregnantboy pregnantboy changed the title PLU-309: [TILES-ATOMIC-INCREMENT-4] enhance multirow-multicol UI with custom styles and operators PLU-309: [TILES-ATOMIC-INCREMENT-4] backend implementation for increment/decrement row value Dec 24, 2024
@@ -32,13 +32,13 @@ function sortVariables(variables: Variable[]): void {
variables.sort((a, b) => {
// Put vars with null order last, but preserve ordering (via `sort`'s
// stability) if both are null.
if (!a.order && !b.order) {
if (a.order == null && !b.order == null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

b.order == null instead

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oops!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

goood catch

Copy link
Contributor

@m0nggh m0nggh left a comment

Choose a reason for hiding this comment

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

other than the small nit, lgtm

tested that the

  • 3 operations work
  • error is caught for non-numeric add/subtract
  • old update row steps still work
  • columns variables now maintain order

@pregnantboy pregnantboy force-pushed the feat/tiles/update-operator-backend branch from 6419851 to 76739a8 Compare January 9, 2025 10:50
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