Skip to content

Conversation

gursimran-singh
Copy link
Collaborator

Description

This PR introduces a new endpoint to provide weather information for the farm. Previously, the frontend directly called the OpenWeather API, exposing API keys. Now, all logic is handled securely behind this endpoint. Additionally, this PR updates the frontend to use the correct RTK Query endpoint for fetching weather data.

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

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?
Login with your credentials and select farm. On landing page, weather information is shown.

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

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

@gursimran-singh gursimran-singh requested review from a team as code owners April 3, 2025 13:44
@gursimran-singh gursimran-singh requested review from antsgar and kathyavini and removed request for a team April 3, 2025 13:44
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.

Left a few suggestions but looks really good overall, thank you so much again for helping improve this ☺️

Comment on lines 23 to 29
try {
const farm_id = req.headers['farm_id'];
const row = await baseController.getIndividual(FarmModel, farm_id);

if (!row.length) {
return res.sendStatus(404);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

We have a method called getFarmByID in the farm controller that does exactly this except it gets the farm from the params, could we update that one to read either from params or from the header? I also think that method should probably just return the single row instead of an array

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This function getFarmByID also uses await baseController.getIndividual(FarmModel, id); so the result would be same. I have updated the code to use array de-structure rather than index to make it cleaner.

@gursimran-singh gursimran-singh requested a review from antsgar May 1, 2025 07:41
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