Skip to content

Commit

Permalink
code review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
JerrySentry committed Dec 5, 2024
1 parent fe3e247 commit 70113c1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions shared/bundle_analysis/comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,13 @@ def size_changes(self) -> List[RouteChange]:
If a route exists on head but not base that is considered "added" and +100% percentage delta
Otherwise it is considered "changed" and percentage delta = (diff_size / base_size) * 100
"""
base_sizes = self.base_report.get_size()
head_sizes = self.head_report.get_size()
base_sizes = self.base_report.get_sizes()
head_sizes = self.head_report.get_sizes()

all_routes, results = base_sizes.keys() | head_sizes.keys(), []
for route_name in all_routes:
# Added new route
if route_name not in base_sizes:
if route_name not in base_sizes or base_sizes[route_name] == 0:
results.append(
RouteChange(
route_name=route_name,
Expand Down
4 changes: 2 additions & 2 deletions shared/bundle_analysis/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,13 @@ def __init__(self, db_path: str, data: Dict[str, List[AssetReport]]):
self.db_path = db_path
self.data = data

def get_size(self) -> Dict[str, int]:
def get_sizes(self) -> Dict[str, int]:
results = {}
for route, asset_reports in self.data.items():
results[route] = sum([asset.size for asset in asset_reports])
return results

def get_size_by_route(self, route: str) -> Optional[int]:
def get_size(self, route: str) -> Optional[int]:
if route not in self.data:
return None
return sum([asset.size for asset in self.data[route]])
Expand Down
12 changes: 6 additions & 6 deletions tests/unit/bundle_analysis/test_bundle_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1041,16 +1041,16 @@ def test_bundle_report_route_report_with_dynamic_imports():

route_report = bundle_report.full_route_report()

assert route_report.get_size() == {
assert route_report.get_sizes() == {
"/sverdle/about": 2111,
"/sverdle/careers": 2100,
"/sverdle/faq": 2110,
"/sverdle/users": 2111,
}
assert route_report.get_size_by_route("/sverdle/fake") is None
assert route_report.get_size_by_route("/sverdle/about") == 2111
assert route_report.get_size_by_route("/sverdle/careers") == 2100
assert route_report.get_size_by_route("/sverdle/faq") == 2110
assert route_report.get_size_by_route("/sverdle/users") == 2111
assert route_report.get_size("/sverdle/fake") is None
assert route_report.get_size("/sverdle/about") == 2111
assert route_report.get_size("/sverdle/careers") == 2100
assert route_report.get_size("/sverdle/faq") == 2110
assert route_report.get_size("/sverdle/users") == 2111
finally:
report.cleanup()

0 comments on commit 70113c1

Please sign in to comment.