Skip to content
This repository has been archived by the owner on Feb 29, 2020. It is now read-only.

Migration for old profiles #2990

Merged
merged 4 commits into from
Jul 28, 2017

Conversation

piatra
Copy link
Contributor

@piatra piatra commented Jul 27, 2017

Closes #2967

@coveralls
Copy link

Coverage Status

Coverage remained the same at 86.407% when pulling bbc2a4e on piatra:bug-2967-migration-for-old-profiles into 929fc6a on mozilla:master.

Copy link
Member

@Mardak Mardak left a comment

Choose a reason for hiding this comment

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

some nits and question about short-circuiting isMigrationMessageExpired

if (migrationLastShownDate < today) {
let profileAge = new ProfileAge(null, null);
Copy link
Member

Choose a reason for hiding this comment

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

This constructor works with no args. Remove the double null

if (migrationLastShownDate < today) {
let profileAge = new ProfileAge(null, null);
let profileCreationDate = await profileAge.created;
let daysSinceProfileCreation = (Date.now() - profileCreationDate) / MS_PER_DAY;
Copy link
Member

Choose a reason for hiding this comment

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

Any reason to do this only inside if (migrationLastShownDate < today) ? It seems like all the profile age stuff can be done at the beginning of isMigrationMessageExpired and just short circuit the rest of the method? It would also avoid setting the remaining/lastshown prefs below… unless that's desired to set?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason I had it like was to reduce the number of returns in the function. Makes it easier to reason (at least for me). But I don't feel strongly about it.

if (!alreadyExpired && this.isMigrationMessageExpired()) {
async expireIfNecessary(alreadyExpired) {
const isMigrationExpired = await this.isMigrationMessageExpired();
if (!alreadyExpired && isMigrationExpired) {
Copy link
Member

Choose a reason for hiding this comment

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

adding await in the same original line is well within 80 characters on the line:
if (!alreadyExpired && await this.isMigrationMessageExpired()) {

@piatra
Copy link
Contributor Author

piatra commented Jul 28, 2017

@Mardak updated & answered your question. Let me know if you still want me to make the change.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 86.407% when pulling ae89c04 on piatra:bug-2967-migration-for-old-profiles into 929fc6a on mozilla:master.

@Mardak
Copy link
Member

Mardak commented Jul 28, 2017

The code is doing unnecessary things and will be confusing to others why those changes are being done. E.g., "why are we checking and updating last shown date if profile age is independent of that?"

Move the profile age check and add a comment above that section to make it easier for you to reason.

@Mardak Mardak assigned piatra and unassigned Mardak Jul 28, 2017
@piatra piatra assigned Mardak and unassigned piatra Jul 28, 2017
@coveralls
Copy link

Coverage Status

Coverage remained the same at 86.407% when pulling 5b7b506 on piatra:bug-2967-migration-for-old-profiles into 929fc6a on mozilla:master.

@Mardak Mardak merged commit 2d43da4 into mozilla:master Jul 28, 2017
@as-pine-proxy
Copy link
Collaborator

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants