Skip to content

Conversation

@minhtriet359
Copy link

@minhtriet359 minhtriet359 commented Aug 6, 2025

Description

Finished implementing the UI changes required for the time-varying conversion feature (required backend changes are also included in this PR).

Fixes #896

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.

Limitations

(Describe any issues that remain or work that should still be done.)

PRINCESANCHEZ and others added 30 commits July 23, 2025 11:06
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 @minhtriet359, @evan-carey & @PRINCESANCHEZ for the updates. I'm sorry this took so long as I figured out what to do and my attention was taken elsewhere. I've made a few new comments and some from before are still not resolved. I tried to resolve everything that I think was complete. If you are willing to either address the comment or say it will not be done by any of you then that would be great. I can then resolve all I think are fine and figure out if the PR can be merged. I appreciate any efforts after you have graduated. Please let me know if anything is not clear or I can help.

I also should have said that there are now merge conflicts.

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 @PRINCESANCHEZ for the update. I have now reviewed the updated code and tried to test it more systematically now that it is generally working. I've made around 10 new comments and a similar number of unresolved comments remain. At this point would it be possible to put a comment on each one (done, unsure about, do not want to do, ....) so they can be resolved in some way.

There are also merge conflicts that need careful resolution. Please let me know if you want me to try to handle them.

I welcome any thoughts or questions. Also let me know if I can help in any way. This is getting fairly close.

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

Copy link
Member

Choose a reason for hiding this comment

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

If I create a new conversion and then try to delete it, I see error message both in the web console and the terminal where I started OED. It has:

web-1 | [ERROR@2025-09-10T14:19:55.585+00:00] Unhandled Promise Rejection: Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
web-1 | Stacktrace:
web-1 | Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
web-1 | at new NodeError (node:internal/errors:405:5)
web-1 | at ServerResponse.setHeader (node:_http_outgoing:648:11)
web-1 | at ServerResponse.header (/usr/src/app/node_modules/express/lib/response.js:795:10)
web-1 | at ServerResponse.send (/usr/src/app/node_modules/express/lib/response.js:175:12)
web-1 | at success (/usr/src/app/src/server/routes/response.js:16:3)
web-1 | at /usr/src/app/src/server/routes/conversions.js:199:3
web-1 | at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
web-1 |
web-1 | (node:162) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 14)

The delete does not seem to happen (even though it is a success notification). I have not tried to figure out why.

}

if (segment.endTime !== 'infinity' && next) {
const endMatches = moment.utc(segment.endTime, 'YYYY-MM-DD HH:mm:ss').isSame(moment.utc(next.startTime));
Copy link
Member

@huss huss Sep 10, 2025

Choose a reason for hiding this comment

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

If the end time of the edited segment must equal the start time of the next segment then it cannot be changed. If this is enforced then editing does not make sense. I think what is supposed to happen is that if you change the end time of the edited segment then the start time of the next segment must be changed to match that time. I believe this is what src/server/models/ConversionSegment.js does. However, the next segment's end time must be after the new start time. Effectively, the edited segment's end time must be before the next segment's end time. I think this is the desired check.

The same idea applies above for editing the start time.

I'm noting that I want to check if the start and end time of a segment can be edited once this is resolved.

Choose a reason for hiding this comment

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

I updated the logic so that editing a segment’s end or start time now also updates the neighboring segment accordingly. Added validation checks to enforce that the new end time is after the start, and the new start time is before the end

Copy link
Member

Choose a reason for hiding this comment

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

I'm getting server/DB errors when I violate the rule rather than client notices. Do you see this?

Choose a reason for hiding this comment

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

I was unable to reproduce this. When I enter invalid or overlapping start/end times and click save, no request is sent in the network tab, and the validation error shows in the modal.

Copy link
Member

Choose a reason for hiding this comment

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

We should discuss this to figure out what I am seeing as I saw it again.

@huss
Copy link
Member

huss commented Sep 11, 2025

I forgot to sweep all previous non-GitHub conversation records to make sure everything was resolved. Here are the few items I found that were not:

  • src/client/app/components/conversion/EditConversionSegmentModalComponent.tsx does not disable the save if no changes. (resolved)
  • When you edit an overall conversion there is no toast msg if successful or not. (resolved)
  • Changes in segments (split, delete, edit slope/intercept/pattern) will require a redo of cik. That issue is not yet being seen since that code is not yet in place for time-varying. However, the logic is needed. It would be easiest to do on every change but this process does take some time. Thus, it should use similar logic to src/client/app/components/unit/UnitsDetailComponent.tsx to show bouncing balls if RefreshingReadings is true. Note src/client/app/components/conversion/EditConversionModalComponent.tsx should also do the bouncing balls but it did and does not. This is a nontrivial change so we can discuss if it will be done now or made into an issue.

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 @PRINCESANCHEZ for quickly making updates to address my recent comments. I've updated a couple of comments and made a few new ones to consider. I have not yet looked at the ones with issues you are encountering.

I would also like to know if anyone on the team plans to address the remaining unresolved comments or if OED needs to find others to do this? Any thoughts or comments would be appreciated.

}

if (segment.endTime !== 'infinity' && next) {
const endMatches = moment.utc(segment.endTime, 'YYYY-MM-DD HH:mm:ss').isSame(moment.utc(next.startTime));
Copy link
Member

Choose a reason for hiding this comment

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

I'm getting server/DB errors when I violate the rule rather than client notices. Do you see this?

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 @PRINCESANCHEZ for addressing more comments. I've made a few small comments to consider. I also noted it might be good to discuss the one error I am seeing but you are not.

I still want to understand the remaining unresolved items to figure out how to finalize this PR. Any insights would be appreciated.

},
originalStartTime: previous.startTime,
originalEndTime: previous.endTime
}).unwrap();
Copy link
Member

Choose a reason for hiding this comment

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

OED uses .then in the current code so I think that should be followed. Applies below too.

Choose a reason for hiding this comment

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

Updated to use .then/.catch for consistency

}

if (segment.endTime !== 'infinity' && next) {
const endMatches = moment.utc(segment.endTime, 'YYYY-MM-DD HH:mm:ss').isSame(moment.utc(next.startTime));
Copy link
Member

Choose a reason for hiding this comment

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

We should discuss this to figure out what I am seeing as I saw it again.

<td>{segment.startTime} to {segment.endTime}</td>
<td>{(segment.weekPatternsId ?? -99) === -99 ? segment.slope : ''}</td>
<td>{(segment.weekPatternsId ?? -99) === -99 ? segment.intercept : ''}</td>
<td>{weekPatterns.find(wp => wp.id === segment.weekPatternsId)?.name ?? 'No Pattern'}</td>
Copy link
Member

Choose a reason for hiding this comment

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

I just noticed that this is not translated. All the drop down menus for this do translate it.

Choose a reason for hiding this comment

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

updated to use translation string

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.

6 participants