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: user storage space #2274

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open

feat: user storage space #2274

wants to merge 16 commits into from

Conversation

headri
Copy link
Contributor

@headri headri commented Dec 20, 2024

Backend

user space accounting/quota

  • Add new columns to user (used-space, available-space) migration script

calculation tools as sql functions

  • for a dataset: a dataset has many attachments

  • for [element].attachments where Element is a Sample, Reaction, Wellplate, ResearchPlan, Screen ....
    and for [element].analyses

  • for a collection (useful for export, validation of collection ownership transfer, but not working for the total user's usage since element can be in multiple collections at once)

  • for a type of elements owned by a user
    user ➡️ collections ➡️ unique elements of a type (eg: sample) ➡️ elements-attachments + elements-analyses

  • for user reports

cronJob to update user used-space

  • Add Job
  • Enqueue Job

Frontend

prevent upload if quota exceeded and show message

  • Inbox upload
  • Dataset on Element save
  • Dataset before "Keep Changes" (Show warning only)
  • Research Plan on save
  • Research Plan before save (Show warning only)
  • Report on Generate

Admin interface

  • Set default for all users
  • Set value for group
  • Set value for user
  • Show current usage (in percent/absolut)

@headri headri requested review from PiTrem and JanCBrammer December 20, 2024 14:06
@headri headri force-pushed the user-storage-space branch from cb78ec5 to d5f3651 Compare January 7, 2025 09:06
app/api/chemotion/admin_api.rb Show resolved Hide resolved
@@ -16,7 +16,7 @@ def hashize(inputs)
end

def time_now
Time.now.strftime('%Y-%m-%dT%H-%M-%S')
Time.zone.now.strftime('%Y-%m-%dT%H-%M-%S')
Copy link

Choose a reason for hiding this comment

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

Metrics/ClassLength: Class has too many lines. [237/200]

@PiTrem PiTrem linked an issue Jan 8, 2025 that may be closed by this pull request
@headri headri force-pushed the user-storage-space branch 2 times, most recently from cb3e56b to e7a1011 Compare January 8, 2025 12:13
@PiTrem PiTrem changed the title User storage space feat: user storage space Jan 8, 2025
@headri headri force-pushed the user-storage-space branch 2 times, most recently from bf1e72d to 4983883 Compare January 8, 2025 12:56
Copy link

github-actions bot commented Jan 8, 2025

LCOV of commit 4983883 during Continuous Integration #4284

Summary coverage rate:
  lines......: 66.7% (14363 of 21527 lines)
  functions..: no data found
  branches...: no data found

Files changed coverage rate: n/a

Copy link
Collaborator

@JanCBrammer JanCBrammer left a comment

Choose a reason for hiding this comment

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

Finished the first pass of my review.
Next I'll try the new features in the UI.

app/api/chemotion/admin_api.rb Outdated Show resolved Hide resolved
app/javascript/src/apps/admin/AdminDashboard.js Outdated Show resolved Hide resolved
app/javascript/src/apps/admin/UserManagement.js Outdated Show resolved Hide resolved
app/models/attachment.rb Outdated Show resolved Hide resolved
db/functions/calculate_collection_space_v01.sql Outdated Show resolved Hide resolved
@PiTrem PiTrem added this to the v2.0.0 milestone Jan 21, 2025
PiTrem added a commit that referenced this pull request Jan 21, 2025
Squashed commit of the following:

commit ea193ee
Author: Adrian Herrmann <[email protected]>
Date:   Mon Jan 20 09:44:50 2025 +0000

    Renamed users_available and changed set and show to MB

commit 4983883
Author: Adrian Herrmann <[email protected]>
Date:   Tue Jan 7 13:11:10 2025 +0000

    rebase fix

commit d5f3651
Author: Adrian Herrmann <[email protected]>
Date:   Mon Dec 16 15:08:40 2024 +0000

    feat: set available_space in admin interface

commit 334a83c
Author: Adrian Herrmann <[email protected]>
Date:   Wed Dec 11 16:07:43 2024 +0000

    added usage job

commit 5646024
Author: Adrian Herrmann <[email protected]>
Date:   Fri Dec 6 08:22:50 2024 +0000

    added error handling for reports

commit 6242df9
Author: Adrian Herrmann <[email protected]>
Date:   Thu Dec 5 08:43:57 2024 +0000

    fix: attachment space calculation

commit 139210e
Author: Adrian Herrmann <[email protected]>
Date:   Wed Dec 4 09:34:17 2024 +0000

    added warning before saving research plan when adding attachments

commit c1ebe4c
Author: Adrian Herrmann <[email protected]>
Date:   Tue Dec 3 14:02:29 2024 +0000

    added warning before 'keep changes' in dataset

commit f8a3887
Author: Adrian Herrmann <[email protected]>
Date:   Mon Dec 2 14:35:26 2024 +0000

    fix: error messages from attachment save

commit 73befa5
Author: Adrian Herrmann <[email protected]>
Date:   Mon Dec 2 09:48:25 2024 +0000

    refactor: rm commented out code

commit 72ad19a
Author: Adrian Herrmann <[email protected]>
Date:   Fri Nov 29 15:45:48 2024 +0000

    Added inbox upload check

commit 7f9b306
Author: Adrian Herrmann <[email protected]>
Date:   Mon Nov 4 13:32:00 2024 +0000

    feat: added migration for new user cols
    and calculation for used space per user and element
@headri headri force-pushed the user-storage-space branch 2 times, most recently from f83522d to 457f2cf Compare January 22, 2025 09:10
Copy link

LCOV of commit f83522d during Continuous Integration #4340

Summary coverage rate:
  lines......: 66.9% (14463 of 21609 lines)
  functions..: no data found
  branches...: no data found

Files changed coverage rate: n/a

Copy link

LCOV of commit 457f2cf during Continuous Integration #4341

Summary coverage rate:
  lines......: 66.9% (14447 of 21609 lines)
  functions..: no data found
  branches...: no data found

Files changed coverage rate: n/a

@headri headri requested a review from JanCBrammer January 22, 2025 09:47
Copy link

LCOV of commit d32e068 during Continuous Integration #4356

Summary coverage rate:
  lines......: 66.9% (14447 of 21609 lines)
  functions..: no data found
  branches...: no data found

Files changed coverage rate: n/a

@headri headri force-pushed the user-storage-space branch 2 times, most recently from 860f049 to 894c452 Compare January 24, 2025 11:58
@headri headri requested a review from JanCBrammer January 24, 2025 13:48
@headri headri force-pushed the user-storage-space branch from 7c3aec6 to 17584ed Compare January 27, 2025 14:19
Copy link
Collaborator

@JanCBrammer JanCBrammer left a comment

Choose a reason for hiding this comment

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

Do we have documentation for this feature?

I tried the feature in the UI and have a few comments (see below).

@headri headri force-pushed the user-storage-space branch 3 times, most recently from 0cacbdd to 4a36abe Compare January 29, 2025 16:09
Copy link

LCOV of commit 4a36abe during Continuous Integration #4374

Summary coverage rate:
  lines......: 66.9% (14448 of 21607 lines)
  functions..: no data found
  branches...: no data found

Files changed coverage rate: n/a

@headri headri force-pushed the user-storage-space branch from 4a36abe to 5ad9247 Compare January 30, 2025 09:00
@headri headri force-pushed the user-storage-space branch from 5ad9247 to 430d265 Compare January 30, 2025 09:03
Copy link

LCOV of commit 430d265 during Continuous Integration #4377

Summary coverage rate:
  lines......: 66.9% (14449 of 21606 lines)
  functions..: no data found
  branches...: no data found

Files changed coverage rate: n/a

@headri headri requested a review from JanCBrammer January 31, 2025 09:24
PiTrem added a commit that referenced this pull request Feb 3, 2025
Squashed commit of the following:

commit ea193ee
Author: Adrian Herrmann <[email protected]>
Date:   Mon Jan 20 09:44:50 2025 +0000

    Renamed users_available and changed set and show to MB

commit 4983883
Author: Adrian Herrmann <[email protected]>
Date:   Tue Jan 7 13:11:10 2025 +0000

    rebase fix

commit d5f3651
Author: Adrian Herrmann <[email protected]>
Date:   Mon Dec 16 15:08:40 2024 +0000

    feat: set available_space in admin interface

commit 334a83c
Author: Adrian Herrmann <[email protected]>
Date:   Wed Dec 11 16:07:43 2024 +0000

    added usage job

commit 5646024
Author: Adrian Herrmann <[email protected]>
Date:   Fri Dec 6 08:22:50 2024 +0000

    added error handling for reports

commit 6242df9
Author: Adrian Herrmann <[email protected]>
Date:   Thu Dec 5 08:43:57 2024 +0000

    fix: attachment space calculation

commit 139210e
Author: Adrian Herrmann <[email protected]>
Date:   Wed Dec 4 09:34:17 2024 +0000

    added warning before saving research plan when adding attachments

commit c1ebe4c
Author: Adrian Herrmann <[email protected]>
Date:   Tue Dec 3 14:02:29 2024 +0000

    added warning before 'keep changes' in dataset

commit f8a3887
Author: Adrian Herrmann <[email protected]>
Date:   Mon Dec 2 14:35:26 2024 +0000

    fix: error messages from attachment save

commit 73befa5
Author: Adrian Herrmann <[email protected]>
Date:   Mon Dec 2 09:48:25 2024 +0000

    refactor: rm commented out code

commit 72ad19a
Author: Adrian Herrmann <[email protected]>
Date:   Fri Nov 29 15:45:48 2024 +0000

    Added inbox upload check

commit 7f9b306
Author: Adrian Herrmann <[email protected]>
Date:   Mon Nov 4 13:32:00 2024 +0000

    feat: added migration for new user cols
    and calculation for used space per user and element
PiTrem added a commit that referenced this pull request Feb 3, 2025
Squashed commit of the following:

commit ea193ee
Author: Adrian Herrmann <[email protected]>
Date:   Mon Jan 20 09:44:50 2025 +0000

    Renamed users_available and changed set and show to MB

commit 4983883
Author: Adrian Herrmann <[email protected]>
Date:   Tue Jan 7 13:11:10 2025 +0000

    rebase fix

commit d5f3651
Author: Adrian Herrmann <[email protected]>
Date:   Mon Dec 16 15:08:40 2024 +0000

    feat: set available_space in admin interface

commit 334a83c
Author: Adrian Herrmann <[email protected]>
Date:   Wed Dec 11 16:07:43 2024 +0000

    added usage job

commit 5646024
Author: Adrian Herrmann <[email protected]>
Date:   Fri Dec 6 08:22:50 2024 +0000

    added error handling for reports

commit 6242df9
Author: Adrian Herrmann <[email protected]>
Date:   Thu Dec 5 08:43:57 2024 +0000

    fix: attachment space calculation

commit 139210e
Author: Adrian Herrmann <[email protected]>
Date:   Wed Dec 4 09:34:17 2024 +0000

    added warning before saving research plan when adding attachments

commit c1ebe4c
Author: Adrian Herrmann <[email protected]>
Date:   Tue Dec 3 14:02:29 2024 +0000

    added warning before 'keep changes' in dataset

commit f8a3887
Author: Adrian Herrmann <[email protected]>
Date:   Mon Dec 2 14:35:26 2024 +0000

    fix: error messages from attachment save

commit 73befa5
Author: Adrian Herrmann <[email protected]>
Date:   Mon Dec 2 09:48:25 2024 +0000

    refactor: rm commented out code

commit 72ad19a
Author: Adrian Herrmann <[email protected]>
Date:   Fri Nov 29 15:45:48 2024 +0000

    Added inbox upload check

commit 7f9b306
Author: Adrian Herrmann <[email protected]>
Date:   Mon Nov 4 13:32:00 2024 +0000

    feat: added migration for new user cols
    and calculation for used space per user and element
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.

Disk quota in Chemotion ELN
3 participants