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

Lf 4703 nice to have add base properties to farm addon #3687

Merged

Conversation

Duncan-Brain
Copy link
Collaborator

@Duncan-Brain Duncan-Brain commented Feb 11, 2025

Description

This PR adds base properties to the farm_addon object.

Also necessitates the addition of an id primary key to distinguish between deleted records.

Notes:

  • bumped up in my queue because it will really affect how DELETE endpoint works
  • Partial unique index constraint (PUI) used to guarantee maximum 1 single non deleted entry for a composite key. Use of this constraint is an indication to rethink the architecture. PUI is specifically difficult when working with multiple records at a time - like soil_amendment_task_products. Looking back soil amendment task products should not have base properties - it should use hard delete -- so I forget why I added base properties there maybe I was still learning. Here it makes sense to have base properties on farm_addon, so the main re-think is about if multiple addons with the same partner should be allowed -- and I think the answer is: in the future we may do that so constraining it for now is ok and can be removed later. We will also not be manipulating multiple records at a time so the drawback is less.
  • I might have some questions about the CRUD record cycle in the DELETE endpoint PR

Jira link: https://lite-farm.atlassian.net/browse/LF-4703

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Passes test case
  • UI components visually reviewed on desktop view
  • UI components visually reviewed on mobile view
  • Other (please explain): Tested in Postman

Checklist:

  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • The precommit and linting ran successfully
  • I have added or updated language tags for text that's part of the UI
  • I have added "MISSING" for all new language tags to languages I don't speak
  • I have added the GNU General Public License to all new files

@Duncan-Brain Duncan-Brain requested review from a team as code owners February 11, 2025 15:22
@Duncan-Brain Duncan-Brain requested review from antsgar and kathyavini and removed request for a team February 11, 2025 15:22
@Duncan-Brain Duncan-Brain force-pushed the LF-4703-nice-to-have-add-base-properties-to-farm-addon branch from 73712d1 to c56065a Compare February 11, 2025 15:44
Copy link
Collaborator

@kathyavini kathyavini left a comment

Choose a reason for hiding this comment

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

It looks pretty good to me!

In what sense does the PUI indicate we need to rethink architecture? I didn't quite follow that part of the PR description but I think I would be interested in hearing about that in tech daily -- maybe Thursday or tomorrow if the dev-design is fast?

The only thing missing that I could spot is that farmAdonModel.getOrganisationIds (this is called by getEnsembleSensors) will also need a .whereNotDeleted() with this change or you'll keep getting back sensors even after deleting the farm_addon record.

@Duncan-Brain
Copy link
Collaborator Author

@kathyavini

Just that its a one-off thing to need to use so its good to second guess it. Happy to explain the two times I have used it and why I regret the previous use of it -- but think its fine here for now.

Thanks for finding will fix!

@Duncan-Brain Duncan-Brain self-assigned this Feb 12, 2025
Copy link
Collaborator

@kathyavini kathyavini left a comment

Choose a reason for hiding this comment

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

Oh yeah, that's a good call to keep the old functions compatible until the point at which we remove them! 👍

Copy link
Collaborator

@antsgar antsgar left a comment

Choose a reason for hiding this comment

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

Looks good! ☺️ And I honestly don't dislike the constraint, I think it's a good solution

@antsgar antsgar added this pull request to the merge queue Feb 13, 2025
Merged via the queue into integration with commit 072e869 Feb 13, 2025
4 of 5 checks passed
@antsgar antsgar deleted the LF-4703-nice-to-have-add-base-properties-to-farm-addon branch February 13, 2025 23:32
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.

3 participants