Browse Source

By default return only drivers for active releases

Active releases are configured in etc/default_data.json

Change-Id: I3757e291f773176598dce763b5b6cda8fcdbfad6
Ilya Shakhat 1 year ago
parent
commit
9726be8fc1
1 changed files with 9 additions and 1 deletions
  1. 9
    1
      driverlog/dashboard/api.py

+ 9
- 1
driverlog/dashboard/api.py View File

@@ -27,14 +27,22 @@ def get_drivers_internal(**params):
27 27
     drivers = vault.get_vault()['drivers_map']
28 28
     filtered_drivers = []
29 29
 
30
+    # when release_id is not set return only drivers from active releases
31
+    if not params.get('release_id'):
32
+        all_releases = vault.get_vault()['releases_map']
33
+        active_releases = ','.join(sorted(
34
+            r['id'].lower() for r in all_releases.values() if r.get('active')))
35
+        params['release_id'] = active_releases
36
+
30 37
     for driver in drivers.values():
31 38
         include = True
32 39
         for param, value in params.iteritems():
33 40
             value = value.lower()
34 41
             if param == 'release_id' and value:
42
+                query_releases = set(value.split(','))
35 43
                 found = False
36 44
                 for release in driver['releases_info']:
37
-                    if release['release_id'] == value:
45
+                    if release['release_id'] in query_releases:
38 46
                         found = True
39 47
                         break
40 48
 

Loading…
Cancel
Save