[web] improving how suggestions are verified if they are installed

This commit is contained in:
Vinícius Moreira
2019-12-23 13:15:23 -03:00
parent c29b1a0252
commit 6984a34d25
2 changed files with 16 additions and 9 deletions

View File

@@ -64,6 +64,7 @@ updates:
- suggestions are now retrieved from [suggestions.txt](https://github.com/vinifmor/bauh-files/blob/master/snap/suggestions.txt) - suggestions are now retrieved from [suggestions.txt](https://github.com/vinifmor/bauh-files/blob/master/snap/suggestions.txt)
- Minor memory improvements - Minor memory improvements
### Fixes ### Fixes
- AUR: - AUR:
- an exception happens when retrieving matches from the cached AUR index - an exception happens when retrieving matches from the cached AUR index

View File

@@ -784,17 +784,23 @@ class WebApplicationManager(SoftwareManager):
suggestion_list.sort(key=lambda s: s.get('priority', 0), reverse=True) suggestion_list.sort(key=lambda s: s.get('priority', 0), reverse=True)
if filter_installed: if filter_installed:
installed = self.read_installed(disk_loader=None) installed = {self._strip_url_protocol(i.url) for i in self.read_installed(disk_loader=None).installed}
url_map = {self._strip_url_protocol(s['url']): idx for idx, s in enumerate(suggestion_list)} else:
installed = None
if installed.installed: res = []
for i in installed.installed:
s_url = self._strip_url_protocol(i.url)
if s_url in url_map:
suggestion_list.pop(url_map[s_url])
to_map = suggestion_list if limit <= 0 else suggestion_list[0:limit] for s in suggestion_list:
res = [self._map_suggestion(s) for s in to_map] if limit <= 0 or len(res) < limit:
if installed:
surl = self._strip_url_protocol(s['url'])
if surl in installed:
continue
res.append(self._map_suggestion(s))
else:
break
if not self.env_settings and self.env_thread: if not self.env_settings and self.env_thread:
self.env_thread.join() self.env_thread.join()