Skip to content

Commit 225c97d

Browse files
authored
Merge branch 'main' into avatar-refactor
2 parents 4ab7616 + dd22c65 commit 225c97d

File tree

7 files changed

+54
-7
lines changed

7 files changed

+54
-7
lines changed

custom/conf/app.example.ini

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1883,7 +1883,7 @@ PATH =
18831883
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
18841884
;ENABLED = false
18851885
;RUN_AT_START = false
1886-
;NO_SUCCESS_NOTICE = f;alse
1886+
;NO_SUCCESS_NOTICE = false
18871887
;SCHEDULE = @every 72h
18881888

18891889
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -1907,7 +1907,7 @@ PATH =
19071907
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
19081908
;ENABLED = false
19091909
;RUN_AT_START = false
1910-
;NO_SUCCESS_NOTICE = f;alse
1910+
;NO_SUCCESS_NOTICE = false
19111911
;SCHEDULE = @every 72h
19121912

19131913
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -2041,6 +2041,8 @@ PATH =
20412041
;ENABLED = false
20422042
;; If you want to add authorization, specify a token here
20432043
;TOKEN =
2044+
;; Enable issue by label metrics; default is false
2045+
;ENABLED_ISSUE_BY_LABEL = false
20442046

20452047
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
20462048
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

docs/content/doc/advanced/config-cheat-sheet.en-us.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,7 @@ NB: You must have `DISABLE_ROUTER_LOG` set to `false` for this option to take ef
853853
## Metrics (`metrics`)
854854

855855
- `ENABLED`: **false**: Enables /metrics endpoint for prometheus.
856+
- `ENABLED_ISSUE_BY_LABEL`: **false**: Enable issue by label metrics
856857
- `TOKEN`: **\<empty\>**: You need to specify the token, if you want to include in the authorization the metrics . The same token need to be used in prometheus parameters `bearer_token` or `bearer_token_file`.
857858

858859
## API (`api`)

models/statistic.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package models
77
import (
88
"code.gitea.io/gitea/models/db"
99
"code.gitea.io/gitea/models/login"
10+
"code.gitea.io/gitea/modules/setting"
1011
)
1112

1213
// Statistic contains the database statistics
@@ -20,9 +21,16 @@ type Statistic struct {
2021
Milestone, Label, HookTask,
2122
Team, UpdateTask, Project,
2223
ProjectBoard, Attachment int64
24+
IssueByLabel []IssueByLabelCount
2325
}
2426
}
2527

28+
// IssueByLabelCount contains the number of issue group by label
29+
type IssueByLabelCount struct {
30+
Count int64
31+
Label string
32+
}
33+
2634
// GetStatistic returns the database statistics
2735
func GetStatistic() (stats Statistic) {
2836
e := db.GetEngine(db.DefaultContext)
@@ -39,6 +47,17 @@ func GetStatistic() (stats Statistic) {
3947
Count int64
4048
IsClosed bool
4149
}
50+
51+
if setting.Metrics.EnabledIssueByLabel {
52+
stats.Counter.IssueByLabel = []IssueByLabelCount{}
53+
54+
_ = e.Select("COUNT(*) AS count, l.name AS label").
55+
Join("LEFT", "label l", "l.id=il.label_id").
56+
Table("issue_label il").
57+
GroupBy("l.name").
58+
Find(&stats.Counter.IssueByLabel)
59+
}
60+
4261
issueCounts := []IssueCount{}
4362

4463
_ = e.Select("COUNT(*) AS count, is_closed").Table("issue").GroupBy("is_closed").Find(&issueCounts)

modules/metrics/collector.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ type Collector struct {
2424
Issues *prometheus.Desc
2525
IssuesOpen *prometheus.Desc
2626
IssuesClosed *prometheus.Desc
27+
IssuesByLabel *prometheus.Desc
2728
Labels *prometheus.Desc
2829
LoginSources *prometheus.Desc
2930
Milestones *prometheus.Desc
@@ -45,6 +46,7 @@ type Collector struct {
4546

4647
// NewCollector returns a new Collector with all prometheus.Desc initialized
4748
func NewCollector() Collector {
49+
4850
return Collector{
4951
Accesses: prometheus.NewDesc(
5052
namespace+"accesses",
@@ -81,6 +83,11 @@ func NewCollector() Collector {
8183
"Number of Issues",
8284
nil, nil,
8385
),
86+
IssuesByLabel: prometheus.NewDesc(
87+
namespace+"issues_by_label",
88+
"Number of Issues",
89+
[]string{"label"}, nil,
90+
),
8491
IssuesOpen: prometheus.NewDesc(
8592
namespace+"issues_open",
8693
"Number of open Issues",
@@ -177,7 +184,6 @@ func NewCollector() Collector {
177184
nil, nil,
178185
),
179186
}
180-
181187
}
182188

183189
// Describe returns all possible prometheus.Desc
@@ -189,6 +195,7 @@ func (c Collector) Describe(ch chan<- *prometheus.Desc) {
189195
ch <- c.Follows
190196
ch <- c.HookTasks
191197
ch <- c.Issues
198+
ch <- c.IssuesByLabel
192199
ch <- c.IssuesOpen
193200
ch <- c.IssuesClosed
194201
ch <- c.Labels
@@ -249,6 +256,14 @@ func (c Collector) Collect(ch chan<- prometheus.Metric) {
249256
prometheus.GaugeValue,
250257
float64(stats.Counter.Issue),
251258
)
259+
for _, il := range stats.Counter.IssueByLabel {
260+
ch <- prometheus.MustNewConstMetric(
261+
c.IssuesByLabel,
262+
prometheus.GaugeValue,
263+
float64(il.Count),
264+
il.Label,
265+
)
266+
}
252267
ch <- prometheus.MustNewConstMetric(
253268
c.IssuesClosed,
254269
prometheus.GaugeValue,

modules/setting/setting.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -390,11 +390,13 @@ var (
390390

391391
// Metrics settings
392392
Metrics = struct {
393-
Enabled bool
394-
Token string
393+
Enabled bool
394+
Token string
395+
EnabledIssueByLabel bool
395396
}{
396-
Enabled: false,
397-
Token: "",
397+
Enabled: false,
398+
Token: "",
399+
EnabledIssueByLabel: false,
398400
}
399401

400402
// I18n settings

options/locale/locale_ja-JP.ini

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ error=エラー
9696
error404=アクセスしようとしたページは<strong>存在しない</strong>か、閲覧が<strong>許可されていません</strong>。
9797

9898
never=無し
99+
color=色
99100

100101
[error]
101102
occurred=エラーが発生しました
@@ -345,6 +346,8 @@ reset_password.text=あなたのアカウントを回復するには、<b>%s</b>
345346

346347
register_success=登録が完了しました
347348

349+
issue_assigned.pull=リポジトリ %[3]s で @%[1]s さんが、あなたをプルリクエスト %[2]s の担当者にしました。
350+
issue_assigned.issue=リポジトリ %[3]s で @%[1]s さんが、あなたをイシュー %[2]s の担当者にしました。
348351

349352
issue.x_mentioned_you=<b>@%s</b> さんが、あなたにメンションしました:
350353
issue.action.force_push=<b>%[1]s</b> さんが <b>%[2]s</b> に強制プッシュしました。(%[3]s から %[4]s へ)
@@ -967,6 +970,7 @@ file_view_rendered=レンダリング表示
967970
file_view_raw=Rawデータを見る
968971
file_permalink=パーマリンク
969972
file_too_large=このファイルは大きすぎるため、表示できません。
973+
file_copy_permalink=パーマリンクをコピー
970974
video_not_supported_in_browser=このブラウザはHTML5のvideoタグをサポートしていません。
971975
audio_not_supported_in_browser=このブラウザーはHTML5のaudioタグをサポートしていません。
972976
stored_lfs=Git LFSで保管されています
@@ -1383,6 +1387,8 @@ pulls.compare_changes=新規プルリクエスト
13831387
pulls.compare_changes_desc=マージ先ブランチとプル元ブランチを選択。
13841388
pulls.compare_base=マージ先
13851389
pulls.compare_compare=プル元
1390+
pulls.switch_comparison_type=比較の種類を切り替える
1391+
pulls.switch_head_and_base=ヘッドとベースを切り替える
13861392
pulls.filter_branch=ブランチの絞り込み
13871393
pulls.no_results=結果が見つかりませんでした。
13881394
pulls.nothing_to_compare=同じブランチ同士のため、 プルリクエストを作成する必要がありません。
@@ -2417,6 +2423,7 @@ auths.attribute_name=名
24172423
auths.attribute_surname=姓
24182424
auths.attribute_mail=メールアドレス
24192425
auths.attribute_ssh_public_key=SSH公開鍵
2426+
auths.attribute_avatar=アバター
24202427
auths.attributes_in_bind=バインドDNのコンテクストから属性を取得する
24212428
auths.allow_deactivate_all=サーチ結果が空のときは全ユーザーを非アクティブ化
24222429
auths.use_paged_search=ページ分割検索を使用

options/locale/locale_zh-TW.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,7 @@ file_view_rendered=檢視渲染圖
970970
file_view_raw=查看原始文件
971971
file_permalink=永久連結
972972
file_too_large=檔案太大,無法顯示。
973+
file_copy_permalink=複製固定連結
973974
video_not_supported_in_browser=您的瀏覽器不支援使用 HTML5 播放影片。
974975
audio_not_supported_in_browser=您的瀏覽器不支援 HTML5 的「audio」標籤
975976
stored_lfs=已使用 Git LFS 儲存

0 commit comments

Comments
 (0)