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: Send event startsAt and endsAt time in event timezone #3633

Merged
merged 4 commits into from
Nov 19, 2019

Conversation

prateekj117
Copy link
Member

Fixes #3632

Short description of what this resolves:

Send event timings in event timezone and render time correctly on event basic details page.

Checklist

  • I have read the Contribution & Best practices Guide.
  • My branch is up-to-date with the Upstream development branch.
  • The acceptance, integration, unit tests and linter pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

@auto-label auto-label bot added the fix label Nov 16, 2019
@prateekj117
Copy link
Member Author

@iamareebjamal Please review.

@@ -47,13 +47,13 @@ export const computedSegmentedLink = function(property) {
export const computedDateTimeSplit = function(property, segmentFormat, endProperty) {
return computed(property, {
get() {
return moment(this.get(property)).format(getFormat(segmentFormat));
return moment(this.get(property)).tz(this.timezone).format(getFormat(segmentFormat));
Copy link
Member

Choose a reason for hiding this comment

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

Will fail for everything except event

Copy link
Member

Choose a reason for hiding this comment

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

@prateekj117 Dont send the timezone with time, as we are already collecting timezone in seperate field. I dont think sending timezone with date & time would be mandatory.

Copy link
Member

Choose a reason for hiding this comment

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

It is mandatory. As I said, please read about moment and timezones and ISO 8601 format a bit more

Copy link
Member

Choose a reason for hiding this comment

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

@iamareebjamal So adding a if conditional should work in that case here.

Copy link
Member

Choose a reason for hiding this comment

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

Yes

@iamareebjamal
Copy link
Member

@prateekj117 Status?

@prateekj117
Copy link
Member Author

@iamareebjamal I am having an issue in case of startsAt and endsAt time in speakers and sessions. The page crashes when I try this.event.timezone in case of session and speakers.

@iamareebjamal
Copy link
Member

Just handle the case for event wizard right now and open an issue to handle others

@kushthedude
Copy link
Member

kushthedude commented Nov 18, 2019 via email

@prateekj117
Copy link
Member Author

@iamareebjamal Please review.

@prateekj117
Copy link
Member Author

@iamareebjamal Please review.

} else {
return moment(this.get(property)).format(getFormat(segmentFormat));
timezone = this.event.get('timezone');
Copy link
Member

Choose a reason for hiding this comment

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

This is worse than before

Copy link
Member

Choose a reason for hiding this comment

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

Idea is to write less code, not more

Copy link
Member

Choose a reason for hiding this comment

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

So, make this work in least code possible, please

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't want to assign a variable outside if as it may crash the page of the other model inside an if condition.
For example:

let timezone = this.timezone;
if(this.constuctor.modelName !== 'event') {
	timezone = this.event.get('timezone');
}

This may break in session-speakers page, as it will first search for this.timezone.

@iamareebjamal
Copy link
Member

Normally, I'd wait for you to figure out this so you learn and develop an insight of how to write concise code and not duplicate anything, but since this PR has already delayed the release a lot, this is what you should do:

    let momentDate = moment(this.get(property));
    if (this.constructor.modelName === 'event')
        momentDate = momentDate.tz(this.timezone)
    return momentDate.format(getFormat(segmentFormat));

@iamareebjamal
Copy link
Member

And as said previously, only handle event case as we don't know the effects of changing behaviours of sessions and tracks. And we don't have devs and time to test it out. They are not immediate bugs and fixing them may break the site even more. As discussed, they are planned for next release. Perfection is the killer of pragmatism

} else {
timezone = this.event.get('timezone');
}
oldDate = moment(this.get(property), segmentFormat === 'date' ? FORM_DATE_FORMAT : FORM_TIME_FORMAT).tz(timezone, true);
Copy link
Member

Choose a reason for hiding this comment

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

Somehow you managed to increase the duplication even more from previous iteration

Comment on lines 68 to 66
timezone = '';
if (this.constructor.modelName === 'event') {
timezone = this.timezone;
} else {
timezone = this.event.get('timezone');
}
Copy link
Member

Choose a reason for hiding this comment

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

I don't even understand why this block of code is repeated here in this if statement.

@niranjan94
Copy link
Member

Codacy Here is an overview of what got changed by this pull request:

Complexity increasing per file
==============================
- app/utils/computed-helpers.js  2
         

See the complete overview on Codacy

@prateekj117
Copy link
Member Author

@iamareebjamal Please review.

@iamareebjamal iamareebjamal merged commit f3fbb16 into fossasia:development Nov 19, 2019
@kushthedude
Copy link
Member

@prateekj117 Are you sure the time is being sent into event timezone after this ?

@kushthedude
Copy link
Member

I tried it and time was stored in my browser timezone only .

@iamareebjamal
Copy link
Member

Yes, I tested it personally

@iamareebjamal
Copy link
Member

time was stored in my browser timezone only

How did you test that?

@kushthedude
Copy link
Member

kushthedude commented Nov 20, 2019 via email

@iamareebjamal
Copy link
Member

And what did you find? Please tell completely. What you did, which timezone you selected, what time did you input and what did you find in DB, and what you expected to find in the DB instead.

Steps of Reproduction, Expected, Actual.

@kushthedude
Copy link
Member

kushthedude commented Nov 20, 2019 via email

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.

Send event timing in event timezone to server
4 participants