Skip to content

Feature sort descending#53

Merged
luisremis merged 2 commits intodevelopfrom
feature_sort_descending
Nov 29, 2018
Merged

Feature sort descending#53
luisremis merged 2 commits intodevelopfrom
feature_sort_descending

Conversation

@luisremis
Copy link
Copy Markdown
Contributor

Solve #52

Copy link
Copy Markdown
Contributor

@vishakha041 vishakha041 left a comment

Choose a reason for hiding this comment

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

The API change is important to fix. Rest looks good.

"sum": { "type": "string" },
"limit": { "$ref": "#/definitions/positiveInt" },
"sort": { "type": "string" },
"descending": { "type": "boolean" },
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there no way to make this part of the sort command? Descend keyword by itself doesn't make sense. It is useful only in the sort context.

Copy link
Copy Markdown
Contributor Author

@luisremis luisremis Nov 27, 2018

Choose a reason for hiding this comment

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

yep, I was divided about this as well. Adding a "sort block" that has a prop for sorting and the option of using order = "ascending" or order = "descending", but this will break backward compatibility of all the old queries that uses sort.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Will it still be possible to have a default so you can only specify the key ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok.
The Options are:

  1. (breaks backward compatibility)
    "sort": {
    "key": "property_used_for_sorting",
    "order": "ascending" // or "descending", with the default to one of them.
    }

  2. As it is implemented, just adds the order as an extra element of the results block, that will only be used if "sort" is also specified.

  3. We can change "descending" = [True, False] to "order" = ["ascending", "descending"]. I like this option more, which does not break compatibility, it just adds more flexibility.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Is there no way to support either a value or a block, as:
"sort" : "<key>"
and
"sort" : { "key" : "<key>", "order" : "descending" }

If not, I'm inclined to go with the backward compatible option, with the addition
"sort-order" = ["ascending","descending"]

self.assertEqual(response[0]["AddEntity"]["status"], 0)
self.assertEqual(response[1]["AddEntity"]["status"], 0)

def test_FindAscending(self):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be called FindDescending? Or FindWithSortOrder :)

philiplantz
philiplantz previously approved these changes Nov 29, 2018
"sum": { "type": "string" },
"limit": { "$ref": "#/definitions/positiveInt" },
"sort": { "type": "string" },
"descending": { "type": "boolean" },
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Is there no way to support either a value or a block, as:
"sort" : "<key>"
and
"sort" : { "key" : "<key>", "order" : "descending" }

If not, I'm inclined to go with the backward compatible option, with the addition
"sort-order" = ["ascending","descending"]

@luisremis
Copy link
Copy Markdown
Contributor Author

I like what you propose @philiplantz. For some reason I have a memory that we cannot do that.
Let me try it harder.

@vishakha041
Copy link
Copy Markdown
Contributor

I like the option Philip has mentioned. Otherwise option 1 from Luis. It will break backward compatibility but will open the way for allowing sort on multiple keys and so on in the near future.

@luisremis luisremis force-pushed the feature_sort_descending branch 2 times, most recently from 115e3fe to 1a36838 Compare November 29, 2018 19:07
@luisremis
Copy link
Copy Markdown
Contributor Author

Sorting multiple keys is independent for of the having a sort block or not. I will go with option 2 to avoid braking compatibility for now, and change the keywords following Philip suggestion which is much nicer.

@luisremis
Copy link
Copy Markdown
Contributor Author

Good news, after trying many different schema configurations, it is indeed possible to have:
"sort" : ""
and
"sort" : { "key" : "", "order" : "descending" }
Will push this, since this looks nice and avoid braking backward compatibility.

Now I wonder what was the memory both @philiplantz and I have, and if we can make some other checks better. But at least now we are sure we can.

@luisremis luisremis merged commit 34efac9 into develop Nov 29, 2018
@vishakha041
Copy link
Copy Markdown
Contributor

For multiple keys we will need a sort block but never mind for now. Its good that the other option worked. Cool.

@mwahle
Copy link
Copy Markdown

mwahle commented Dec 10, 2018

When can we have this in the master branch? Or even released?

@luisremis
Copy link
Copy Markdown
Contributor Author

Our "develop" branch is like a master branch. We only commit to master with releases.
In any case, we are working on a new release that will have this change (and everything pushed into the "develop" branch) in the next 10-20 days.

@luisremis luisremis deleted the feature_sort_descending branch January 30, 2019 18:11
Ragaad pushed a commit to Ragaad/vdms that referenced this pull request Jun 16, 2022
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