Handling data for sensorRead from a DBS #12

Closed
opened 2026-03-27 15:30:01 +00:00 by Andras · 4 comments
Owner

sensorRead handles old (historical) data.

Add a function so that we can read in old (historical) data when we are updating (or refreshing the system).

sensorRead handles old (historical) data. Add a function so that we can read in old (historical) data when we are updating (or refreshing the system).
Author
Owner
Parent / related issue: [Additional microservices for monitoring for multiple sensors #7](https://git.webug.se/Andras/BoundlessFlowCampus2K/issues/7)
Collaborator

I have made a fuction that read the historic data, and added a view just to show it. I took it as this issue was only to create the read part so the view is not as it should be displayed only to show the values and see that it works.

I have made a fuction that read the historic data, and added a view just to show it. I took it as this issue was only to create the read part so the view is not as it should be displayed only to show the values and see that it works.
Collaborator

Added parts in the branch:
2 new files under /frontend/src/features/temperature

  • TemperatureTimeSeriesView.js # a view just to see that it works
  • useTemperatureTimeSeriesView.js # the actual feature
    and in /frontend/src/app/App.js
    i have added line 9
    <TemperatureTimeSeriesView/>
    to call the render on the lokalhost to view
Added parts in the branch: 2 new files under /frontend/src/features/temperature - TemperatureTimeSeriesView.js # a view just to see that it works - useTemperatureTimeSeriesView.js # the actual feature and in /frontend/src/app/App.js i have added line 9 `<TemperatureTimeSeriesView/>` to call the render on the lokalhost to view
Collaborator

Whats done

  • Tested on fedora 43
    • Worked without problems
    • Used UnixBuild.sh
  • inspected code in following files
    • TemperatureTimeSeriesView.js
    • useTemperatureTimeSeriesView.js
    • App.js
  • Tested to run the function useTemperatureTimeSeriesView using a empty array.
const [data, setData] = useState([]);
  • This worked without problems.

  • Also tested the code using null instead of an empty array.

const [data, setData]  = useState(null);

Needs to be improved

  • Comments in TemperatureTimeSeriesView.js and useTemperatureTimeSeriesView.js does not follow the standard for multi line comments in javascript. How to comment .
//This function uses the prebuilt api/temperature/all in middleware/tempService
// if succsessfull it gives back an list of pares timestamp,temperature inside the data varible being returned
// the array in the data varible will hold all recorded pairs in the db so it needs to be filtered if the entirerty is unwanted
//[
//  {Timestamp,temperature}
//  {Timestamp,temperature}
//  {Timestamp,temperature}
//]
  • Unnecessary change to code.
const [data, setData] = useState([]);
  • change to.
const [data, setData] = useState(null);
  • No unit tests for useTemperatureTimeSeriesView
    • Unit test for this function is unnecessary be because the refactoring done in Breakout of duplicate code in frontend/src/features #159 The central function useApi already implements a unit test.
    • This implies that you don't need to implement a unit test but in future don't forget to write unit tests.
## Whats done + Tested on fedora 43 + Worked without problems + Used **_UnixBuild.sh_** + inspected code in following files + TemperatureTimeSeriesView.js + useTemperatureTimeSeriesView.js + App.js + Tested to run the function _**useTemperatureTimeSeriesView**_ using a empty array. ``` javascript const [data, setData] = useState([]); ``` + This worked without problems. + Also tested the code using null instead of an empty array. ```javascript const [data, setData] = useState(null); ``` + This also worked and should be implemented. + Reason: [Breakout of duplicate code in frontend/src/features #159](https://git.webug.se/Andras/BoundlessFlowCampus2K/issues/159) + By using null it's going to be easier to refactor the code to use the shared _**useApi**_ function. ## Needs to be improved + Comments in TemperatureTimeSeriesView.js and useTemperatureTimeSeriesView.js does not follow the standard for multi line comments in javascript. [How to comment ](https://git.webug.se/Andras/BoundlessFlowCampus2K/wiki/React%2FJavaScript-coding-standards#comments). ``` javascript //This function uses the prebuilt api/temperature/all in middleware/tempService // if succsessfull it gives back an list of pares timestamp,temperature inside the data varible being returned // the array in the data varible will hold all recorded pairs in the db so it needs to be filtered if the entirerty is unwanted //[ // {Timestamp,temperature} // {Timestamp,temperature} // {Timestamp,temperature} //] ``` + Unnecessary change to code. ``` javascript const [data, setData] = useState([]); ``` + change to. ``` javascript const [data, setData] = useState(null); ``` + No unit tests for _**useTemperatureTimeSeriesView**_ + Unit test for this function is unnecessary be because the refactoring done in [Breakout of duplicate code in frontend/src/features #159](https://git.webug.se/Andras/BoundlessFlowCampus2K/issues/159) The central function _**useApi**_ already implements a unit test. + This implies that you don't need to implement a unit test but in future don't forget to write unit tests.
Sign in to join this conversation.
No milestone
No project
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Andras/BoundlessFlowCampus2K#12
No description provided.