Skip to content

Feature size repo in admin panel #39

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

Closed
wants to merge 1 commit into from
Closed

Feature size repo in admin panel #39

wants to merge 1 commit into from

Conversation

DblK
Copy link
Member

@DblK DblK commented Nov 3, 2016

Equivalent of my PR #3631 on gogs

@DblK DblK changed the title Feature size repo Feature size repo in admin panel Nov 3, 2016
if err = sess.Begin(); err != nil {
return nil
}
if _, err = sess.Exec("UPDATE `repository` SET repo_size=? WHERE name=?", repoSize, repoName); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Had you tested this with PostgreSQL backend ?

Copy link
Member Author

Choose a reason for hiding this comment

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

No I didn't. I will need to make another install to let this work. I used Sqllite. If someone can give a try before me just do it ;).

Copy link
Member

Choose a reason for hiding this comment

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

Please avoid plain SQL queries and use XORM.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have done the same thing as previous SQL (See L1372).
I will do it in XORM but only mine.

A review of SQL queries need to be done.

@tboerger tboerger added this to the 1.0.0 milestone Nov 3, 2016
@tboerger tboerger added the type/enhancement An improvement of existing functionality label Nov 3, 2016
@strk
Copy link
Member

strk commented Nov 3, 2016 via email

if err = sess.Begin(); err != nil {
return nil
}
if _, err = sess.Exec("UPDATE `repository` SET repo_size=? WHERE name=?", repoSize, repoName); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Please avoid plain SQL queries and use XORM.

@codecov-io
Copy link

codecov-io commented Nov 3, 2016

Current coverage is 2.15% (diff: 0.00%)

Merging #39 into master will decrease coverage by 0.02%

@@            master       #39   diff @@
========================================
  Files           31        31          
  Lines         7508      7593    +85   
  Methods          0         0          
  Messages         0         0          
  Branches         0         0          
========================================
  Hits           164       164          
- Misses        7327      7412    +85   
  Partials        17        17          

Powered by Codecov. Last update fc55182...74cbcef

@tboerger tboerger added type/feature Completely new functionality. Can only be merged if feature freeze is not active. and removed type/enhancement An improvement of existing functionality labels Nov 3, 2016
@DblK
Copy link
Member Author

DblK commented Nov 4, 2016

Changes made

@strk
Copy link
Member

strk commented Nov 4, 2016

Applying this change and going to my Admin panel I see all 0B as the repositories size, does this miss an automatic migration ?

@@ -1666,6 +1693,125 @@ func GitGcRepos() error {
})
}

// Maybe move this to gogits/git-module
Copy link
Member

Choose a reason for hiding this comment

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

Make a separate issue for that (when this is merged) instead of adding useless comments in the source-code 😉

Copy link
Member Author

Choose a reason for hiding this comment

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

I just copy/paste the comments because in the same file there is also another block to move.
Without comments and depending on the time for the PR to get merge, I will probably forget this (because I haven't only one PR)

@strk
Copy link
Member

strk commented Nov 4, 2016 via email

@DblK
Copy link
Member Author

DblK commented Nov 4, 2016

@strk The size will be updated in the next commit.
I could make another PR to make a migration script (even if I don't know how to do it).

@strk
Copy link
Member

strk commented Nov 4, 2016

I don't know how to do migrations either, and I do realize on next commit the size would be updated. But I think its better to figure that out that to keep getting bug reports about those sizes being at 0

@DblK
Copy link
Member Author

DblK commented Nov 4, 2016

An easy way, could be to provide in the admin panel a button to force compute of all 0 sized repository.
What do you think about that?

@strk
Copy link
Member

strk commented Nov 4, 2016 via email

@DblK
Copy link
Member Author

DblK commented Nov 4, 2016

I didn't want to put in a periodic function because there are only two cases when we should update:

  1. When an Update occurs
  2. To compute if the data isn't set (migration)

The less intrusive could be at startup, but only watching repositories with a size of 0 to not spend too much time at startup (if you have a bunch of repos, it should be something that will lower the startup boot sequence too much).

@strk
Copy link
Member

strk commented Nov 4, 2016 via email

@strk strk dismissed tboerger’s stale review November 4, 2016 14:25

it was addressed

@strk
Copy link
Member

strk commented Nov 4, 2016

The new feature still needs automated tests

@lunny
Copy link
Member

lunny commented Nov 4, 2016

see https://github.com/go-gitea/gitea/tree/master/models/migrations to find some examples about migrations. You have to write a migration to set the default reposize value of the exsit repos.

@DblK
Copy link
Member Author

DblK commented Nov 4, 2016

Thanks @lunny for the help. I will look to this to make a migration script.

@strk Can you point me to something that show how to make tests for gitea?

@strk
Copy link
Member

strk commented Nov 4, 2016

I actually never made a test in Gogs/Gitea,
but you can get a list of existing tests with something like:

find . -name "*_test.go"

It looks like all of them use github.com/smartystreets/goconvey/convey

@metalmatze
Copy link
Contributor

IMHO we should get rid of goconvey with time. Thoughts?

@strk
Copy link
Member

strk commented Nov 4, 2016

On Fri, Nov 04, 2016 at 12:37:38PM -0700, Matthias Loibl wrote:

IMHO we should get rid of goconvey with time. Thoughts?

I've no experiences with different testing frameworks,
but I do think tests should be there.

@lunny
Copy link
Member

lunny commented Nov 5, 2016

@metalmatze We need to build a new test suites before we remove goconvey. This is a plan.

@strk strk modified the milestones: 1.1.0, 1.0.0 Nov 6, 2016
const STAT_GARBAGE = "garbage: "
const STAT_SIZEGARBAGE = "size-garbage: "

func GitRepoSize(repoPath string) (*CountObject, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This method should be on the git module, not here

@thibaultmeyer
Copy link
Contributor

thibaultmeyer commented Nov 13, 2016

Why put it on database ? It could be easily become out-dated, by exemple, if server run periodically housekeeping operation via CRON outside from Gitea.

Why not simply use the command git count-objects directly ?


func GitRepoSize(repoPath string) (*CountObject, error) {
var cmd *exec.Cmd
cmd = exec.Command("git", "count-objects", "-v")
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add the flag --human-readable

Copy link
Member

Choose a reason for hiding this comment

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

This function should really in git repository.

@bkcsoft
Copy link
Member

bkcsoft commented Dec 1, 2016

Why put it on database ? It could be easily become out-dated, by exemple, if server run periodically housekeeping operation via CRON outside from Gitea.

Don't do this 😆 Repos should be owned by Gitea...

Why not simply use the command git count-objects directly ?

Slow as fsck... at least until someome implements a cache-layer 😉

@tboerger tboerger added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Dec 1, 2016
@lunny
Copy link
Member

lunny commented Dec 25, 2016

Please rebase and we can continue to review this.

@tboerger
Copy link
Member

@DblK any update? Need to resolve the conflicts.

@tboerger tboerger added pr/wip This PR is not ready for review issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail and removed pr/wip This PR is not ready for review labels Dec 29, 2016
@Bwko
Copy link
Member

Bwko commented Jan 11, 2017

@DblK any updates on this?

@tboerger
Copy link
Member

Looks like @DblK don't have time to come back to this. Maybe somebody else wants to takeover and finish this PR?

@lunny lunny added the status/blocked This PR cannot be merged yet, i.e. because it depends on another unmerged PR label Jan 25, 2017
@lunny lunny modified the milestones: 1.2.0, 1.1.0 Feb 5, 2017
@lunny
Copy link
Member

lunny commented Feb 5, 2017

So let's move it to v1.2

@tboerger
Copy link
Member

Maybe we should just takeover this pr?

@cez81
Copy link
Contributor

cez81 commented Mar 31, 2017

May I take this one?

@lunny
Copy link
Member

lunny commented Apr 1, 2017

@cez81 please do it.

@appleboy
Copy link
Member

Closed via #1482

@appleboy appleboy closed this Apr 11, 2017
@lunny lunny removed this from the 1.2.0 milestone Apr 11, 2017
lunny pushed a commit to lunny/gitea that referenced this pull request Feb 7, 2019
@go-gitea go-gitea locked and limited conversation to collaborators Nov 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. status/blocked This PR cannot be merged yet, i.e. because it depends on another unmerged PR type/feature Completely new functionality. Can only be merged if feature freeze is not active.
Projects
None yet
Development

Successfully merging this pull request may close these issues.