Skip to content

Conversation

@danielshid
Copy link
Contributor

Description

Refactored and added to weather data and weather location code according to the "Getting temperature data" section of the weather data design document.

Partially Addresses #1291

Type of change

  • Note merging this changes the database configuration.
  • This change requires a documentation update

Checklist

  • I have followed the OED pull request ideas
  • I have removed text in ( ) from the issue request
  • You acknowledge that every person contributing to this work has signed the OED Contributing License Agreement and each author is listed in the Description section.

Limitations

The data that my code gets from Openmateo does not match what Openmateo outputs directly.

Josue-SR and others added 29 commits April 29, 2024 11:09
Copy link
Member

@huss huss left a comment

Choose a reason for hiding this comment

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

Thanks to @danielshid for another contribution to OED. Not unexpectedly given the size of this PR, I made a number of comments within files. Here are some thoughts that don't fit nicely within files:

  • The check failed because src/client/app/components/weather/EditWeatherModalComponent.tsx does not have an MPL header.
  • There needs to be a migration for the changes to the preferences table including making the correct default values.
  • src/server/sql/preferences/insert_default_row.sql needs values for the new preferences columns. I propose the temperature unit be celsius since area is meter.
  • There is a model and sql for weather data but no route to get the data. This is going to be needed for the graphics.
  • I tried to do a careful reading of all the code. I still need to sweep the TODO items within the code to decide what to do. I also need to check the old PR comments and design doc to make sure all is good but I don't think that will show much at this point.

If anything is not clear or you have thoughts then please let me know. I'm also here to help as needed.

"ngraph.graph": "~20.0.0",
"ngraph.path": "~1.5.0",
"nodemailer": "~6.9.13",
"openmeteo": "~1.1.3",
Copy link
Member

Choose a reason for hiding this comment

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

openmeteo is now at version 1.2.3.

const response = await request(app).get('/api/weatherLocation');
// Check for successful response
expect(response.status).to.equal(200);
expect(response.body).to.be.an('array');
Copy link
Member

Choose a reason for hiding this comment

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

This would be a much stronger test if it added a location first and verified it could retrieve that location. Please either do or add a TODO.

The other two test are also weak in not checking the returned values.

const app = require('../../app');
const { expect } = require('chai');

mocha.describe('Weather Location Routes', () => {
Copy link
Member

Choose a reason for hiding this comment

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

I think all the tests should be under this one describe.

});
});

mocha.describe('POST for adding a weather location', () => {
Copy link
Member

Choose a reason for hiding this comment

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

This and the next test fails because the route now (correctly) checks for admin status. Thus, it needs to login in first to get the token as in other admin route tests.

const conn = DB.getConnection();
let serverEnum = [];
let jsObject = [];
//SQL query returning area_unit_type ENUM
Copy link
Member

Choose a reason for hiding this comment

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

area_unit_type -> temperature_unit_type

resetState();
};

const compareLocations = (loc1: { [x: string]: any; }, loc2: { [x: string]: any; }) => {
Copy link
Member

Choose a reason for hiding this comment

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

A few thoughts on this. First, I think it is trying to see if edits were made. This is not how many other pages do it. They check each item and some use a useEffect so the save is disabled if no change was made. I'm okay with the new way as it is more general but OED should consider switching to it across pages if it is going to be used. I also think the disable of the save is better and should be used here.

*/
const [validLocation, setValidLocation] = useState(false);
useEffect(() => {
setValidLocation(state.identifier !== '' && state.gps !== '');
Copy link
Member

Choose a reason for hiding this comment

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

This is a weak check to disable save. See below on making it better.

placeholder='gps'
disabled={true}
/>
<FormFeedback>
Copy link
Member

Choose a reason for hiding this comment

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

Since it cannot be changed (disabled) then I don't think form feedback is needed. The autocomplete, etc also seem unneeded (if can remove).

req.body.note
);
await newLocation.insert(conn);
await addWeatherDataForLocation(newLocation, conn);
Copy link
Member

Choose a reason for hiding this comment

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

When you add a new weather location I get a failure notice but the location is added. However, I don't think any weather data is added. I believe the issue is that the insert happens on the line above but the id is not captured and set in the newLocation so getLatestTimeStamp does not find it and it fails. However, maybe it should have been done via this and it is something else.

autoComplete='on'
onChange={e => handleStringChange(e)}
value={state.identifier}
placeholder='Identifier'
Copy link
Member

Choose a reason for hiding this comment

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

OED does not use placeholders as there is a title above each input. All of these should be removed.

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.

5 participants