mirror of
https://github.com/ddworken/hishtory.git
synced 2025-06-24 14:01:46 +02:00
Update custom column support to also automatically retry DB errors to further harden against issues like #119
This commit is contained in:
parent
5f9ff9e158
commit
f8b515c328
@ -4,6 +4,7 @@ import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"context"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
@ -937,15 +938,17 @@ func parseAtomizedToken(ctx context.Context, token string) (string, any, any, er
|
||||
|
||||
func getAllCustomColumnNames(ctx context.Context) ([]string, error) {
|
||||
db := hctx.GetDb(ctx)
|
||||
query := `
|
||||
SELECT DISTINCT json_extract(value, '$.name') as cc_name
|
||||
FROM history_entries
|
||||
JOIN json_each(custom_columns)
|
||||
WHERE value IS NOT NULL
|
||||
LIMIT 10`
|
||||
rows, err := db.Raw(query).Rows()
|
||||
rows, err := RetryingDbFunctionWithResult(func() (*sql.Rows, error) {
|
||||
query := `
|
||||
SELECT DISTINCT json_extract(value, '$.name') as cc_name
|
||||
FROM history_entries
|
||||
JOIN json_each(custom_columns)
|
||||
WHERE value IS NOT NULL
|
||||
LIMIT 10`
|
||||
return db.Raw(query).Rows()
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("failed to query for list of custom columns: %v", err)
|
||||
}
|
||||
ccNames := make([]string, 0)
|
||||
for rows.Next() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user