Skip to content
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

Package update: dont upload unmodified files aka dedupe #2080

Merged
merged 10 commits into from
Mar 1, 2021
Merged

Conversation

nl0
Copy link
Member

@nl0 nl0 commented Feb 21, 2021

No description provided.

@codecov
Copy link

codecov bot commented Feb 24, 2021

Codecov Report

Merging #2080 (d8b95c7) into master (99ece37) will decrease coverage by 0.07%.
The diff coverage is 39.84%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2080      +/-   ##
==========================================
- Coverage   46.29%   46.22%   -0.08%     
==========================================
  Files         408      408              
  Lines       19475    19510      +35     
  Branches     2258     2266       +8     
==========================================
+ Hits         9016     9018       +2     
- Misses       9449     9514      +65     
+ Partials     1010      978      -32     
Flag Coverage Δ
api-python 89.36% <ø> (ø)
catalog 15.75% <39.84%> (-0.04%) ⬇️
lambda 92.60% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...talog/app/containers/Bucket/PackageDialog/index.ts 0.00% <0.00%> (ø)
...alog/app/containers/Bucket/PackageUpdateDialog.tsx 0.00% <0.00%> (ø)
.../containers/Bucket/PackageDialog/PackageDialog.tsx 19.08% <17.80%> (ø)
catalog/app/utils/workflows.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 99ece37...d8b95c7. Read the comment docs.

@nl0 nl0 force-pushed the pkg-update-dedupe branch 2 times, most recently from 19a18dd to 5d67c76 Compare February 24, 2021 19:16
@nl0 nl0 force-pushed the pkg-update-dedupe branch from 39987d6 to 3acb365 Compare February 26, 2021 16:42
@nl0 nl0 marked this pull request as ready for review February 26, 2021 16:42
@nl0 nl0 requested review from fiskus and akarve February 26, 2021 16:42
@nl0 nl0 changed the title Package update: dont upload unmodified files WIP Package update: dont upload unmodified files aka dedupe Feb 26, 2021
Copy link
Member

@fiskus fiskus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked the feature in the browser, didn't spot any bug. There is a control "Undo changes ←" when all files are the same (hashed), but I think, it's ok.

Code is good, just advice: I think that the better strategy for typescript migration is converting small modules to typescript instead of large ones. If you don't have small modules, you can create them by splitting large into small ones. Also, as you are using .js imports you can create intermediate types (PackageDialog/types.ts). Otherwise, you are forced to use any and typecasting.
In short: having a small number of tiny modules completely converted to typescript is better, than large ones converted partially with any and typecasting.

catalog/app/containers/Bucket/PackageDialog/FilesInput.tsx Outdated Show resolved Hide resolved
catalog/app/containers/Bucket/PackageDialog/FilesInput.tsx Outdated Show resolved Hide resolved
const existingEntries = Object.entries(existing).map(
([path, { isDir, size, hash }]) => {
if (path in deleted) {
return { type: 'deleted' as const, path, size }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'deleted' as const

I think you should use Enum for type

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why? const strings make more sense imo, and you can also use them as keys (like, for classes or some matches), and it's properly type-checked anyways

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use enum as object key too

enum State {
  Deleted,
}

entry[State.Deleted]

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, but it wont help with classes (or classes will have some number keys, which doesnt seem nice). we could use string enums, but they require more boilerplate, so, in the end, i dont see what we gain from that

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Profit in letting typescript already know type without manual casting as const

catalog/app/containers/Bucket/PackageUpdateDialog.tsx Outdated Show resolved Hide resolved
Success: (v: { name: string; hash: string }) => v,
},
)

// eslint-disable-next-line @typescript-eslint/no-redeclare
type DialogState = tagged.InstanceOf<typeof DialogState>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get it. Why not just pick another name?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

first, in this case it's getting imported together with the value, so no need for another import;
second, it's like an instance of a class, like, you usually dont create smth like type SomeClassInstance and use it like (x: SomeClassInstance) => whatever, you just use it directly like (x: SomeClass) => whatever;
so it's just a convenience / developer ergonomics thing

@nl0
Copy link
Member Author

nl0 commented Mar 1, 2021

@fiskus

There is a control "Undo changes ←" when all files are the same (hashed), but I think, it's ok.

well, it requires some extra logic for comparing trees (maybe overriding final-form's equality check, not sure), and i guess it doesnt worth it right now

I think that the better strategy for typescript migration is converting small modules to typescript instead of large ones

I agree on that, but I decided to migrate the modules I was modifying and directly importing, bc it was getting hard to reason about that code without proper contracts / typings for state and interfaces

@nl0 nl0 merged commit fcfb440 into master Mar 1, 2021
@nl0 nl0 deleted the pkg-update-dedupe branch March 1, 2021 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants