Skip to content

Commit 8869ee9

Browse files
hellcpjwise
authored andcommitted
Make sure that the supported platforms are reflected in the api responses
1 parent 12420cf commit 8869ee9

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

appstore/api.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,14 @@
66

77
from sqlalchemy.orm.exc import NoResultFound
88

9-
from appstore.utils import jsonify_app, asset_fallback, generate_image_url, get_access_token
9+
from appstore.utils import jsonify_app, asset_fallback, generate_image_url, get_access_token, HARDWARE_SUPPORT
1010
from .models import App, Collection, HomeBanners, Category, db, Release
1111
from .settings import config
1212

1313
parent_app = None
1414
api = Blueprint('api', __name__)
1515
CORS(api)
1616

17-
HARDWARE_SUPPORT = {
18-
'aplite': ['aplite'],
19-
'basalt': ['basalt', 'aplite'],
20-
'chalk': ['chalk'],
21-
'diorite': ['diorite', 'aplite'],
22-
'emery': ['emery', 'diorite', 'basalt', 'aplite'],
23-
'flint': ['flint', 'diorite', 'aplite']
24-
}
25-
2617

2718
def generate_app_response(results, sort_override=None):
2819
target_hw = request.args.get('hardware', 'basalt')

appstore/locker.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from .settings import config
99
from .models import App, LockerEntry, db
1010
from .api import api
11-
from .utils import get_uid, generate_pbw_url, asset_fallback, generate_image_url, plat_dimensions, jsonify_companion, get_access_token
11+
from .utils import get_uid, generate_pbw_url, asset_fallback, generate_image_url, plat_dimensions, jsonify_companion, get_access_token, HARDWARE_SUPPORT
1212

1313

1414
def jsonify_locker_app(entry):
@@ -60,7 +60,7 @@ def jsonify_locker_app(entry):
6060
},
6161
**{
6262
x: {
63-
'supported': x in (release.compatibility if release and release.compatibility else ['aplite', 'basalt', 'diorite', 'emery', 'flint']),
63+
'supported': bool(set(HARDWARE_SUPPORT[x]) & set(release.compatibility if release and release.compatibility else ['aplite', 'basalt', 'diorite', 'emery', 'flint'])),
6464
'firmware': {'major': 3}
6565
} for x in ['aplite', 'basalt', 'chalk', 'diorite', 'emery', 'flint']
6666
},

appstore/utils.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@
1616
from .settings import config
1717
from appstore.models import App, AssetCollection, CompanionApp
1818

19+
HARDWARE_SUPPORT = {
20+
'aplite': ['aplite'],
21+
'basalt': ['basalt', 'aplite'],
22+
'chalk': ['chalk'],
23+
'diorite': ['diorite', 'aplite'],
24+
'emery': ['emery', 'diorite', 'basalt', 'aplite'],
25+
'flint': ['flint', 'diorite', 'aplite']
26+
}
1927

2028
parent_app = None
2129

@@ -86,7 +94,7 @@ def _jsonify_common(app: App, target_hw: str) -> dict:
8694
},
8795
**{
8896
x: {
89-
'supported': x in (release.compatibility if release and release.compatibility else ['aplite', 'basalt', 'diorite', 'emery', 'flint']),
97+
'supported': bool(set(HARDWARE_SUPPORT[x]) & set(release.compatibility if release and release.compatibility else ['aplite', 'basalt', 'diorite', 'emery', 'flint'])),
9098
'firmware': {'major': 3}
9199
} for x in ['aplite', 'basalt', 'chalk', 'diorite', 'emery', 'flint']
92100
},
@@ -170,7 +178,7 @@ def algolia_app(app: App) -> dict:
170178

171179
tags = [app.type]
172180
if release:
173-
tags.extend(release.compatibility or [])
181+
tags.extend(set(item for platform in (release.compatibility or []) for item in HARDWARE_SUPPORT[platform]))
174182
else:
175183
tags.extend(['aplite', 'basalt', 'chalk', 'diorite', 'emery', 'flint'])
176184
tags.append('companion-app')

0 commit comments

Comments
 (0)