# have an overage badge score of zero.
my $adjusted_scale = ( $max_mult - 1.0 ) / 5.0;
- $rank = "1.0/(( $rel ) * (1.0 + (AVG(COALESCE(pop_with.total_score::NUMERIC,0.0)) * $adjusted_scale)))::NUMERIC";
+ $rank = "1.0/(( $rel ) * (1.0 + (AVG(COALESCE(pop_with.total_score::NUMERIC,0.0::NUMERIC)) * ${adjusted_scale}::NUMERIC)))::NUMERIC";
}
} elsif ($sort_filter =~ /^pop/) {
- $rank = '1.0/(AVG(COALESCE(pop_with.total_score::NUMERIC,0.0)) + 5.0)::NUMERIC';
+ $rank = '1.0/(AVG(COALESCE(pop_with.total_score::NUMERIC,0.0::NUMERIC)) + 5.0::NUMERIC)::NUMERIC';
my $pop_desc = $desc eq 'ASC' ? 'DESC' : 'ASC';
$pop_extra_sort = "3 $pop_desc $nullpos,";
} else {
$with
SELECT $key AS id,
$agg_records,
- $rel AS rel,
+ ${rel}::NUMERIC AS rel,
$rank AS rank,
FIRST(pubdate_t.value) AS tie_break,
STRING_AGG(ARRAY_TO_STRING(pop_with.badges,','),',') AS badges,
- AVG(COALESCE(pop_with.total_score::NUMERIC,0.0))::NUMERIC(2,1) AS popularity
+ AVG(COALESCE(pop_with.total_score::NUMERIC,0.0::NUMERIC))::NUMERIC(2,1) AS popularity
FROM metabib.metarecord_source_map m
$$flat_plan{from}
$mra_join
superpage_of_records := all_brecords[slice_start:slice_end];
qpfts_query :=
'SELECT NULL::BIGINT AS id, ARRAY[r] AS records, ' ||
- 'NULL AS badges, NULL AS popularity, ' ||
- '1::INT AS rel FROM (SELECT UNNEST(' ||
+ 'NULL AS badges, NULL::NUMERIC AS popularity, ' ||
+ '1::NUMERIC AS rel FROM (SELECT UNNEST(' ||
quote_literal(superpage_of_records) || '::BIGINT[]) AS r) rr';
-- We use search.query_parser_fts() for visibility testing.
superpage_of_records := all_arecords[slice_start:slice_end];
qpfts_query :=
'SELECT NULL::BIGINT AS id, ARRAY[r] AS records, ' ||
- 'NULL AS badges, NULL AS popularity, ' ||
- '1::INT AS rel FROM (SELECT UNNEST(' ||
+ 'NULL AS badges, NULL::NUMERIC AS popularity, ' ||
+ '1::NUMERIC AS rel FROM (SELECT UNNEST(' ||
quote_literal(superpage_of_records) || '::BIGINT[]) AS r) rr';
-- We use search.query_parser_fts() for visibility testing.
superpage_of_records := all_brecords[slice_start:slice_end];
qpfts_query :=
'SELECT NULL::BIGINT AS id, ARRAY[r] AS records, ' ||
- 'NULL AS badges, NULL AS popularity, ' ||
- '1::INT AS rel FROM (SELECT UNNEST(' ||
+ 'NULL AS badges, NULL::NUMERIC AS popularity, ' ||
+ '1::NUMERIC AS rel FROM (SELECT UNNEST(' ||
quote_literal(superpage_of_records) || '::BIGINT[]) AS r) rr';
-- We use search.query_parser_fts() for visibility testing.
superpage_of_records := all_arecords[slice_start:slice_end];
qpfts_query :=
'SELECT NULL::BIGINT AS id, ARRAY[r] AS records, ' ||
- 'NULL AS badges, NULL AS popularity, ' ||
- '1::INT AS rel FROM (SELECT UNNEST(' ||
+ 'NULL AS badges, NULL::NUMERIC AS popularity, ' ||
+ '1::NUMERIC AS rel FROM (SELECT UNNEST(' ||
quote_literal(superpage_of_records) || '::BIGINT[]) AS r) rr';
-- We use search.query_parser_fts() for visibility testing.