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

Split lfs size from repository size #22900

Merged
merged 41 commits into from
Jun 28, 2023

Conversation

a1012112796
Copy link
Member

@a1012112796 a1012112796 commented Feb 14, 2023

releated to #21820

  • Split Size in repository table as two new colunms, one is GitSize for git size, the other is LFSSize for lfs data. still store full size in Size colunm.

  • Show full size on ui, but show each of them by a title; example:
    image

  • Return full size in api response.

@a1012112796 a1012112796 added the type/enhancement An improvement of existing functionality label Feb 14, 2023
releated to go-gitea#21820

splite `Size` in repository table as two
colunms, one is `Size` for git size, the
other is `LFSSize` for lfs data.
still show full size on ui, but show each of
them by a `title`; still response full size
in api response.

Signed-off-by: a1012112796 <[email protected]>
@a1012112796 a1012112796 force-pushed the zzc/dev/split_lfs_size branch from 910dd5b to b149388 Compare February 14, 2023 04:05
Signed-off-by: a1012112796 <[email protected]>
@kousu
Copy link
Contributor

kousu commented Feb 14, 2023

Nice. I have a question: what if lfs.ENABLED = false? Will this display '0 KiB' everywhere or should it hide that?

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Feb 14, 2023
@lunny
Copy link
Member

lunny commented Feb 14, 2023

Maybe we should move the setting to a seperate table, after #22500 merged

@a1012112796
Copy link
Member Author

Maybe we should move the setting to a seperate table, after #22500 merged

yes, but I think both Size and LFSSize are status value, not config data.

- show title when the lfs size isn't zero
- merge `Add64` and `Add` helper function

Signed-off-by: a1012112796 <[email protected]>
@lunny lunny mentioned this pull request Feb 14, 2023
30 tasks
@lunny
Copy link
Member

lunny commented Feb 14, 2023

For a repository, there are many related data not only git data. There are still, lfs, package, database tables, attachments. Should we have another x columns to store them?

@silverwind
Copy link
Member

silverwind commented Feb 15, 2023

For a repository, there are many related data not only git data. There are still, lfs, package, database tables, attachments. Should we have another x columns to store them?

I think the main size value displayed should be the repo size that you get with git clone, other sizes can be shown in the tooltip, but should not be added up.

I guess other sizes can be done in a separate PR.

@a1012112796
Copy link
Member Author

For a repository, there are many related data not only git data. There are still, lfs, package, database tables, attachments. Should we have another x columns to store them?

Hmm, How about use a json struct like this ?

diff --git a/models/repo/repo.go b/models/repo/repo.go
index a06ae7269..e733afd76 100644
--- a/models/repo/repo.go
+++ b/models/repo/repo.go
@@ -112,6 +112,17 @@ const (
 	RepositoryBroken                                  // repository is in a permanently broken state
 )
 
+type RepositorySize struct {
+	GitSize         int64
+	LFSSize         int64
+	AttachmentsSize int64
+	// ....
+}
+
+func (s RepositorySize) Size() int64 {
+	return s.GitSize + s.LFSSize
+}
+
 // Repository represents a git repository.
 type Repository struct {
 	ID                  int64 `xorm:"pk autoincr"`
@@ -163,8 +174,7 @@ type Repository struct {
 	IsTemplate bool        `xorm:"INDEX NOT NULL DEFAULT false"`
 	TemplateID int64       `xorm:"INDEX"`
 	// the size of git repository directory itself, not include lfs/package/attachment size
-	Size                            int64              `xorm:"NOT NULL DEFAULT 0"`
-	LFSSize                         int64              `xorm:"NOT NULL DEFAULT 0"`
+	Size                            RepositorySize     `xorm:"JSON TEXT"`
 	CodeIndexerStatus               *RepoIndexerStatus `xorm:"-"`
 	StatsIndexerStatus              *RepoIndexerStatus `xorm:"-"`
 	IsFsckEnabled                   bool               `xorm:"NOT NULL DEFAULT true"`

``

@a1012112796
Copy link
Member Author

other sizes can be shown in the tooltip

Hmm, I think show them on setting page to let repo owner know it is enough.

@lunny
Copy link
Member

lunny commented Feb 15, 2023

For a repository, there are many related data not only git data. There are still, lfs, package, database tables, attachments. Should we have another x columns to store them?

Hmm, How about use a json struct like this ?

diff --git a/models/repo/repo.go b/models/repo/repo.go
index a06ae7269..e733afd76 100644
--- a/models/repo/repo.go
+++ b/models/repo/repo.go
@@ -112,6 +112,17 @@ const (
 	RepositoryBroken                                  // repository is in a permanently broken state
 )
 
+type RepositorySize struct {
+	GitSize         int64
+	LFSSize         int64
+	AttachmentsSize int64
+	// ....
+}
+
+func (s RepositorySize) Size() int64 {
+	return s.GitSize + s.LFSSize
+}
+
 // Repository represents a git repository.
 type Repository struct {
 	ID                  int64 `xorm:"pk autoincr"`
@@ -163,8 +174,7 @@ type Repository struct {
 	IsTemplate bool        `xorm:"INDEX NOT NULL DEFAULT false"`
 	TemplateID int64       `xorm:"INDEX"`
 	// the size of git repository directory itself, not include lfs/package/attachment size
-	Size                            int64              `xorm:"NOT NULL DEFAULT 0"`
-	LFSSize                         int64              `xorm:"NOT NULL DEFAULT 0"`
+	Size                            RepositorySize     `xorm:"JSON TEXT"`
 	CodeIndexerStatus               *RepoIndexerStatus `xorm:"-"`
 	StatsIndexerStatus              *RepoIndexerStatus `xorm:"-"`
 	IsFsckEnabled                   bool               `xorm:"NOT NULL DEFAULT true"`

``

Or we can let Size as the total size and store details in this new column of size detail.

@a1012112796
Copy link
Member Author

Or we can let Size as the total size and store details in this new column of size detail.

then the Size (total size) looks useless, why store a data which can be sumed quickly in database?

@lunny
Copy link
Member

lunny commented Feb 15, 2023

Or we can let Size as the total size and store details in this new column of size detail.

then the Size (total size) looks useless, why store a data which can be sumed quickly in database?

I don't think so. If we need to filter with size, we need that column as index.

@a1012112796
Copy link
Member Author

Or we can let Size as the total size and store details in this new column of size detail.

then the Size (total size) looks useless, why store a data which can be sumed quickly in database?

I don't think so. If we need to filter with size, we need that column as index.

@lunny done, how about this now? 0c047b3

models/repo/update.go Outdated Show resolved Hide resolved
@DmitryFrolovTri
Copy link
Contributor

@a1012112796 please also update the description of the PR - we have not only split the Size into git size and lfs size in the table, we have also done so in the UI for administrator templates/admin/repo/list.tmpl and probably move the screenshot from #22900 (comment) to the PR description

@silverwind
Copy link
Member

silverwind commented Jun 20, 2023

@a1012112796 decided that it is faster to do the change. PR into your branch: a1012112796#9 Split Size in repository table as two columns, one is Size for git size, the other is LFSSize for lfs data. in the Administrative UI. Feel free to accept / deny or rework to your liking. Notable this it is uncoditional, i.e. if LFS_START_SERVER=false, it would still show the column, which is probably acceptable, but not ideal. For simplicity and as LFS is no longer rare I think should be ok. What do you think?

gitsize_and_lfssize_in_admin

We can also do a tooltip in the admin interface if you fancy (I think). But since size limit would be on this screen and in future LFS limit probably like that should be fine, also I suppose admin does care where his data is stored.

Can you check with longer owner and repo names? These admin tables are already bursting on their width, so I'm not too fond of adding another column.

@lunny
Copy link
Member

lunny commented Jun 21, 2023

@a1012112796 decided that it is faster to do the change. PR into your branch: a1012112796#9 Split Size in repository table as two columns, one is Size for git size, the other is LFSSize for lfs data. in the Administrative UI. Feel free to accept / deny or rework to your liking. Notable this it is uncoditional, i.e. if LFS_START_SERVER=false, it would still show the column, which is probably acceptable, but not ideal. For simplicity and as LFS is no longer rare I think should be ok. What do you think?
gitsize_and_lfssize_in_admin
We can also do a tooltip in the admin interface if you fancy (I think). But since size limit would be on this screen and in future LFS limit probably like that should be fine, also I suppose admin does care where his data is stored.

Can you check with longer owner and repo names? These admin tables are already bursting on their width, so I'm not too fond of adding another column.

Group Watchers,Stars, Forks, Issues as Watchers / Stars / Forks / Issues and Group Size, LFS Size as Size / LFS Size.

@DmitryFrolovTri
Copy link
Contributor

@a1012112796 decided that it is faster to do the change. PR into your branch: a1012112796#9 Split Size in repository table as two columns, one is Size for git size, the other is LFSSize for lfs data. in the Administrative UI. Feel free to accept / deny or rework to your liking. Notable this it is uncoditional, i.e. if LFS_START_SERVER=false, it would still show the column, which is probably acceptable, but not ideal. For simplicity and as LFS is no longer rare I think should be ok. What do you think?
gitsize_and_lfssize_in_admin
We can also do a tooltip in the admin interface if you fancy (I think). But since size limit would be on this screen and in future LFS limit probably like that should be fine, also I suppose admin does care where his data is stored.

Can you check with longer owner and repo names? These admin tables are already bursting on their width, so I'm not too fond of adding another column.

Group Watchers,Stars, Forks, Issues as Watchers / Stars / Forks / Issues and Group Size, LFS Size as Size / LFS Size.

There are sorts. so may be we group just Size and LFS Size

@silverwind
Copy link
Member

I guess we can reduce padding a bit, add this to base.css after rule at line 870:

.ui.table > thead > tr > th,
.ui.table > tbody > tr > td,
.ui.table > tr > td {
  padding-left: .5em;
  padding-right: .5em;
}

@a1012112796
Copy link
Member Author

test result, looks okay in my view.
image

or maybe limit max name length in ui like here?
image

@silverwind
Copy link
Member

silverwind commented Jun 26, 2023

Ah, the table scrolls. Still, I would hide the column LFS_START_SERVER as already mentioned. Can you merge main branch once more please? It looks like another migration landed.

@wxiaoguang
Copy link
Contributor

wxiaoguang commented Jun 27, 2023

The "auto-ellipsis" table is already supported by g-table-auto-ellipsis, see the "notice" admin page. (not a must and not related to this PR)

@DmitryFrolovTri
Copy link
Contributor

@a1012112796. Hi did a merge of latest upstream. a1012112796#12

…nupdate

Zzc/dev/split lfs size junupdate
@silverwind
Copy link
Member

So I guess this is LGTM. I don't think it's worth checking whether LFS is enabled because storage space could still be used when LFS is disabled. Regarding global table padding reduction, I will follow up with a separate PR.

@silverwind silverwind added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Jun 28, 2023
@silverwind
Copy link
Member

FYI, #25568 will reduce table padding which will help here a bit.

@silverwind silverwind added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Jun 28, 2023
@silverwind silverwind changed the title split lfs size from repository size Split lfs size from repository size Jun 28, 2023
@silverwind silverwind enabled auto-merge (squash) June 28, 2023 21:33
@silverwind silverwind merged commit 4aba8a6 into go-gitea:main Jun 28, 2023
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Jun 28, 2023
@a1012112796 a1012112796 deleted the zzc/dev/split_lfs_size branch June 29, 2023 05:06
@DmitryFrolovTri
Copy link
Contributor

Great! moving on to the other PR then!

@DmitryFrolovTri
Copy link
Contributor

@a1012112796 thank you!

@go-gitea go-gitea locked as resolved and limited conversation to collaborators Sep 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. type/enhancement An improvement of existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants