Skip to content

Commit 35bec9b

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: [skip ci] Updated licenses and gitignores Estimate Action Count in Statistics (go-gitea#19775)
2 parents 788c3c5 + fa5dec9 commit 35bec9b

File tree

5 files changed

+43
-3
lines changed

5 files changed

+43
-3
lines changed

models/db/context.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"code.gitea.io/gitea/modules/setting"
1212

1313
"xorm.io/builder"
14+
"xorm.io/xorm/schemas"
1415
)
1516

1617
// DefaultContext is the default context to run xorm queries in
@@ -175,3 +176,24 @@ func CountByBean(ctx context.Context, bean interface{}) (int64, error) {
175176
func TableName(bean interface{}) string {
176177
return x.TableName(bean)
177178
}
179+
180+
// EstimateCount returns an estimate of total number of rows in table
181+
func EstimateCount(ctx context.Context, bean interface{}) (int64, error) {
182+
e := GetEngine(ctx)
183+
e.Context(ctx)
184+
185+
var rows int64
186+
var err error
187+
tablename := TableName(bean)
188+
switch x.Dialect().URI().DBType {
189+
case schemas.MYSQL:
190+
_, err = e.Context(ctx).SQL("SELECT table_rows FROM information_schema.tables WHERE tables.table_name = ? AND tables.table_schema = ?;", tablename, x.Dialect().URI().DBName).Get(&rows)
191+
case schemas.POSTGRES:
192+
_, err = e.Context(ctx).SQL("SELECT reltuples AS estimate FROM pg_class WHERE relname = ?;", tablename).Get(&rows)
193+
case schemas.MSSQL:
194+
_, err = e.Context(ctx).SQL("sp_spaceused ?;", tablename).Get(&rows)
195+
default:
196+
return e.Context(ctx).Count(tablename)
197+
}
198+
return rows, err
199+
}

models/statistic.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func GetStatistic() (stats Statistic) {
5656
stats.Counter.Repo, _ = repo_model.CountRepositories(db.DefaultContext, repo_model.CountRepositoryOptions{})
5757
stats.Counter.Watch, _ = e.Count(new(repo_model.Watch))
5858
stats.Counter.Star, _ = e.Count(new(repo_model.Star))
59-
stats.Counter.Action, _ = e.Count(new(Action))
59+
stats.Counter.Action, _ = db.EstimateCount(db.DefaultContext, new(Action))
6060
stats.Counter.Access, _ = e.Count(new(access_model.Access))
6161

6262
type IssueCount struct {

options/gitignore/Umbraco

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,14 @@
3939
#ignore umbraco backoffice assest from wwwroot
4040
**/wwwroot/umbraco/
4141

42+
# SQLite files
43+
*.sqlite.db*
44+
4245
#ignore umbraco data/views/settings
4346
**/umbraco/
4447

4548
#include default location for modelsbuilder output
4649
!**/umbraco/models
4750

4851
#include default location for packages
49-
!**/umbraco/Data/packages
52+
!**/umbraco/Data/packages

options/license/Bitstream-Vera

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Copyright Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera is a trademark of Bitstream, Inc.
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of the fonts accompanying this license ("Fonts") and associated documentation files (the "Font Software"), to reproduce and distribute the Font Software, including without limitation the rights to use, copy, merge, publish, distribute, and/or sell copies of the Font Software, and to permit persons to whom the Font Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright and trademark notices and this permission notice shall be included in all copies of one or more of the Font Software typefaces.
6+
7+
The Font Software may be modified, altered, or added to, and in particular the designs of glyphs or characters in the Fonts may be modified and additional glyphs or characters may be added to the Fonts, only if the fonts are renamed to names not containing either the words "Bitstream" or the word "Vera".
8+
9+
This License becomes null and void to the extent applicable to Fonts or Font Software that has been modified and is distributed under the "Bitstream Vera" names.
10+
11+
The Font Software may be sold as part of a larger software package but no copy of one or more of the Font Software typefaces may be sold by itself.
12+
13+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.
14+
15+
Except as contained in this notice, the names of Gnome, the Gnome Foundation, and Bitstream Inc., shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Font Software without prior written authorization from the Gnome Foundation or Bitstream Inc., respectively. For further information, contact: fonts at gnome dot org.

options/locale/locale_en-US.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2423,7 +2423,7 @@ dashboard.new_version_hint = Gitea %s is now available, you are running %s. Chec
24232423
dashboard.statistic = Summary
24242424
dashboard.operations = Maintenance Operations
24252425
dashboard.system_status = System Status
2426-
dashboard.statistic_info = The Gitea database holds <b>%d</b> users, <b>%d</b> organizations, <b>%d</b> public keys, <b>%d</b> repositories, <b>%d</b> watches, <b>%d</b> stars, <b>%d</b> actions, <b>%d</b> accesses, <b>%d</b> issues, <b>%d</b> comments, <b>%d</b> social accounts, <b>%d</b> follows, <b>%d</b> mirrors, <b>%d</b> releases, <b>%d</b> authentication sources, <b>%d</b> webhooks, <b>%d</b> milestones, <b>%d</b> labels, <b>%d</b> hook tasks, <b>%d</b> teams, <b>%d</b> update tasks, <b>%d</b> attachments.
2426+
dashboard.statistic_info = The Gitea database holds <b>%d</b> users, <b>%d</b> organizations, <b>%d</b> public keys, <b>%d</b> repositories, <b>%d</b> watches, <b>%d</b> stars, ~<b>%d</b> actions, <b>%d</b> accesses, <b>%d</b> issues, <b>%d</b> comments, <b>%d</b> social accounts, <b>%d</b> follows, <b>%d</b> mirrors, <b>%d</b> releases, <b>%d</b> authentication sources, <b>%d</b> webhooks, <b>%d</b> milestones, <b>%d</b> labels, <b>%d</b> hook tasks, <b>%d</b> teams, <b>%d</b> update tasks, <b>%d</b> attachments.
24272427
dashboard.operation_name = Operation Name
24282428
dashboard.operation_switch = Switch
24292429
dashboard.operation_run = Run

0 commit comments

Comments
 (0)