Skip to content

Conversation

@Tenacs
Copy link

@Tenacs Tenacs commented Jul 19, 2024

Removes 'center' time setting and standardizes date time format in SettingSlice. Cleaned up TimeFilter and date and time usage throughout.
Depends on GridProtectionAlliance/gpa-gemstone#321

@Tenacs Tenacs force-pushed the Updated-TimeFilter-to-use-gemstone-version branch from e3adc0e to 258ae81 Compare July 19, 2024 19:32
@Tenacs Tenacs requested a review from clackner-gpa July 19, 2024 19:33
@collins-self collins-self force-pushed the Updated-TimeFilter-to-use-gemstone-version branch from 8f1966b to 2b90980 Compare September 20, 2024 13:17
@gcsantos-gpa gcsantos-gpa self-requested a review January 27, 2025 17:39
Copy link
Contributor

@gcsantos-gpa gcsantos-gpa left a comment

Choose a reason for hiding this comment

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

I think you are being a little over-zealous on what formating constants you replace. I don't think you can use one global constant everywhere since different components expect different formats and different formats make sense in different places. I left some comments on some places where I saw this done but I know for sure I didn't comment on everything. Can you go through and only replace where it makes sense for the setting? What is the setting meant to unifiy? The server format we get back from the controllers? That we send to the controllers? Clarification on this would assist me in reviewing this PR.

setEventMarkers(data.map(datum => {
const meterID = props.Plot.Channels.find(channel => channel.MeterKey === datum["Meter Key"]).MeterID;
return { value: moment.utc(datum.Time, eventFormat).valueOf(), meterID: meterID, eventID: datum["EventID"]}
return { value: moment.utc(datum.Time, dateTimeFormat).valueOf(), meterID: meterID, eventID: datum["EventID"] }
Copy link
Contributor

Choose a reason for hiding this comment

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

Event format is different than date time

Comment on lines +124 to +128
const startMoment: moment.Moment = moment.utc(props.TimeFilter.start, dateTimeFormat);
const endMoment: moment.Moment = moment.utc(props.TimeFilter.end, dateTimeFormat);

const startTime: number = startMoment.valueOf();
const endTime: number = endMoment.valueOf();
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const startMoment: moment.Moment = moment.utc(props.TimeFilter.start, dateTimeFormat);
const endMoment: moment.Moment = moment.utc(props.TimeFilter.end, dateTimeFormat);
const startTime: number = startMoment.valueOf();
const endTime: number = endMoment.valueOf();
const startTime: number = moment.utc(props.TimeFilter.start, dateTimeFormat).valueOf();
const endTime: number = moment.utc(props.TimeFilter.end, dateTimeFormat).valueOf();

No need to have this assignment, it makes it a little more hard to read in my opinion.

const [trendMarkers, setTrendMarkers] = React.useState<TrendSearch.IMarker[]>([]);
const [sortField, setSortField] = React.useState<string>('MeterName');
const [ascending, setAscending] = React.useState<boolean>(true);
const momentFormat = "DD HH:mm:ss.SSS";
Copy link
Contributor

Choose a reason for hiding this comment

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

This replacement doesn't work, moment format isn't the same as datetimeformat from settings.

/>
<ReportTimeFilter filter={props.Plot.TimeFilter} showQuickSelect={false}
setFilter={newFilter => props.SetPlot({ ...props.Plot, TimeFilter: newFilter })} />
<TimeFilter filter={props.Plot.TimeFilter/* convertTimeFilter(props.Plot.TimeFilter) */} showQuickSelect={false}
Copy link
Contributor

Choose a reason for hiding this comment

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

What's with this commented out code?


React.useEffect(() => {
let range = "";
const startMoment = moment(timeFilter.start); // These default to the date+time format
Copy link
Contributor

Choose a reason for hiding this comment

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

Please don't use default moment formats, it can lead to unexpected bugs. Be explicit

{
Value: 'center',
Label: 'Center Date/Time and Window',
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we dropping support for centered time window format?

Choose a reason for hiding this comment

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

I believe that was the main update I was doing to this branch. Christoph said to do away with it, and just handle its conversion to the back end. (If it's still using that format in the back end)

@collins-self collins-self force-pushed the Updated-TimeFilter-to-use-gemstone-version branch from 96f0333 to ab73e5d Compare January 29, 2025 15:25
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