Overhaul the repository link functionality
- Fix regex (repositories with number or other characters were not accepted)
- Url escape template arguments by default (the "do not escape" <%== $var %> markers can be used if needed)
- Also support a generic repository type instead of only repotype:repopath in the configuration ($repotype:$repopath has priority over $repotype if both are defined)
- Cache compiled templates
CREATE OR REPLACE FUNCTION extract_crashing_functions (processed_json jsonb) RETURNS text AS
$$
-- extract threads[crashing_idx]->frames[*]->function
SELECT string_agg(functions, E'\n')
FROM (
SELECT jsonb_array_elements(
(($1 #> ARRAY['threads', $1->'crash_info'->>'crashing_thread'])->'frames')
)->>'function' AS functions
) AS frames
$$
LANGUAGE sql IMMUTABLE;
-- This extension is the contrib modules
CREATE EXTENSION IF NOT EXISTS pg_trgm;
-- Used for searching function in the crashing thread backtrace
-- Search will be really slow if this index is not present
CREATE INDEX crash_datas_idx_extract_crashing_functions ON crash_datas USING gin (
extract_crashing_functions(processed) gin_trgm_ops
);