updated random value to double precision float

This commit is contained in:
Joe Lothan 2026-05-19 23:37:50 -04:00
parent 41c0eb5c49
commit 7f36e99443
3 changed files with 4 additions and 4 deletions

View file

@ -14,7 +14,7 @@ CREATE TABLE IF NOT EXISTS hosts (
iframe_allowed BOOLEAN, iframe_allowed BOOLEAN,
best_icon_s3_key TEXT, best_icon_s3_key TEXT,
parsed BOOLEAN DEFAULT FALSE, parsed BOOLEAN DEFAULT FALSE,
random_order REAL DEFAULT random() random_order DOUBLE PRECISION DEFAULT random()
); );
CREATE TABLE IF NOT EXISTS icons ( CREATE TABLE IF NOT EXISTS icons (

View file

@ -13,11 +13,11 @@ type HostRow struct {
HtmlTitle string HtmlTitle string
IframeAllowed bool IframeAllowed bool
BestIconS3Key string BestIconS3Key string
RandomOrder float32 RandomOrder float64
} }
// fetchHostsPage gets a page of hosts with titles, ordered by random_order for shuffled bundles. // fetchHostsPage gets a page of hosts with titles, ordered by random_order for shuffled bundles.
func fetchHostsPage(ctx context.Context, pool *pgxpool.Pool, lastRandom float32, limit int) ([]HostRow, error) { func fetchHostsPage(ctx context.Context, pool *pgxpool.Pool, lastRandom float64, limit int) ([]HostRow, error) {
rows, err := pool.Query(ctx, ` rows, err := pool.Query(ctx, `
SELECT id, hostname, protocol, html_title, COALESCE(iframe_allowed, true), COALESCE(best_icon_s3_key, ''), random_order SELECT id, hostname, protocol, html_title, COALESCE(iframe_allowed, true), COALESCE(best_icon_s3_key, ''), random_order
FROM hosts FROM hosts

View file

@ -120,7 +120,7 @@ func main() {
bundleCount := 0 bundleCount := 0
var totalBytes int64 var totalBytes int64
var lastRandom float32 = -1 var lastRandom float64 = -1
pageSize := cfg.EntriesPerBundle * 50 // fetch 50 bundles worth at a time pageSize := cfg.EntriesPerBundle * 50 // fetch 50 bundles worth at a time
var entryBuf []BundleEntry var entryBuf []BundleEntry
hostsProcessed := 0 hostsProcessed := 0