Skip to content

Commit 18ac8e6

Browse files
committed
fix: 修复行数计算问题
1 parent d33dc01 commit 18ac8e6

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

backend/internal/proxy/repo/proxy.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -233,25 +233,25 @@ func (r *ProxyRepo) Report(ctx context.Context, req *domain.ReportReq) error {
233233
}
234234

235235
func (r *ProxyRepo) handleFileWritten(ctx context.Context, tx *db.Tx, rc *db.Task, req *domain.ReportReq) error {
236-
lines := 0
236+
lineCount := 0
237237
switch req.Tool {
238238
case "appliedDiff", "editedExistingFile", "insertContent":
239239
if strings.Contains(req.Content, "<<<<<<<") {
240240
lines := diff.ParseConflictsAndCountLines(req.Content)
241241
for _, line := range lines {
242-
rc.CodeLines += int64(line)
242+
lineCount += line
243243
}
244244
} else {
245-
rc.CodeLines = int64(strings.Count(req.Content, "\n"))
245+
lineCount = strings.Count(req.Content, "\n")
246246
}
247247
case "newFileCreated":
248-
rc.CodeLines = int64(strings.Count(req.Content, "\n"))
248+
lineCount = strings.Count(req.Content, "\n")
249249
}
250250

251-
if lines > 0 {
251+
if lineCount > 0 {
252252
if err := tx.Task.
253253
UpdateOneID(rc.ID).
254-
AddCodeLines(int64(lines)).
254+
AddCodeLines(int64(lineCount)).
255255
SetIsAccept(true).
256256
Exec(ctx); err != nil {
257257
return err
@@ -264,7 +264,7 @@ func (r *ProxyRepo) handleFileWritten(ctx context.Context, tx *db.Tx, rc *db.Tas
264264
SetRole(consts.ChatRoleSystem).
265265
SetPrompt("写入文件").
266266
SetCompletion("").
267-
SetCodeLines(int64(lines)).
267+
SetCodeLines(int64(lineCount)).
268268
SetCode(req.Content).
269269
SetOutputTokens(0).
270270
Save(ctx); err != nil {

0 commit comments

Comments
 (0)