-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
Conversation
if err = sess.Begin(); err != nil { | ||
return nil | ||
} | ||
if _, err = sess.Exec("UPDATE `repository` SET repo_size=? WHERE name=?", repoSize, repoName); err != nil { |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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 ;).
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
At the moment I'm unable to build the code, so cannot test.
|
if err = sess.Begin(); err != nil { | ||
return nil | ||
} | ||
if _, err = sess.Exec("UPDATE `repository` SET repo_size=? WHERE name=?", repoSize, repoName); err != nil { |
There was a problem hiding this comment.
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.
Current coverage is 2.15% (diff: 0.00%)@@ 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
|
Changes made |
Applying this change and going to my Admin panel I see all |
@@ -1666,6 +1693,125 @@ func GitGcRepos() error { | |||
}) | |||
} | |||
|
|||
// Maybe move this to gogits/git-module |
There was a problem hiding this comment.
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 😉
There was a problem hiding this comment.
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)
I actually like comments in the source-code, so that people
reading the code can get inspired to help by doing what the
commentor left to the reader as an excercise :)
|
@strk The size will be updated in the next commit. |
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 |
An easy way, could be to provide in the admin panel a button to force compute of all 0 sized repository. |
If I'm not mistaken there's also a periodic "repository checker"
routine (not sure what it does, maybe GC) -- how about adding
the count updates there ?
Or, I've noticed other caches are being updated at startup
(count if issues on which labels are applied) - could be
another place, even less intrusive.
|
I didn't want to put in a periodic function because there are only two cases when we should update:
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). |
It's ok with me to only look at repos with size of 0 at startup,
if migration is too hard to do. Maybe @lunny can give advice here
about xorm migrations
|
The new feature still needs automated tests |
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. |
I actually never made a test in Gogs/Gitea,
It looks like all of them use github.com/smartystreets/goconvey/convey |
IMHO we should get rid of goconvey with time. Thoughts? |
On Fri, Nov 04, 2016 at 12:37:38PM -0700, Matthias Loibl wrote:
I've no experiences with different testing frameworks, |
@metalmatze We need to build a new test suites before we remove goconvey. This is a plan. |
const STAT_GARBAGE = "garbage: " | ||
const STAT_SIZEGARBAGE = "size-garbage: " | ||
|
||
func GitRepoSize(repoPath string) (*CountObject, error) { |
There was a problem hiding this comment.
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
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 |
|
||
func GitRepoSize(repoPath string) (*CountObject, error) { | ||
var cmd *exec.Cmd | ||
cmd = exec.Command("git", "count-objects", "-v") |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
Don't do this 😆 Repos should be owned by Gitea...
Slow as fsck... at least until someome implements a cache-layer 😉 |
Please rebase and we can continue to review this. |
@DblK any update? Need to resolve the conflicts. |
@DblK any updates on this? |
Looks like @DblK don't have time to come back to this. Maybe somebody else wants to takeover and finish this PR? |
So let's move it to v1.2 |
Maybe we should just takeover this pr? |
May I take this one? |
@cez81 please do it. |
Closed via #1482 |
Signed-off-by: Dennis Keitzel <[email protected]>
Equivalent of my PR #3631 on gogs