-
-
Notifications
You must be signed in to change notification settings - Fork 1
Pass image scale info on treemap element data model if available #524
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,25 @@ | ||
| import os | ||
|
|
||
| from launchpad.size.models.common import FileInfo | ||
| from launchpad.size.models.treemap import TreemapElement | ||
| from launchpad.size.models.treemap import TreemapElement, TreemapElementMisc | ||
| from launchpad.size.treemap.treemap_element_builder import TreemapElementBuilder | ||
| from launchpad.utils.file_utils import to_nearest_block_size | ||
|
|
||
|
|
||
| class DefaultFileElementBuilder(TreemapElementBuilder): | ||
| def build_element(self, file_info: FileInfo, display_name: str) -> TreemapElement: | ||
| size = to_nearest_block_size(file_info.size, self.filesystem_block_size) | ||
|
|
||
| misc = None | ||
| if file_info.scale is not None: | ||
| misc = TreemapElementMisc(scale=file_info.scale) | ||
|
|
||
| return TreemapElement( | ||
| name=display_name, | ||
| size=size, | ||
| type=file_info.treemap_type, | ||
| path=file_info.path, | ||
| is_dir=False, | ||
| children=[self.build_element(child, os.path.basename(child.path)) for child in file_info.children], | ||
| misc=misc, | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,6 +42,11 @@ export enum TreemapType { | |
| UNMAPPED = "unmapped", | ||
| } | ||
|
|
||
| export interface TreemapElementMisc { | ||
| /** Scale factor for asset catalog images (1, 2, 3) */ | ||
| scale?: number; | ||
| } | ||
|
|
||
| export interface TreemapElement { | ||
| /** Display name of the element */ | ||
| name: string; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might need to separate out these FE changes first as the deploys could get out of sync, especially if we need to make more fields optional
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think in this case we're OK since the only stuff we're adding is optional on both ends, so even if one of them deploys before the other, it shouldn't matter
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (oh and fwiw this is in launchpad, but i know what you mean) |
||
|
|
@@ -53,6 +58,8 @@ export interface TreemapElement { | |
| path?: string; | ||
| /** Whether this element represents a directory */ | ||
| is_dir: boolean; | ||
| /** Optional miscellaneous data for this element */ | ||
| misc?: TreemapElementMisc; | ||
| /** Child elements */ | ||
| children: TreemapElement[]; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rbro112 this is the fix to not have
path: nullormisc: nullincluded in the treemap data when passed to the frontendThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, I think we might need support in the backend/frontend to ensure we parse these all properly, can you just do an E2E test to make sure downstream size processing related code either responds gracefully to missing fields or uncover any potential errors?