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 export and version comparison #43

Merged
merged 1 commit into from
Nov 30, 2016
Merged

Fix export and version comparison #43

merged 1 commit into from
Nov 30, 2016

Conversation

skjnldsv
Copy link
Member

@skjnldsv skjnldsv commented Nov 29, 2016

We can have the export back! 🎉

fix #39
@irgendwie @brjhaverkamp

@skjnldsv skjnldsv added 3. to review Waiting for reviews bug Something isn't working labels Nov 29, 2016

function compareVersion(version1, version2) {
var result=false;
for(var i=0;i<(Math.max(version1.length, version2.length));i++) {
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't it be Math.min? You don't want to access an index greater than the string length, do you? :-)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes we do.
If we're comparing 9.0.0 and 9.0.0.1 we still need to check the last value. But I need to add a safety conversion if NaN or undefined.

var result=false;
for(var i=0;i<(Math.max(version1.length, version2.length));i++) {
if(Number(version1[i])<Number(version2[i])) {
result=true;
Copy link
Member

Choose a reason for hiding this comment

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

simple return true;?

result=true;
break;
}
if(version1[i]!==version2[i]) {
Copy link
Member

Choose a reason for hiding this comment

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

if(version1[i] !== version2[i]) {
   return false; // version 2 is higher
}

Otherwise: do nothing and continue with the next digit.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I snapped this code from somewhere and didn't even realised how poorly it was written...
Please forgive me! 😢

Signed-off-by: John Molakvoæ (skjnldsv) <[email protected]>
@skjnldsv skjnldsv force-pushed the fix-version-compare branch from f67ff10 to 4b05574 Compare November 29, 2016 21:00
@skjnldsv
Copy link
Member Author

@ChristophWurst Fixed and rewritten 😊

@ChristophWurst
Copy link
Member

nice! code looks good now

@ChristophWurst
Copy link
Member

you could add a unit test for this function 😉

@skjnldsv
Copy link
Member Author

skjnldsv commented Nov 29, 2016

I could I could... 😂

@ChristophWurst
Copy link
Member

merge? 🙈 🙊 🙉

@skjnldsv
Copy link
Member Author

Since it's a function inside a controller, I don't think I can do tests directly :)
Soooo, let's merge? 😄

@ChristophWurst
Copy link
Member

Since it's a function inside a controller, I don't think I can do tests directly :)

You could export but prefix it with an underscore ;-)

@skjnldsv
Copy link
Member Author

But is it really necessary? :D
Let's not over-complicate things!

@skjnldsv skjnldsv merged commit 26305a5 into master Nov 30, 2016
@skjnldsv skjnldsv deleted the fix-version-compare branch November 30, 2016 16:42
@brjhaverkamp
Copy link

Thanks for fixing this. I'm still trying to figure out how this version comparison will solve the export of single address groups. But I am eager to give it a try. Will this be released alongside NC 11? Or how can I try this best?

@skjnldsv skjnldsv added 4. to release Ready to be released and/or waiting for tests to finish and removed 2. developing Work in progress 3. to review Waiting for reviews labels Dec 29, 2016
@skjnldsv skjnldsv modified the milestone: 1.5.3 Dec 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4. to release Ready to be released and/or waiting for tests to finish bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Currently not possible to download group of contacts.
3 participants