-
Notifications
You must be signed in to change notification settings - Fork 488
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
feat: add sharing statistics on the homepage #1942
base: main
Are you sure you want to change the base?
Conversation
Jorropo
commented
Jun 6, 2022
520a47b
to
50f39a9
Compare
8bed475
to
c33f0e4
Compare
@@ -10,6 +10,7 @@ | |||
"countMore": "...and {count} more", | |||
"StatusConnected": { | |||
"repoSize": "Hosting {repoSize} of data", | |||
"shareSize": "Downloaded {downloadedSize} and Shared {sharedSize} ({ratio})", |
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.
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.
I think we should add some indication that this is not since the beginning, but just for the current session. Maybe some surrounding box saying current session?
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.
I like the idea of a "Since {date}" prefix.
Also, this is a great candidate for #1220
dabaee3
to
7ddf870
Compare
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.
left a few comments.
@@ -10,6 +10,7 @@ | |||
"countMore": "...and {count} more", | |||
"StatusConnected": { | |||
"repoSize": "Hosting {repoSize} of data", | |||
"shareSize": "Downloaded {downloadedSize} and Shared {sharedSize} ({ratio})", |
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.
I like the idea of a "Since {date}" prefix.
Also, this is a great candidate for #1220
src/bundles/bitswap-stats.js
Outdated
const bundle = createAsyncResourceBundle({ | ||
name: 'bitswapStats', | ||
getPromise: async ({ getIpfs }) => { | ||
const rawData = await getIpfs().stats.bitswap() |
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.
What happens if this function throws?
Also, prefer const { dataReceived, dataSent } = await getIpfs().stats.bitswap()
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.
What happens if this function throws?
I have no idea, wtf is javascript anyway ?
(I guess the ressources are never initialised which isn't that bad ?)
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.
updated with try/catch
bundle.selectDownloadedSize = createSelector( | ||
'selectBitswapStats', | ||
(bitswapStats) => { | ||
if (bitswapStats && bitswapStats.downloadedSize) { |
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.
eslint should be yelling here about using optional chaining instead, e.g. bitswapStats?.downloadedSize
. Also, most of our eslint rules prefer explicit boolean checks, so either
Boolean(bitswapStats?.downloadedSize)
orbitswapStats?.downloadedSize != null
You may want to check your editor settings.
bundle.selectSharedSize = createSelector( | ||
'selectBitswapStats', | ||
(bitswapStats) => { | ||
console.log(bitswapStats) |
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.
do we still need this? If so, prefer logger.debug
or similar. If not, remove please :)
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.
Debug I forgot to remove
'selectBitswapStats', | ||
(bitswapStats) => { | ||
console.log(bitswapStats) | ||
if (bitswapStats && bitswapStats.sharedSize) { |
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.
Boolean(bitswapStats?.sharedSize)
orbitswapStats?.sharedSize != null
const humanRepoSize = humanSize(repoSize || 0) | ||
downloadedSize = downloadedSize || 0 |
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.
nit: we should prefer the null coalescence operator (??
) instead of the OR operator (||
) for default values if possible. I assume we also want to make sure downloadedSize is a number? Number(downloadedSize ?? 0)
ditto for other vars here.
assigning to Dan to push past the finish line |