updated random value to double precision float
This commit is contained in:
parent
41c0eb5c49
commit
7f36e99443
3 changed files with 4 additions and 4 deletions
|
|
@ -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 (
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue