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

Update readingsCompareMeterQuantity.js #1413

Open
wants to merge 5 commits into
base: development
Choose a base branch
from

Conversation

alecdog04
Copy link

Description

Authors: Alec Gonzales(alecdog04), Mia Escobar(miaescobar1), AungKhant Min (Aung-Khant-Min1211)

Wrote test case C6, verifying the compare readings API for an electric meter. The shift period is 28 days, ensuring the API can handle long-period shifts. This test also validates timestamp alignment for 15-minute reading intervals and proper unit conversion from Electric_Utility to kWh. This test case was completed as part of the CTI open source internship cohert.

Partly Addresses #issue #962, Test Case C6

Type of change

(Check the ones that apply by placing an "x" instead of the space in the [ ] so it becomes [x])

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

Checklist

(Note what you have done by placing an "x" instead of the space in the [ ] so it becomes [x]. It is hoped you do all of them.)

  • 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.

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 @alecdog04, @miaescobar1 & @Aung-Khant-Min1211 for their first contribution to OED. I have made several comments that should be addressed. It may help to try local testing of this file on your machine as described in the design doc for testing (step 9). Please let me know if you need anything.

@@ -85,7 +85,19 @@ mocha.describe('readings API', () => {
expectCompareToEqualExpected(res, expected);
});

// Add C6 here
mocha.it('C6: 28 day shift end 2022-10-31 17:00:00 for 15 minute reading intervals and quantity units & kWh as kWh', async () => {
Copy link
Member

Choose a reason for hiding this comment

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

The text in the design doc is slightly different with "28 day shift end 2022-10-31 17:12:34 (partial hour) for 15 minute reading intervals and quantity units & kWh as kWh". Could this be updated to match?

Choose a reason for hiding this comment

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

Will do, thank you for your prompt feedback!

.query({
curr_start: '2022-10-09 00:00:00',
curr_end: '2022-10-31 17:00:00',
shift: 'P28D',
Copy link
Member

Choose a reason for hiding this comment

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

The specified time was '2022-10-31 17:12:34'.

Choose a reason for hiding this comment

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

Will do, thank you for your prompt feedback!

const unitId = await getUnitId('kWh');
const expected = [108269.924822581, 108889.847659507];
const res = await chai.request(app).get('/api/compareReadings/meters/${METER_ID}')
.query({
Copy link
Member

Choose a reason for hiding this comment

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

The quotes need to be backquotes so the METER_ID is treated as a variable, e.g., `/api/compareReadings/meters/${METER_ID}`

Choose a reason for hiding this comment

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

Will do, thank you for your prompt feedback!

curr_end: '2022-10-31 17:00:00',
shift: 'P28D',
graphicUnitID:unitId
});
Copy link
Member

Choose a reason for hiding this comment

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

The "d" in graphicUnitID must be lowercase.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for the feedback! We'll get to work making those changes and testing on our local machine.

@alecdog04
Copy link
Author

Thanks to @alecdog04, @miaescobar1 & @Aung-Khant-Min1211 for their first contribution to OED. I have made several comments that should be addressed. It may help to try local testing of this file on your machine as described in the design doc for testing (step 9). Please let me know if you need anything.

@alecdog04 alecdog04 closed this Dec 18, 2024
@alecdog04 alecdog04 reopened this Dec 18, 2024
@alecdog04
Copy link
Author

My bad I misclicked on closing the pull request

@alecdog04
Copy link
Author

@huss I'm following step 9 to test our code locally but I'm getting this error relating to a database
databaseError
I've even forked the original OED code and received the same error (pictured)

miaescobar1 added a commit to alecdog04/OED that referenced this pull request Dec 18, 2024
@huss
Copy link
Member

huss commented Dec 18, 2024

@huss I'm following step 9 to test our code locally but I'm getting this error relating to a database

@alecdog04 I cannot be sure but let me ask the following:

  • I wanted to be sure that OED was running and you were in a Linux terminal in the OED web Docker container. It looks as if it is a root terminal so I think yes but want to be sure.
  • The file path in the first command seems to have the slashes going in a Windows direction and not a Linux one. The second one seems okay. I'm assuming the question relates to the second one but wanted to be sure.
  • Are you running under Codespaces? The file explorer has that listed so I thought you might. I don't know of anyone who has gotten that to work so if you have then let me know. It might be the source of the issue.
  • If you are working on Windows, did you clone OED on the Linux partition or the Windows (C:, normally)? People have had issues if they cloned on Windows instead of the Linux partition.

Let me know if any of this helps and once I know more information I'll try to help more (if needed).

@miaescobar1
Copy link

Hi @huss, just letting you I added another commit with the changes that you requested.

I'll double-check with Alec about your comments about the error message and will get back to you as soon as possible. Thank you again!

@alecdog04
Copy link
Author

@huss I'm following step 9 to test our code locally but I'm getting this error relating to a database

@alecdog04 I cannot be sure but let me ask the following:

* I wanted to be sure that OED was running and you were in a Linux terminal in the OED web Docker container. It looks as if it is a root terminal so I think yes but want to be sure.

* The file path in the first command seems to have the slashes going in a Windows direction and not a Linux one. The second one seems okay. I'm assuming the question relates to the second one but wanted to be sure.

* Are you running under Codespaces? The file explorer has that listed so I thought you might. I don't know of anyone who has gotten that to work so if you have then let me know. It might be the source of the issue.

* If you are working on Windows, did you clone OED on the Linux partition or the Windows (C:, normally)? People have had issues if they cloned on Windows instead of the Linux partition.

Let me know if any of this helps and once I know more information I'll try to help more (if needed).
@huss
Alright so this time I ran it in a Linux partition and recieved a similar error.
linuxPartition

vladoleksiyenko and others added 4 commits December 18, 2024 06:03
… errors, indicated that OED docker database container must be running
I forgot to mention this in my previous comments so I added a final output
statement to tell where the backup was placed.
@huss
Copy link
Member

huss commented Dec 18, 2024

@alecdog04 This seems to be a blocking of the Postgres port (5432). The terminal seems to be a regular on and not one opened on the OED web Docker container. I'm wondering if that is the issue.

@miaescobar1
Copy link

Hi @huss, I tested the readingsCompareMeterQuantity.js file in a codespace of Alec's forked repository. It seems to work as expected.

Screenshot 2024-12-18 at 2 16 02 PM
Screenshot 2024-12-18 at 2 19 29 PM

@huss
Copy link
Member

huss commented Dec 18, 2024

@miaescobar1 Great. If you want me to look at something else then let me know. Otherwise I'll consider this resolved and plan to review this PR in the near future.

If you could provide how you ran OED and the tests in Codespaces that would be great. I'd like to try it and post directions for other developers. Thanks.

@miaescobar1
Copy link

@huss Great, thanks so much again!

Running the tests in codespaces

(It’s already explained well here, under "Rapid testing of a one or a few test(s)")

  1. Access forked repository of OED (or receive writer permissions / email invite from a teammate to access their forked repository)
  2. Create a codespace in said forked repository
  3. Use git status to get pathway of file(s) modified (Or you can hover over the file and copy the pathway directly)
  4. npm run testsome <pathway of file that you modified>
  5. Testing should run as expected

Note: There was no need to run OED locally to run the tests. You can do this all directly in Git codespaces.

Running OED locally using MacOs terminal

  1. Download Visual Studio Code (VS Code)
  2. Download docker (the container platform for OED)
  3. Clone the repository using VS Code (Struggled with this because it was not explicitly explained in the OED developer documentation. Only explained how to clone the repository solely using Github, under section "Github" Steps 3-4)
    1. Open VS Code
    2. Command + Shift + P (in search bar at the top)
    3. Select Git clone
    4. Enter link to OED Github repository
    5. Choose where you would like the cloned repository to be on your machine
  4. Open docker
  5. Open MacOs terminal
    1. cd <pathway where you cloned the repository locally>
    2. docker-compose up
  6. Open docker
    1. Enter Port of OED container into Safari (or another web browser)
  7. OED should run successfully in your web browser
  8. Use docker compose down in MacOs terminal to terminate OED once you finish

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.

4 participants