updated getItemsBySections and getItemsByAudiencesAndSections to #1

Open
wants to merge 216 commits into
from

Conversation

Projects
None yet
4 participants
@lukebrannon

At the Cioppino sprint there was talk to have knowledge base documentation sort by version number. I've updated the getItemsBySections and getItemsByAudiencesAndSections methods to sort the generated dictionary values for 'items' by version number.

smcmahon added some commits Jan 7, 2009

dukebody and others added some commits Dec 28, 2010

updated getItemsBySections and getItemsByAudiencesAndSections to
sort items key using getVersions and then reverse the items list
value.
@@ -112,8 +112,9 @@ def getItemsBySections(self, **kwargs):
# sort inside sections
for j in sections:
- j['items'].sort(_sectionCmp)
-
+ #j['items'].sort(_sectionCmp)

This comment has been minimized.

Show comment Hide comment
@davisagli

davisagli Apr 13, 2012

Member

Please just delete things instead of commenting them out; we can find out what used to be there from version control if we need to. (See http://nedbatchelder.com/text/deleting-code.html for discussion.)

@davisagli

davisagli Apr 13, 2012

Member

Please just delete things instead of commenting them out; we can find out what used to be there from version control if we need to. (See http://nedbatchelder.com/text/deleting-code.html for discussion.)

- j['items'].sort(_sectionCmp)
-
+ #j['items'].sort(_sectionCmp)
+ j['items'].sort(key=lambda x: x.getVersions)

This comment has been minimized.

Show comment Hide comment
@davisagli

davisagli Apr 13, 2012

Member

You can do:

from operator import attrgetter

And then do:

j['items'].sort(key=attrgetter('getVersions'))

which reads a little nicer.

@davisagli

davisagli Apr 13, 2012

Member

You can do:

from operator import attrgetter

And then do:

j['items'].sort(key=attrgetter('getVersions'))

which reads a little nicer.

-
+ #j['items'].sort(_sectionCmp)
+ j['items'].sort(key=lambda x: x.getVersions)
+ j['items'].reverse()

This comment has been minimized.

Show comment Hide comment
@davisagli

davisagli Apr 13, 2012

Member

You can also just pass reverse=True when you call sort()

@davisagli

davisagli Apr 13, 2012

Member

You can also just pass reverse=True when you call sort()

@davisagli

This comment has been minimized.

Show comment Hide comment
@davisagli

davisagli Apr 13, 2012

Member

Aside from my comments on particular lines... this approach assumes that getVersions has the newest versions first. Is that a valid assumption?

Member

davisagli commented Apr 13, 2012

Aside from my comments on particular lines... this approach assumes that getVersions has the newest versions first. Is that a valid assumption?

@lukebrannon

This comment has been minimized.

Show comment Hide comment
@lukebrannon

lukebrannon Apr 19, 2012

Thanks for the comments. I've addressed the notes and I believe we should take the newest version from getVersions for the sort. I'll take a look at that and resubmit.

Thanks for the comments. I've addressed the notes and I believe we should take the newest version from getVersions for the sort. I'll take a look at that and resubmit.

created get_latest_version function to return highest version for
sorting in getItemsBySections and getItemsByAudiencesAndSections
@mauritsvanrees

This comment has been minimized.

Show comment Hide comment
@mauritsvanrees

mauritsvanrees Sep 13, 2013

Member

If someone still cares about this, please create a new pull request. Something seems to have gone wrong, as this pull request currently has 216 commits, including some from five years ago.

Member

mauritsvanrees commented Sep 13, 2013

If someone still cares about this, please create a new pull request. Something seems to have gone wrong, as this pull request currently has 216 commits, including some from five years ago.

@tcurvelo

This comment has been minimized.

Show comment Hide comment
@tcurvelo

tcurvelo Sep 18, 2013

Member

tumblr_ml3vybk9yz1qfqp8jo1_500

Member

tcurvelo commented Sep 18, 2013

tumblr_ml3vybk9yz1qfqp8jo1_500

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment