egdb3_12_9
.rating
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
bib_pub_age(badge_id integer)
Parameters
Name
Type
Mode
badge_id
integer
IN
record
bigint
TABLE
value
numeric
TABLE
Definition
DECLARE badge rating.badge_with_orgs%ROWTYPE; BEGIN SELECT * INTO badge FROM rating.badge_with_orgs WHERE id = badge_id; PERFORM rating.precalc_bibs_by_copy_or_uri(badge_id); SET LOCAL client_min_messages = error; DROP TABLE IF EXISTS precalc_bib_list; CREATE TEMP TABLE precalc_bib_list ON COMMIT DROP AS SELECT id FROM precalc_filter_bib_list INTERSECT SELECT id FROM precalc_bibs_by_copy_or_uri_list; RETURN QUERY SELECT pop.id AS bib, s.value::NUMERIC FROM precalc_bib_list pop JOIN metabib.record_sorter s ON ( s.source = pop.id AND s.attr = 'pubdate' AND s.value ~ '^\d+$' ) WHERE s.value::INT <= EXTRACT(YEAR FROM NOW())::INT; END;