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

fix(moon): changed to type specific return values and added moon test #123

Merged
merged 7 commits into from
Apr 19, 2024

Conversation

godind
Copy link
Contributor

@godind godind commented Nov 26, 2023

Fixes #122

Previous implementation retuned all moon path values as strings. Adjusted return types to correct types and added tests.

Copy link
Member

@tkurki tkurki left a comment

Choose a reason for hiding this comment

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

The moon values are numbers when coming from suncalc at https://github.com/SignalK/signalk-derived-data/blob/master/calcs/moon.js#L25. In this PR this plugin converts them first to strings and then back to numbers, in different parts of the code, that makes very little sense.

calcs/moon.js Outdated Show resolved Hide resolved
@godind
Copy link
Contributor Author

godind commented Dec 8, 2023

You are most probably right! To be honest I was just trying to fix the output to get cleaner types and did not look deeper. But I added some tests! It's just a quick patch.

Do you need more work done or is it good for now?

@tkurki
Copy link
Member

tkurki commented Dec 8, 2023

Could you please fix the issues I pointed out.

@godind
Copy link
Contributor Author

godind commented Dec 8, 2023

No problem. I'll look at it.

@godind godind requested a review from tkurki December 10, 2023 05:17
Copy link
Member

@tkurki tkurki left a comment

Choose a reason for hiding this comment

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

There are 2 failing tests on my machine:

       Sets environment.moon.* information such as phase, rise, and set[0] works:

      AssertionError: expected [ { …(2) }, { …(2) }, { …(2) }, …(5) ] to have the same json representation as [ { …(2) }, { …(2) }, { …(2) }, …(5) ]
      + expected - actual

           "value": 1.6
         }
         {
           "path": "environment.moon.times.rise"
      -    "value": "2017-04-15T02:59:40.750Z"
      +    "value": "2017-04-16T03:52:46.109Z"
         }
         {
           "path": "environment.moon.times.set"
      -    "value": "2017-04-15T13:26:01.692Z"
      +    "value": "2017-04-15T13:25:54.314Z"
         }
         {
           "path": "environment.moon.times.alwaysUp"
           "value": false

@godind
Copy link
Contributor Author

godind commented Dec 10, 2023

I'll check this out. I dont understand why the date changes every time in tests since it provides static input coordinates and date time.

Could it be that while running the tests, if the server is playing stream file, that it overrides the static test data?

@godind
Copy link
Contributor Author

godind commented Dec 12, 2023

I've fix the test issue, removed unnecessary variables, set default as undefined instead of ''. See if this is acceptable.

Thanks!

@godind godind requested a review from tkurki December 12, 2023 03:59
@tkurki
Copy link
Member

tkurki commented Dec 12, 2023

There is no server involved in running the tests. I have no idea why the value would change, but the same tests still fail on my machine. Just remove the offending ones?

@godind
Copy link
Contributor Author

godind commented Dec 14, 2023

It should work fine. Looks good on my end.

derived data converts
    ✓ Magnetic Course Over Ground[0] works
    ✓ Magnetic Variation[0] works
    ✓ Magnetic Variation[1] works
    ✓ Sets environment.moon.* information such as phase, rise, and set[0] works
    ✓ propulsion.port.slip (propulsion.port.transmission.gearRatio, propulsion.port.drive.propeller.pitch)[0] works
    ✓ propulsion.port.slip (propulsion.port.transmission.gearRatio, propulsion.port.drive.propeller.pitch)[1] works
  6 passing (10ms)

@tkurki
Copy link
Member

tkurki commented Jan 4, 2024

It seems that the output varies for some reason, the tests fail on my machine

         {
           "path": "environment.moon.times.rise"
      -    "value": "2017-04-15T02:59:40.750Z"
      +    "value": "2017-04-16T03:52:46.109Z"
         }
         {
           "path": "environment.moon.times.set"
      -    "value": "2017-04-15T13:26:01.692Z"
      +    "value": "2017-04-15T13:25:54.314Z"
         }

Why don't you just remove the offending tests where the output varies for some reason? This PR does not change how the value is calculated, so this is a sidetrack.

Unless you want to really dig into what happens and fix things for all.

As long as the test fails I won't be merging this.

Copy link
Contributor Author

@godind godind left a comment

Choose a reason for hiding this comment

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

Done!

@tkurki tkurki added the fix label Jan 21, 2024
@tkurki
Copy link
Member

tkurki commented Jan 21, 2024

The test is failing, because the output contains properties not in the expected block. You would have spotted that if you had ran the tests.

@godind
Copy link
Contributor Author

godind commented Jan 23, 2024

I did not. I have a new machine and did not have complete setup so I just deleted the tests. That's what being out of time does... I'll get to it.

@tkurki
Copy link
Member

tkurki commented Mar 1, 2024

Let's get this finished?

Copy link
Contributor Author

@godind godind left a comment

Choose a reason for hiding this comment

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

Removed ofending tests.

Copy link
Contributor Author

@godind godind left a comment

Choose a reason for hiding this comment

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

Removed offending tests.

@godind
Copy link
Contributor Author

godind commented Apr 17, 2024

Do I still need to fix something? I don't see it if so...

Thanks

@tkurki tkurki merged commit 9c129d3 into SignalK:master Apr 19, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Type Specific Path Values to Moon
2 participants