get for 10 biggest repo in forgejo (#15)

I added that line to get the 10 biggest repo. I'm not sure it is the smartest way to use `echo "git_biggestrepos ${GIT_BIGGESTREPOS}" >> /tmp/git_stats` coz it would be displayed like this:

```
git_biggestrepos  repostest1       | 6936 MB        | user1
 repostest2       | 5212 MB        | user2
 repostest3 | 5039 MB        | user3

```

So I don't know how to get this in monitoring to work...

Co-authored-by: muppeth <muppeth@disroot.org>
Reviewed-on: #15
Reviewed-by: muppeth <muppeth@no-reply@disroot.org>
Co-authored-by: meaz <meaz@disroot.org>
Co-committed-by: meaz <meaz@disroot.org>
This commit is contained in:
meaz 2024-01-05 09:47:22 +00:00 committed by meaz
parent d7ac6baf3c
commit 1371b2c62c
1 changed files with 8 additions and 1 deletions

View File

@ -15,9 +15,16 @@ GIT_PUBREPOS=$(psql postgresql://${GITDB_USER}:${GITDB_PASSWD}@${GITDB_HOST}:${G
#private repos
GIT_PRIVREPOS=$(psql postgresql://${GITDB_USER}:${GITDB_PASSWD}@${GITDB_HOST}:${GITDB_PORT}/${GITDB_NAME} -t -c "SELECT COUNT(repository) FROM repository WHERE is_private != 'f';")
#10 biggest repo
GIT_BIGGESTREPOS=$(psql postgresql://${GITDB_USER}:${GITDB_PASSWD}@${GITDB_HOST}:${GITDB_PORT}/${GITDB_NAME} -t -c "SELECT name,PG_SIZE_PRETTY(size),owner_name FROM repository ORDER BY size DESC LIMIT 10;" | sed 's/|//g')
#10 repo owners
GIT_REPOCOUNT=$(psql postgresql://${GITDB_USER}:${GITDB_PASSWD}@${GITDB_HOST}:${GITDB_PORT}/${GITDB_NAME} -t -c "SELECT owner_name,count(*) AS repo_count FROM repository GROUP BY owner_name ORDER BY repo_count DESC LIMIT 10;" | sed 's/|//g')
#save onto a file
echo "git_users ${GIT_USERS}" > /tmp/git_stats
echo "git_allrepos ${GIT_ALLREPOS}" >> /tmp/git_stats
echo "git_pubrepos ${GIT_PUBREPOS}" >> /tmp/git_stats
echo "git_privrepos ${GIT_PRIVREPOS}" >> /tmp/git_stats
echo "git_biggestrepos ${GIT_BIGGESTREPOS}" >> /tmp/git_stats
echo "git_repocount" ${GIT_REPOCOUNT} >> /tmp/git_stats