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-4690 Create POST endpoint to create an Ensemble addon #3655

Merged

Conversation

kathyavini
Copy link
Collaborator

@kathyavini kathyavini commented Jan 16, 2025

Description

This is the controller to link an Ensemble organization to a LiteFarm farm. You can send a different addon_partner_id if you like, but you'll get back a 400.

POST to /farm_addon

Request body:

{
    "addon_partner_id": 1,
    "org_uuid": "ensemble-organisation-uuid"

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

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?

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

Test 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

… for readability

Remove reduce in favour of more readable array methods; encapsulate all three Ensemble methods into one function; define a constant for 'Ensemble Scientific'
…adability

Remove unused returned values from registerOrganizationWebhook; un-nest code run when function does not return early; add comments to make more explicit how bulkSensorClaim response is defined from Ensemble API response
@kathyavini kathyavini added the enhancement New feature or request label Jan 16, 2025
@kathyavini kathyavini self-assigned this Jan 16, 2025
@kathyavini kathyavini requested review from a team as code owners January 16, 2025 22:14
@kathyavini kathyavini requested review from antsgar and Duncan-Brain and removed request for a team January 16, 2025 22:14
@kathyavini
Copy link
Collaborator Author

kathyavini commented Jan 20, 2025

With the move towards the farm-wide "add-on" concept (and confirmation we're sticking with sending only organization_uuid), I'm now more inclined to let this be a POST to something like /add-ons/ or /add-ons/ensemble although I think that has to be implemented alongside the table rename (if that happens).

Otherwise I think "linking" and "unlinking" should l be the wording used now (to match the views) so I have made that change in the meantime.

@kathyavini kathyavini marked this pull request as draft January 21, 2025 20:29
@kathyavini kathyavini changed the base branch from integration to LF-4625-readability-refactors January 23, 2025 20:35
@kathyavini kathyavini changed the base branch from LF-4625-readability-refactors to integration January 23, 2025 20:40
@kathyavini kathyavini changed the title LF-4625a Update controller for sensor addition LF-4690 Create POST endpoint to create an Ensemble addon Jan 23, 2025
@kathyavini kathyavini changed the base branch from integration to LF-4625-readability-refactors January 23, 2025 20:46
@kathyavini kathyavini changed the base branch from LF-4625-readability-refactors to integration January 28, 2025 19:40
@kathyavini kathyavini marked this pull request as ready for review January 29, 2025 00:57
Duncan-Brain
Duncan-Brain previously approved these changes Jan 29, 2025
Copy link
Collaborator

@Duncan-Brain Duncan-Brain left a comment

Choose a reason for hiding this comment

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

Seems to be working great!

I think all my comments are optional

This PR had me wondering about being a good "addon_partner" and if we will ever need to limit req/s on our 3rd party endpoints. Would obv be worse for any readings endpoint than this one.

packages/api/src/controllers/farmAddonController.js Outdated Show resolved Hide resolved
packages/api/src/controllers/farmAddonController.js Outdated Show resolved Hide resolved
packages/api/src/models/addonPartnerModel.js Show resolved Hide resolved
packages/api/src/models/farmAddonModel.js Outdated Show resolved Hide resolved
Copy link
Collaborator

@SayakaOno SayakaOno left a comment

Choose a reason for hiding this comment

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

Looking forward to integrating this! 😍

@Duncan-Brain Duncan-Brain added this pull request to the merge queue Jan 30, 2025
Merged via the queue into integration with commit 1e6097f Jan 30, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants