Skip to content
This repository was archived by the owner on Oct 21, 2022. It is now read-only.

Commit ffd53aa

Browse files
authored
Backend for getting dependencies need to update (#106)
1 parent b872ee6 commit ffd53aa

3 files changed

Lines changed: 46 additions & 35 deletions

File tree

dashboard/dashboard_builder.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ def __init__(
6666
self.checker = checker
6767
self.store = store
6868
self.deprecated_deps = self.get_deprecated_deps()
69+
self.dependency_to_update = self.get_dependencies_needed_to_update()
6970

7071
def _is_py_version_incompatible(self, result):
7172
if result.status == compatibility_store.Status.INSTALL_ERROR:
@@ -105,7 +106,7 @@ def has_issues(self, p: package.Package) -> bool:
105106

106107
return False
107108

108-
def get_deprecated_deps(self) -> Mapping[str, Tuple[List, bool]]:
109+
def get_deprecated_deps(self) -> Mapping[str, List]:
109110
"""
110111
Returns if there are deprecated dependencies for a
111112
given package as well as the list of deprecated deps for a package.
@@ -116,20 +117,29 @@ def get_deprecated_deps(self) -> Mapping[str, Tuple[List, bool]]:
116117

117118
results = {}
118119
for item in deprecated_deps:
119-
has_deprecated_deps = False
120120
(pkg_name, deps) = item[0]
121-
if deps:
122-
has_deprecated_deps = True
123-
results[pkg_name] = (deps, has_deprecated_deps)
121+
results[pkg_name] = deps
124122

125123
return results
126124

127125
def has_deprecated_deps(self, p: package.Package) -> bool:
128-
return self.deprecated_deps[p.install_name][1]
126+
return bool(self.deprecated_deps[p.install_name])
127+
128+
def get_dependencies_needed_to_update(self) -> Mapping[str, List]:
129+
"""
130+
Returns a dict of package names together with the dependencies that
131+
they need to update.
132+
"""
133+
highlighter = dependency_highlighter.DependencyHighlighter(
134+
py_version='3', checker=self.checker, store=self.store)
135+
result = highlighter.check_packages(
136+
packages=configs.PKG_LIST, max_workers=10)
137+
return result
129138

130139
def needs_update(self, p: package.Package) -> bool:
131-
# Returns True if the given package needs update.
132-
pass
140+
"""Returns whether the dependencies for a given package needs to
141+
update."""
142+
return bool(self.dependency_to_update[p.install_name])
133143

134144
def get_statistics(self, packages):
135145
"""Get the total number of packages that has issues."""

dashboard/grid-template.html

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -116,38 +116,39 @@
116116
{% for row_package in packages %}
117117
{% set row = loop.index0 %}
118118
<tr>
119-
<td><font face="verdana">{{ row_package.friendly_name }}</font>{% if results.has_issues(row_package) %}
119+
<td><font face="verdana">{{ row_package.friendly_name }}</font>
120+
{% if results.has_issues(row_package) %}
120121
{% set issues = results.deprecated_deps[row_package.friendly_name][0] %}
121122
<img class="warning-img" class="dialog" onclick="showIssues('{{ row_package.friendly_name|safe }}', '{{ issues|replace('\'', '\\\'')|safe }}')" src="https://www.gstatic.com/images/icons/material/system/1x/warning_amber_18dp.png">
122123
<div id="{{ row_package.friendly_name }}" class="dialog" title="{{ row_package.friendly_name }}"></div>
123-
{% endif %}</td>
124-
{% for col_package in packages %}
125-
{% set column = loop.index0 %}
126-
{% if column <= row %}
127-
{% set result = results.get_result(row_package, col_package) %}
128-
{% set cellName = row | string + '-' + column | string %}
129-
{% set bgColorName = result.status_type | lower %}
130-
{% if result.pairwise_compatibility_check | length > 0 %}
131-
{% set pairwise_status = result.pairwise_compatibility_check[0].status %}
132-
{% set pairwise_details = result.pairwise_compatibility_check[0].details %}
133124
{% endif %}
134-
{% if result.self_compatibility_check | length > 0 %}
135-
{% set self_1_status = result.self_compatibility_check[0].status %}
136-
{% set self_1_details = result.self_compatibility_check[0].details %}
137-
{% if result.self_compatibility_check | length > 1 %}
138-
{% set self_2_status = result.self_compatibility_check[1].status %}
139-
{% set self_2_details = result.self_compatibility_check[1].details %}
125+
</td>
126+
{% for col_package in packages %}
127+
{% set column = loop.index0 %}
128+
{% if column <= row %}
129+
{% set result = results.get_result(row_package, col_package) %}
130+
{% set cellName = row | string + '-' + column | string %}
131+
{% set bgColorName = result.status_type | lower %}
132+
{% if result.pairwise_compatibility_check | length > 0 %}
133+
{% set pairwise_status = result.pairwise_compatibility_check[0].status %}
134+
{% set pairwise_details = result.pairwise_compatibility_check[0].details %}
140135
{% endif %}
136+
{% if result.self_compatibility_check | length > 0 %}
137+
{% set self_1_status = result.self_compatibility_check[0].status %}
138+
{% set self_1_details = result.self_compatibility_check[0].details %}
139+
{% if result.self_compatibility_check | length > 1 %}
140+
{% set self_2_status = result.self_compatibility_check[1].status %}
141+
{% set self_2_details = result.self_compatibility_check[1].details %}
142+
{% endif %}
143+
{% endif %}
144+
<td class="{{ bgColorName }}" onclick="showDialog(
145+
'{{ cellName|safe }}', '{{ result.status_type|safe }}', '{{ self_1_status|safe }}', '{{ self_2_status|safe }}','{{ pairwise_status|safe }}', '{{ self_1_details|replace('\n', ' ')|safe}}', '{{ self_2_details|replace('\n', ' ')|safe}}', '{{ pairwise_details|replace('\n', ' ')|safe }}')">
146+
<div id="{{ cellName }}" class="dialog" title="{{ row_package.friendly_name }} and {{ col_package.friendly_name }}">
147+
</div>
148+
</td>
149+
{% else %}
150+
<td><pre></pre></td>
141151
{% endif %}
142-
143-
<td class="{{ bgColorName }}" onclick="showDialog(
144-
'{{ cellName|safe }}', '{{ result.status_type|safe }}', '{{ self_1_status|safe }}', '{{ self_2_status|safe }}','{{ pairwise_status|safe }}', '{{ self_1_details|replace('\n', ' ')|safe}}', '{{ self_2_details|replace('\n', ' ')|safe}}', '{{ pairwise_details|replace('\n', ' ')|safe }}')">
145-
<div id="{{ cellName }}" class="dialog" title="{{ row_package.friendly_name }} and {{ col_package.friendly_name }}">
146-
</div>
147-
</td>
148-
{% else %}
149-
<td><pre></pre></td>
150-
{% endif %}
151152
{% endfor %}
152153
</tr>
153154
{% endfor %}

dashboard/main-template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ <h2 class="number">{{ statistics[3] }}</h2>
145145
<div class="container">
146146
<div class="row">
147147
<div class="col-md-12">
148-
<h3 class="title-5 m-b-35">statistics</h3>
148+
<h3 class="title-5 m-b-35">Statistics</h3>
149149
</div>
150150
</div>
151151
<div class="row">

0 commit comments

Comments
 (0)