{"action":"opened","issue":{"url":"https://api.github.com/repos/mvantellingen/localshop/issues/176","repository_url":"https://api.github.com/repos/mvantellingen/localshop","labels_url":"https://api.github.com/repos/mvantellingen/localshop/issues/176/labels{/name}","comments_url":"https://api.github.com/repos/mvantellingen/localshop/issues/176/comments","events_url":"https://api.github.com/repos/mvantellingen/localshop/issues/176/events","html_url":"https://github.com/mvantellingen/localshop/issues/176","id":166063810,"number":176,"title":"The order of packages_release may be wrong","user":{"login":"Pjack","id":1013484,"avatar_url":"https://avatars.githubusercontent.com/u/1013484?v=3","gravatar_id":"","url":"https://api.github.com/users/Pjack","html_url":"https://github.com/Pjack","followers_url":"https://api.github.com/users/Pjack/followers","following_url":"https://api.github.com/users/Pjack/following{/other_user}","gists_url":"https://api.github.com/users/Pjack/gists{/gist_id}","starred_url":"https://api.github.com/users/Pjack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Pjack/subscriptions","organizations_url":"https://api.github.com/users/Pjack/orgs","repos_url":"https://api.github.com/users/Pjack/repos","events_url":"https://api.github.com/users/Pjack/events{/privacy}","received_events_url":"https://api.github.com/users/Pjack/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-07-18T10:28:46Z","updated_at":"2016-07-18T10:28:46Z","closed_at":null,"body":"There is a search function in pip that will return matched package and the latest version number.\r\nHowever, it may return wrong version number in some case when the backend is localshop.\r\n\r\nIf we have 3 versions of packages, ie:  0.8.0,  0.9.0,   0.10.0\r\nIt will return 0.9.0 instead of 0.10.0 which is wrong.\r\n\r\nThe sort function in sql database is sorted by \"string\" , but not human readable order.\r\nI have two possible solution here. We can modify apps/packages/xmlrpc.py\r\n\r\n1.  Let the search function return the package with the latest-date.\r\n\r\ndef search(spec, operator='and'):\r\n    ...\r\n    for package in packages:\r\n        release = package.last_release\r\n\r\n2. Parse the version string by parse_version provided by pkg_resources.\r\n\r\nfrom pkg_resources import parse_version\r\ndef search(spec, operator='and'):\r\n    ...\r\n    version_lambda = lambda x: parse_version(x.version)\r\n    for package in packages:\r\n        release = sorted(package.releases.all(), key=version_lambda, reverse=True)[0]\r\n\r\n"}}
{"actor":{"display_login":"Pjack"}}