Skip to content

Extend utility scripts to find out quota and its usage #5359

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

Open
1 task
carmenfan opened this issue Jan 23, 2025 · 7 comments
Open
1 task

Extend utility scripts to find out quota and its usage #5359

carmenfan opened this issue Jan 23, 2025 · 7 comments

Comments

@carmenfan
Copy link
Member

Description

For allExpiredLicenses and allActiveLicenses script, we want to extend the output to contain the following:

  • data quota usage
  • number of licenses assigned

Goals

  • as a 3DR admin I want to find out the usage of each teamspace

Tasks

TBC by the developer

@jacobcons
Copy link

Hiya @carmenfan, I'd love to make a PR for this. Just wanted to check a few things over. For a given teamspace, do you want to include the data available and the data used? (maybe using these functions quota.js#26 and quota.js#61), and also the total number of licenses regardless of whether they're expired or active?

Maybe writing the results to a json file with the following format:

[
  {
    "teamspaceId": "abc123",
    "dataMB": {
      "available": 100,
      "used": 20
    },
    "totalLicenses": 10,
    "expiredLicenses": [
      {
        "type": "enterprise",
        "dataMB": 50,
        "collaborators": "unlimited",
        "expiryDate": "2025-01-30T00:00:00Z"
      }
    ]
  }
]

Apologies if I've misunderstood what you're trying to achieve here. I'm just getting to grips with the codebase.

Also I think I've found a bug with the current implementation. If a teamspace has a single expired license it will include all of that teamspace's licenses, even ones that are active.

Thanks,
Jacob

@carmenfan
Copy link
Member Author

Hi @jacobcons,

Thank you for your interest in contributing to the project!

The task in question here is regarding the 2 scripts in https://github.com/3drepo/3drepo.io/tree/master/backend/src/scripts/utility/teamspaces

They are suppose to be utility command line scripts that operates on demand, (see more info here )

So the solution is probably a bit simpler than you think. There's already code that puts some data out in the form of a csv, and we're just looking at adding some columns in it 😄

@jacobcons
Copy link

jacobcons commented Jan 31, 2025

Yeah I understand that, I was just thinking maybe you wanted to write to a .json file to avoid redundantly repeating rows and represent the hierarchical structure of it.

So you want some columns for data quota usage and number of licenses assigned to a given teamspace (which will naturally repeat those values for each license in the same teamspace)?

Happy to add that along with fixing that bug I mentioned 😊

@carmenfan
Copy link
Member Author

Hi @jacobcons ,

Happy to add that along with fixing that bug I mentioned 😊

Not sure I follow on this bug you mentioned. Do you mean on calculating the quota size we're counting all the active licenses even if one of them expired? If that's the case that is the desired behaviour

@jacobcons
Copy link

jacobcons commented Jan 31, 2025

@carmenfan No I mean in the current state of the allExpiredLicenses script (not to do with calculating quota size) it will actually list active licenses in the CSV as long as it belongs to a teamspace with at least one expired license. This is intentional?

@carmenfan
Copy link
Member Author

@carmenfan No I mean in the current state of the allExpiredLicenses script (not to do with calculating quota size) it will actually list active licenses in the CSV as long as it belongs to a teamspace with at least one expired license. This is intentional?

oh no, definitely not. In which case you 100% found a bug 😆

@jacobcons
Copy link

Okay cool 😊

jacobcons added a commit to jacobcons/3drepo.io that referenced this issue Feb 4, 2025
jacobcons added a commit to jacobcons/3drepo.io that referenced this issue Feb 4, 2025
jacobcons added a commit to jacobcons/3drepo.io that referenced this issue Feb 4, 2025
…es, fixed bug where active licenses are displayed if a single license is expired, ensure calculated quota only includes licenses of a valid type
jacobcons added a commit to jacobcons/3drepo.io that referenced this issue Feb 4, 2025
…compare expected expired licenses against the actual ones
jacobcons added a commit to jacobcons/3drepo.io that referenced this issue Feb 4, 2025
jacobcons added a commit to jacobcons/3drepo.io that referenced this issue Feb 4, 2025
…ExpiredLicenses, added some common abstractions between them
jacobcons added a commit to jacobcons/3drepo.io that referenced this issue Feb 4, 2025
jacobcons added a commit to jacobcons/3drepo.io that referenced this issue Feb 4, 2025
…ave a valid format by including subscriptions type
jacobcons added a commit to jacobcons/3drepo.io that referenced this issue Feb 4, 2025
jacobcons added a commit to jacobcons/3drepo.io that referenced this issue Feb 4, 2025
jacobcons added a commit to jacobcons/3drepo.io that referenced this issue Feb 14, 2025
…scriptions and defaults, add tests for full coverage, refactoring of teamspacesetting license functions to be a bit more efficient
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants