mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-02-07 17:23:25 +08:00
Merge pull request #199 from yokowu/fix-code-line-stat
fix: 修复统计页代码行计算错误
This commit is contained in:
@@ -4,7 +4,7 @@ go 1.23.7
|
||||
|
||||
require (
|
||||
entgo.io/ent v0.14.4
|
||||
github.com/GoYoko/web v1.4.0
|
||||
github.com/GoYoko/web v1.1.0
|
||||
github.com/cloudwego/eino v0.3.51
|
||||
github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250710065240-482d48888f25
|
||||
github.com/doquangtan/socket.io/v4 v4.0.8
|
||||
|
||||
@@ -8,8 +8,8 @@ github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg
|
||||
github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
|
||||
github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60=
|
||||
github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
|
||||
github.com/GoYoko/web v1.4.0 h1:DUe5ZsUA3i5HWAX2HiUmkuNop+xEzPYpZpg2ozUw37E=
|
||||
github.com/GoYoko/web v1.4.0/go.mod h1:DL9/gvuUG2jcBE1XUIY+9QBrrhdshzPEdxMCzR9jUHo=
|
||||
github.com/GoYoko/web v1.1.0 h1:nIbtol5z0Y03d0nHsvGjv+W0fgmFRGUL8fzPN3kmrOY=
|
||||
github.com/GoYoko/web v1.1.0/go.mod h1:DL9/gvuUG2jcBE1XUIY+9QBrrhdshzPEdxMCzR9jUHo=
|
||||
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
|
||||
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
|
||||
github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo=
|
||||
|
||||
@@ -46,6 +46,7 @@ func (d *DashboardRepo) CategoryStat(ctx context.Context, req domain.StatisticsF
|
||||
if err := d.db.Task.Query().
|
||||
Where(task.CreatedAtGTE(req.StartTime())).
|
||||
Where(task.ProgramLanguageNEQ("")).
|
||||
Where(task.IsSuggested(true)).
|
||||
Modify(func(s *sql.Selector) {
|
||||
s.Select(
|
||||
sql.As("program_language", "category"),
|
||||
@@ -112,8 +113,9 @@ func (d *DashboardRepo) TimeStat(ctx context.Context, req domain.StatisticsFilte
|
||||
sql.As("COUNT(*) FILTER (WHERE model_type = 'llm')", "llm_count"),
|
||||
sql.As("COUNT(*) FILTER (WHERE is_suggested = true AND model_type = 'coder')", "code_count"),
|
||||
sql.As("COUNT(*) FILTER (WHERE is_accept = true AND model_type = 'coder')", "accepted_count"),
|
||||
sql.As(sql.Sum(task.FieldCodeLines), "code_lines"),
|
||||
).GroupBy("date").
|
||||
sql.As("SUM(code_lines) FILTER (WHERE is_accept = true)", "code_lines"),
|
||||
).
|
||||
GroupBy("date").
|
||||
OrderBy(sql.Asc("date"))
|
||||
}).
|
||||
Scan(ctx, &ds); err != nil {
|
||||
@@ -127,7 +129,8 @@ func (d *DashboardRepo) TimeStat(ctx context.Context, req domain.StatisticsFilte
|
||||
s.Select(
|
||||
sql.As("date_trunc('minute', created_at)", "date"),
|
||||
sql.As(sql.Count("*"), "count"),
|
||||
).GroupBy("date").
|
||||
).
|
||||
GroupBy("date").
|
||||
OrderBy(sql.Asc("date"))
|
||||
}).
|
||||
Scan(ctx, &dsOneHour); err != nil {
|
||||
@@ -208,7 +211,8 @@ func (d *DashboardRepo) UserCodeRank(ctx context.Context, req domain.StatisticsF
|
||||
s.Select(
|
||||
sql.As("user_id", "user_id"),
|
||||
sql.As(sql.Sum(task.FieldCodeLines), "code_lines"),
|
||||
).GroupBy(task.FieldUserID).
|
||||
).
|
||||
GroupBy(task.FieldUserID).
|
||||
OrderBy(sql.Desc("code_lines"))
|
||||
}).
|
||||
Scan(ctx, &rs); err != nil {
|
||||
@@ -289,8 +293,9 @@ func (d *DashboardRepo) UserStat(ctx context.Context, req domain.StatisticsFilte
|
||||
sql.As("COUNT(*) FILTER (WHERE model_type = 'llm')", "llm_count"),
|
||||
sql.As("COUNT(*) FILTER (WHERE is_suggested = true AND model_type = 'coder')", "code_count"),
|
||||
sql.As("COUNT(*) FILTER (WHERE is_accept = true AND model_type = 'coder')", "accepted_count"),
|
||||
sql.As(sql.Sum(task.FieldCodeLines), "code_lines"),
|
||||
).GroupBy("date").
|
||||
sql.As("SUM(code_lines) FILTER (WHERE is_accept = true)", "code_lines"),
|
||||
).
|
||||
GroupBy("date").
|
||||
OrderBy(sql.Asc("date"))
|
||||
}).
|
||||
Scan(ctx, &ds); err != nil {
|
||||
@@ -306,7 +311,8 @@ func (d *DashboardRepo) UserStat(ctx context.Context, req domain.StatisticsFilte
|
||||
s.Select(
|
||||
sql.As("work_mode", "category"),
|
||||
sql.As("COUNT(*)", "value"),
|
||||
).GroupBy(task.FieldWorkMode).
|
||||
).
|
||||
GroupBy(task.FieldWorkMode).
|
||||
OrderBy(sql.Desc("value"))
|
||||
}).
|
||||
Scan(ctx, &cs); err != nil {
|
||||
@@ -317,11 +323,13 @@ func (d *DashboardRepo) UserStat(ctx context.Context, req domain.StatisticsFilte
|
||||
Where(task.CreatedAtGTE(req.StartTime())).
|
||||
Where(task.HasUserWith(user.ID(id))).
|
||||
Where(task.ProgramLanguageNEQ("")).
|
||||
Where(task.IsSuggested(true)).
|
||||
Modify(func(s *sql.Selector) {
|
||||
s.Select(
|
||||
sql.As("program_language", "category"),
|
||||
sql.As("COUNT(*)", "value"),
|
||||
).GroupBy(task.FieldProgramLanguage).
|
||||
).
|
||||
GroupBy(task.FieldProgramLanguage).
|
||||
OrderBy(sql.Desc("value"))
|
||||
}).
|
||||
Scan(ctx, &ps); err != nil {
|
||||
@@ -384,7 +392,8 @@ func (d *DashboardRepo) UserHeatmap(ctx context.Context, userID string) ([]*doma
|
||||
s.Select(
|
||||
sql.As("date_trunc('day', created_at)", "date"),
|
||||
sql.As("COUNT(*)", "count"),
|
||||
).GroupBy("date").
|
||||
).
|
||||
GroupBy("date").
|
||||
OrderBy(sql.Asc("date"))
|
||||
}).
|
||||
Scan(ctx, &rs); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user