Skip to content
This repository was archived by the owner on Nov 7, 2025. It is now read-only.

Commit 288da8e

Browse files
authored
Fix A/B testing console (#1238)
This PR brings the A/B console back to life.
1 parent 70a4dc4 commit 288da8e

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

quesma/quesma/ui/ab_testing.go

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,8 @@ func (qmc *QuesmaManagementConsole) hasABTestingTable() bool {
2424

2525
sql := `SELECT count(*) FROM ab_testing_logs`
2626

27-
row, err := db.Query(context.Background(), sql)
27+
row := db.QueryRow(context.Background(), sql)
2828
var count int
29-
if err != nil {
30-
logger.Error().Err(err).Msg("Error checking for ab_testing_logs table")
31-
return false
32-
}
3329
if errScan := row.Scan(&count); errScan != nil {
3430
logger.Error().Err(errScan).Msg("Error scanning for ab_testing_logs table")
3531
return false
@@ -335,6 +331,7 @@ GROUP BY
335331
return nil, err
336332
}
337333

334+
defer rows.Close()
338335
for rows.Next() {
339336
row := abTestingReportRow{}
340337
err := rows.Scan(&row.dashboardId, &row.panelId, &row.aName, &row.bName, &row.successRate, &row.count, &row.aTime, &row.bTime)
@@ -509,6 +506,7 @@ func (qmc *QuesmaManagementConsole) abTestingReadPanelDetails(dashboardId, panel
509506
return nil, err
510507
}
511508

509+
defer rows.Close()
512510
var result []abTestingPanelDetailsRow
513511
for rows.Next() {
514512

@@ -692,6 +690,7 @@ func (qmc *QuesmaManagementConsole) abTestingReadMismatchDetails(dashboardId, pa
692690
return nil, err
693691
}
694692

693+
defer rows.Close()
695694
var result []abTestingMismatchDetailsRow
696695
for rows.Next() {
697696

@@ -823,11 +822,9 @@ func (qmc *QuesmaManagementConsole) abTestingReadRow(requestId string) (abTestin
823822

824823
db := qmc.logManager.GetDB()
825824

826-
row, err := db.Query(context.Background(), sql, requestId)
825+
row := db.QueryRow(context.Background(), sql, requestId)
827826
rec := abTestingTableRow{}
828-
if err != nil {
829-
return rec, err
830-
}
827+
831828
errScan := row.Scan(
832829
&rec.requestID, &rec.requestPath, &rec.requestIndexName,
833830
&rec.requestBody, &rec.responseBTime, &rec.responseBError, &rec.responseBName, &rec.responseBBody,
@@ -841,10 +838,6 @@ func (qmc *QuesmaManagementConsole) abTestingReadRow(requestId string) (abTestin
841838
return rec, errScan
842839
}
843840

844-
if row.Err() != nil {
845-
return rec, row.Err()
846-
}
847-
848841
return rec, nil
849842
}
850843

0 commit comments

Comments
 (0)