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

feat(occ): print storage values human-friendly #48952

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

solracsf
Copy link
Member

@solracsf solracsf commented Oct 28, 2024

Summary

Values are now printed humand-friendly if --human option is passed.

Before

# occ user:info username
  - user_id: username
  - display_name: username
  - email: username@email.com
  - cloud_id: username@my.cloud.com
  - enabled: true
  - groups:
    - Users
  - quota: 20 GB
  - storage:
    - free: 2002327231
    - used: 19472509249
    - total: 21474836480
    - relative: 90.68
    - quota: 21474836480
  - last_seen: 2024-10-15T11:31:16+00:00
  - user_directory: /var/www/data/username
  - backend: Database

After

# occ user:info username --human
  - user_id: username
  - display_name: username
  - email: username@email.com
  - cloud_id: username@my.cloud.com
  - enabled: true
  - groups:
    - Users
  - quota: 20 GB
  - storage:
    - free: 1.9 GB
    - used: 18.1 GB
    - total: 20 GB
    - relative: 90.68%
    - quota: 20 GB
  - last_seen: 2024-10-15T11:31:16+00:00
  - user_directory: /var/www/data/username
  - backend: Database

@solracsf solracsf added 3. to review Waiting for reviews feature: occ labels Oct 28, 2024
@solracsf solracsf added this to the Nextcloud 31 milestone Oct 28, 2024
@solracsf solracsf force-pushed the printOccHumanFriendly branch 2 times, most recently from e42eb58 to 476e85f Compare October 28, 2024 18:02
@susnux susnux requested review from artonge and come-nc October 29, 2024 09:18
susnux

This comment was marked as resolved.

provokateurin

This comment was marked as resolved.

@skjnldsv skjnldsv added 2. developing Work in progress and removed 3. to review Waiting for reviews labels Oct 29, 2024
@solracsf solracsf force-pushed the printOccHumanFriendly branch from 9368e94 to 1628bd2 Compare October 30, 2024 07:56
@solracsf solracsf added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Oct 30, 2024
@solracsf

This comment was marked as resolved.

core/Command/User/Info.php Outdated Show resolved Hide resolved
core/Command/User/Info.php Show resolved Hide resolved
core/Command/User/Info.php Outdated Show resolved Hide resolved
@solracsf solracsf force-pushed the printOccHumanFriendly branch from 1628bd2 to 0ee9f91 Compare October 30, 2024 08:06
@solracsf solracsf force-pushed the printOccHumanFriendly branch from 0ee9f91 to 3fb55a4 Compare October 30, 2024 09:30
@provokateurin

This comment was marked as resolved.

Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
@solracsf solracsf force-pushed the printOccHumanFriendly branch from 3fb55a4 to 24636ca Compare October 31, 2024 06:30
@solracsf solracsf changed the title enh(occ): print storage values human-friendly feat(occ): print storage values human-friendly Oct 31, 2024
@solracsf solracsf enabled auto-merge October 31, 2024 06:32
@nextcloud nextcloud deleted a comment from solracsf Oct 31, 2024
@nextcloud nextcloud deleted a comment from solracsf Oct 31, 2024
@provokateurin
Copy link
Member

Please don't backport features

@solracsf
Copy link
Member Author

solracsf commented Oct 31, 2024

Hum... things like these (not breaking anything) have been backported in the past, but no problem. 👍

@provokateurin
Copy link
Member

It's also better to not do it right now, as we have to backport a lot of things for the upcoming releases and we need the CI power for that.

Comment on lines +87 to +91
'free' => \OC_Helper::humanFileSize($storage['free']),
'used' => \OC_Helper::humanFileSize($storage['used']),
'total' => \OC_Helper::humanFileSize($storage['total']),
'relative' => $storage['relative'] . '%',
'quota' => ($storage['quota'] >= 0) ? \OC_Helper::humanFileSize($storage['quota']) : $storage['quota'],
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
'free' => \OC_Helper::humanFileSize($storage['free']),
'used' => \OC_Helper::humanFileSize($storage['used']),
'total' => \OC_Helper::humanFileSize($storage['total']),
'relative' => $storage['relative'] . '%',
'quota' => ($storage['quota'] >= 0) ? \OC_Helper::humanFileSize($storage['quota']) : $storage['quota'],
'free' => Util::humanFileSize($storage['free']),
'used' => Util::humanFileSize($storage['used']),
'total' => Util::humanFileSize($storage['total']),
'relative' => $storage['relative'] . '%',
'quota' => ($storage['quota'] >= 0) ? Util::humanFileSize($storage['quota']) : $storage['quota'],

And add a use \OCP\Util; to the top. OC_* classes are deprecated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants