Skip to content

Commit

Permalink
Fix A/B testing console (#1238)
Browse files Browse the repository at this point in the history
This  PR brings the A/B console back to life.
  • Loading branch information
nablaone authored Jan 31, 2025
1 parent 70a4dc4 commit 288da8e
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions quesma/quesma/ui/ab_testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,8 @@ func (qmc *QuesmaManagementConsole) hasABTestingTable() bool {

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

row, err := db.Query(context.Background(), sql)
row := db.QueryRow(context.Background(), sql)
var count int
if err != nil {
logger.Error().Err(err).Msg("Error checking for ab_testing_logs table")
return false
}
if errScan := row.Scan(&count); errScan != nil {
logger.Error().Err(errScan).Msg("Error scanning for ab_testing_logs table")
return false
Expand Down Expand Up @@ -335,6 +331,7 @@ GROUP BY
return nil, err
}

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

defer rows.Close()
var result []abTestingPanelDetailsRow
for rows.Next() {

Expand Down Expand Up @@ -692,6 +690,7 @@ func (qmc *QuesmaManagementConsole) abTestingReadMismatchDetails(dashboardId, pa
return nil, err
}

defer rows.Close()
var result []abTestingMismatchDetailsRow
for rows.Next() {

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

db := qmc.logManager.GetDB()

row, err := db.Query(context.Background(), sql, requestId)
row := db.QueryRow(context.Background(), sql, requestId)
rec := abTestingTableRow{}
if err != nil {
return rec, err
}

errScan := row.Scan(
&rec.requestID, &rec.requestPath, &rec.requestIndexName,
&rec.requestBody, &rec.responseBTime, &rec.responseBError, &rec.responseBName, &rec.responseBBody,
Expand All @@ -841,10 +838,6 @@ func (qmc *QuesmaManagementConsole) abTestingReadRow(requestId string) (abTestin
return rec, errScan
}

if row.Err() != nil {
return rec, row.Err()
}

return rec, nil
}

Expand Down

0 comments on commit 288da8e

Please sign in to comment.