Skip to content
This repository has been archived by the owner on Mar 15, 2018. It is now read-only.

Commit

Permalink
bug 560686, Excluding versions we don't care about.
Browse files Browse the repository at this point in the history
  • Loading branch information
davedash committed May 11, 2010
1 parent 0483b78 commit 3af9a80
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion apps/amo/__init__.py
Expand Up @@ -155,7 +155,7 @@ class FIREFOX:
types = [ADDON_EXTENSION, ADDON_THEME, ADDON_DICT, ADDON_SEARCH,
ADDON_LPAPP, ADDON_PLUGIN, ADDON_PERSONA]
guid = '{ec8030f7-c20a-464f-9b0e-13a3a9e97384}'
min_display_version = 2.0
min_display_version = 3.0
# These versions were relabeled and should not be displayed.
exclude_versions = (3.1,)

Expand Down
6 changes: 5 additions & 1 deletion apps/search/client.py
Expand Up @@ -448,8 +448,12 @@ def query(self, term, limit=10, offset=0, **kwargs):
min_vers = [truncate(m['attrs']['min_ver'])
for m in result['matches']]
result = results[self.queries['max_ver']]

# 10**13-1 (a bunch of 9s) is a pseudo max_ver that is
# meaningless for faceted search.
max_vers = [truncate(m['attrs']['max_ver'])
for m in result['matches']]
for m in result['matches']
if m['attrs']['max_ver'] != 10 ** 13 - 1]
versions = list(set(min_vers + max_vers))
sorted(versions, reverse=True)
self.meta['versions'] = [v for v in versions
Expand Down
7 changes: 3 additions & 4 deletions apps/search/forms.py
Expand Up @@ -38,7 +38,7 @@

# These releases were so minor that we don't want to search for them.
skip_versions = collections.defaultdict(list)
skip_versions[amo.FIREFOX] = (tuplize(v) for v in amo.FIREFOX.exclude_versions)
skip_versions[amo.FIREFOX] = [tuplize(v) for v in amo.FIREFOX.exclude_versions]

min_version = collections.defaultdict(lambda: (0, 0))
min_version.update({
Expand All @@ -58,10 +58,9 @@ def get_app_versions():
app = amo.APP_IDS[app_id]
min_ver, skip = min_version[app], skip_versions[app]
versions = [(a.major, a.minor1) for a in versions]
# Find all the unique (major, minor) pairs.
groups = itertools.groupby(sorted(versions))
strings = ['%s.%s' % v for v, group in groups
strings = ['%s.%s' % v for v in sorted(set(versions))
if v >= min_ver and v not in skip]

rv[app_id] = [(s, s) for s in strings]
for app_id in amo.APP_IDS:
rv[app_id] += [(_('Any'), 'any')]
Expand Down
2 changes: 1 addition & 1 deletion apps/search/tests.py
Expand Up @@ -397,7 +397,7 @@ class TestSearchForm(test_utils.TestCase):
def test_get_app_versions(self):
actual = forms.get_app_versions()
expected = {
amo.FIREFOX.id: ['2.0', '3.0', '3.5', '3.6', '3.7'],
amo.FIREFOX.id: ['3.0', '3.5', '3.6', '3.7'],
amo.THUNDERBIRD.id: [],
amo.SUNBIRD.id: [],
amo.SEAMONKEY.id: [],
Expand Down
4 changes: 3 additions & 1 deletion apps/search/views.py
Expand Up @@ -35,6 +35,7 @@ def _get_versions(request, versions, version):
compats.append(c)
seen = {}
exclude = request.APP.__dict__.get('exclude_versions', [])
versions.sort(reverse=True)

for v in versions:
# v is a version_int so we can get the major and minor:
Expand All @@ -47,7 +48,7 @@ def _get_versions(request, versions, version):

seen[text] = 1

if v_float <= request.APP.min_display_version or v_float in exclude:
if v_float < request.APP.min_display_version or v_float in exclude:
continue

c = MenuItem()
Expand All @@ -57,6 +58,7 @@ def _get_versions(request, versions, version):
if c.text == version:
c.selected = True
compats.append(c)

return compats


Expand Down

0 comments on commit 3af9a80

Please sign in to comment.