Closed flyingtof closed 6 months ago
Tell me if it's ok for you. I would like to stabilize this code because the more I modify it, the more the code for the next PR is less easy to rebase.
Tell me if it's ok for you. I would like to stabilize this code because the more I modify it, the more the code for the next PR is less easy to rebase.
Yep the best is to pause worked based on this until it gets merged. It doesn't have to be perfect to be merged but we should at least have a clear view about what is ok and what need to be updated later (i.e. TODOs).
I should be able to review tomorrow.
Thanks a lot!
@vicb do you have any idea why the tests fails on optimizer lib? I can not reproduce the problem locally (a nicer way to say WOMM ;-) )
@vicb do you have any idea why the tests fails on optimizer lib? I can not reproduce the problem locally (a nicer way to say WOMM ;-) )
issue created https://github.com/vicb/flyxc/issues/209
Replied to your comments. Hope you will find it OK.
I have a proposal for improvements when there is not enough points in the track to optimize. Can you have a look here: https://github.com/vicb/flyxc/blob/refactor/improve-optimizer-when-not-enough-points/libs/optimizer/src/lib/optimizer.ts ?
I have a proposal for improvements when there is not enough points in the track to optimize. Can you have a look here: https://github.com/vicb/flyxc/blob/refactor/improve-optimizer-when-not-enough-points/libs/optimizer/src/lib/optimizer.ts ?
- It ensures that when the track has not enough points, we send to the solver exactly the minimal number of point.
the added points are close to the original points:
- when 2 points: add 3 points near the first point
- when 3 points: add 1 point near the first point and 1 point near the second point
- when 4 points: add 1 point near the first point
- it keep track of the proximity (a mapping of indices) of the added points with the original points so that retrieving the index in the original track does not require computations.
Is that getIndicesInScoringTrack
?
It's not clear to me what this functions does. It's not to comment what the fn does but when the code is tricky, it's good to comment how.
Notes:
getIndicesInScoringTrack
) should be avoided when possible. First because of readability and also because a fn object will have to be created each tilme the enclosing function is executed. If you really can not inline the fn you can move it before the enclosing function - or to a separate file if it's generic enough.The SolverTrack
class:
- Nested function (i.e.
getIndicesInScoringTrack
) should be avoided when possible. First because of readability and also because a fn object will have to be created each tilme the enclosing function is executed. If you really can not inline the fn you can move it before the enclosing function - or to a separate file if it's generic enough.But
getIndicesInScoringTrack
is not a nested function, it's a member function of the SolverTrack class
Oops copy/paste error, I mean pushInResult
Oops copy/paste error, I mean
pushInResult
Ok I pushed this improvement
Can you npm i and try again?
On Fri, May 31, 2024, 16:44 Christophe TARET @.***> wrote:
@.**** commented on this pull request.
In libs/optimizer/src/lib/optimizer.ts https://github.com/vicb/flyxc/pull/203#discussion_r1622530965:
@@ -231,7 +231,7 @@ const circuitMapping = { };
function toCircuitType(code: string): CircuitType {
- const type = circuitMapping[code];
- const type = circuitMapping[code as 'od' | 'tri' | 'fai' | 'oar'];
error occurred when running npm run dev
— Reply to this email directly, view it on GitHub https://github.com/vicb/flyxc/pull/203#discussion_r1622530965, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAB4X4SATWRBPZUBNRCC7E3ZFCEDJAVCNFSM6AAAAABIH3EPECVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDAOJRGAZTGNBRGY . You are receiving this because you were mentioned.Message ID: @.***>
Can you npm i and try again?
ok. It works now.
Latest TS release has improved inference a lot See https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-4.html
On Fri, May 31, 2024 at 5:17 PM Christophe TARET @.***> wrote:
Can you npm i and try again? … <#m-2175490786768393315> On Fri, May 31, 2024, 16:44 Christophe TARET @.*> wrote: @.* commented on this pull request. ------------------------------ In libs/optimizer/src/lib/optimizer.ts <#203 (comment) https://github.com/vicb/flyxc/pull/203#discussion_r1622530965>: > @@ -231,7 +231,7 @@ const circuitMapping = { }; function toCircuitType(code: string): CircuitType { - const type = circuitMapping[code]; + const type = circuitMapping[code as 'od' | 'tri' | 'fai' | 'oar']; error occurred when running npm run dev — Reply to this email directly, view it on GitHub <#203 (comment) https://github.com/vicb/flyxc/pull/203#discussion_r1622530965>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAB4X4SATWRBPZUBNRCC7E3ZFCEDJAVCNFSM6AAAAABIH3EPECVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDAOJRGAZTGNBRGY . You are receiving this because you were mentioned.Message ID: @*.***>
ok. It works now.
— Reply to this email directly, view it on GitHub https://github.com/vicb/flyxc/pull/203#issuecomment-2142484604, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAB4X4XMAZMUYPEXYUFG3BDZFCIABAVCNFSM6AAAAABIH3EPECVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNBSGQ4DINRQGQ . You are receiving this because you were mentioned.Message ID: @.***>
The issue with the hack for 3d is:
So I'm -1 on using this commit.
The correct fix is for igc-xc-score
to move away from using the collections
package which pollutes the global namespace. See mmomtchev/igc-xc-score#234.
The issue with the hack for 3d is:
- it breaks the routing
- it doesn't fix the root cause and the bug can still hit back in a future update on other part of the code
So I'm -1 on using this commit. The correct fix is for
igc-xc-score
to move away from using thecollections
package which pollutes the global namespace. See mmomtchev/igc-xc-score#234.
I agree that this hack, as almost every hack, has drawbacks. It permit to have something that works for the user vs an application that can't ne used. I agree that it introduce a technical debt. I agree that it is a temporary solution, but is easy to revert when root cause disappear. But when switching to 3D mode, why does the application loads a library that
- it has already loaded somewhere
- it actually even does not need in 3D mode
Switching to 3D mode does not reload igc-xc-score
(I guess it is what you mean). The correct way to think about it is that it doesn't unload it when switching to 3D. What flyxc does in this case is that it removes the 2D map and replaces it with the component holding the 3D map.
However when igc-xc-score
was first loaded (in 2D mode) then the collections
dep polluted the global namespace by changing builtin types prototype (see the issue on igc-xc-score
).
It turns out that the changes done by collections
are not compatible with the ArcGIS JS SDK used for the 3D map.
What your hack does is that it fully reload the page (instead of just swapping the 2D component for the 3D component). In this case the igc-xc-score
lib is not loaded as it's a dep of the 2D only.
- require modifications in that library to work in flyxc context. Does it means that the problem may occur again when using other libraries?
It's a problem with any library polluting the global namespace.
Having a transitive dep on collections
might cause other issue that we are not aware today and might cause issues later when any dep is updated.
collections
is used only for Map
and SortedSet
in igc-xc-score
, it should be easy to swap them for an implementation that does not pollute the global namespace.
[!IMPORTANT]
Review skipped
More than 25% of the files skipped due to max files limit. The review is being skipped to prevent a low-quality review.
95 files out of 152 files are above the max files limit of 50. Please upgrade to Pro plan to get higher limits.
You can disable this status message by setting the
reviews.review_status
tofalse
in the CodeRabbit configuration file.
The recent changes encompass a wide range of updates, including refactoring scoring logic, introducing new methods and types, updating configurations, and enhancing documentation. Key updates include modifications to the PathElement
and PlannerElement
classes, restructuring league definitions, and updating scoring rules. Additionally, various configuration files and dependencies have been updated, and new testing and optimization functionalities have been introduced in the optimizer
library.
File/Directory | Change Summary |
---|---|
CONTRIBUTING.md |
Introduced guidelines for contributing to the project. |
apps/fxc-front/src/app/components/2d/path-element.ts |
Refactored scoring logic, introduced computeScore method, updated imports. |
apps/fxc-front/src/app/components/2d/planner-element.ts |
Updated property access from this.score.distance to this.score.distanceM . |
apps/fxc-front/src/app/components/ui/about-modal.ts |
Added a new GitHub link for flyingtof . |
apps/fxc-front/src/app/components/ui/main-menu.ts |
Updated handleUpload method to use HTMLInputElement type and renamed variables for clarity. |
apps/fxc-front/src/app/components/ui/pref-modal.ts |
Updated imports and usage to include LEAGUE_CODES . |
apps/fxc-front/src/app/logic/score/league/leagues.ts |
Restructured league definitions, introduced LeagueCode type, added getScoringRuleName function. |
apps/fxc-front/src/app/logic/score/scorer.ts |
Updated Score class properties and simplified scoreTriangles function. |
apps/fxc-front/src/app/redux/planner-slice.ts |
Updated league property type from string to LeagueCode . |
apps/fxc-front/vite.config.ts |
Added a new global object {} in the define section. |
docker/.env |
Added COMPOSE_PROJECT_NAME variable set to flyxc . |
docker/docker-compose.yml |
Defined services for launching Docker images with specific configurations. |
libs/optimizer/.babelrc |
Introduced Babel preset configuration using @nx/js/babel . |
libs/optimizer/.eslintrc.json |
Introduced ESLint configurations for TypeScript, JavaScript, and JSON files. |
libs/optimizer/README.md |
Described the optimizer library and its optimize function. |
libs/optimizer/jest.config.ts |
Configured Jest for testing the optimizer library. |
libs/optimizer/project.json |
Defined linting and testing configurations using Nx for the optimizer project. |
libs/optimizer/src/index.ts |
Introduced new exports for optimizer functions and types. |
libs/optimizer/src/lib/optimizer.spec.ts |
Added test cases for scoring rules in the optimizer module. |
libs/optimizer/src/lib/optimizer.ts |
Introduced functionality for optimizing flight tracks and defined related interfaces and functions. |
libs/optimizer/src/lib/scoring-rules.ts |
Introduced scoring rules for various competitions and exported related types and functions. |
libs/optimizer/src/lib/utils/create-segments.ts |
Added createSegments function to generate a track with segments. |
libs/optimizer/src/lib/utils/merge-tracks.ts |
Added mergeTracks function to merge multiple tracks. |
libs/optimizer/tsconfig.json |
Updated to extend a base configuration and reference additional configuration files. |
libs/optimizer/tsconfig.lib.json |
Introduced configuration settings for TypeScript compilation. |
libs/optimizer/tsconfig.spec.json |
Introduced configuration settings for TypeScript compilation specific to testing. |
nx.json |
Added new TypeScript compilation configuration with caching enabled. |
package.json |
Updated various dependencies and added new ones. |
tsconfig.base.json |
Added new path mapping for @flyxc/optimizer to libs/optimizer/src/index.ts . |
In the code where logic thrives,
Paths and leagues take new drives.
Optimizer's wings now soar,
Scores refined, rules galore.
Docker's ship set to sail,
Contributions without fail.
CodeRabbit cheers, with joy so bright,
For changes made, a coder's delight! 🐇✨
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
I have pushed more changes to the PR.
igc-xc-score
is now invoked from a worker so that we can workaround the global namespace issue more easily. We still need to drop the barrel file (index.ts
) because importing the enum from there in fxc-front
still causes the issue. That should be easy to do.
I have also added more info to the SocringResult
.
Hopefully we can merge this tomorrow!
@coderabbitai generate interesting stats about this repository and render them as a table.
[!TIP] For best results, initiate chat on the files or code changes.
@vicb, here are some interesting statistics about the repository:
Metric | Value |
---|---|
Number of Authors | 7 |
Total Commits | 678 |
Total Lines of Code | 138,915 |
Number of Open Issues | 30 |
These metrics provide a snapshot of the repository's current state, including contributions, codebase size, and ongoing issues.
Summary by CodeRabbit
New Features
flyingtof
in the About modal.computeScore
method for optimized route scoring.optimize
function in the optimizer library for enhanced performance.Bug Fixes
PlannerElement
fromthis.score.distance
tothis.score.distanceM
.Refactor
PathElement
for better readability and efficiency.handleUpload
method for clarity.Documentation
CONTRIBUTING.md
.Chores
package.json
to their latest versions.