       AND values.path IS NOT NULL
       AND value = 'true';
 
-  select count(*) into ev_polling_location_errors
+  select count(*) into ev_pl_errors
   from xml_tree_validations xtv
   where xtv.path <@ ev_polling_location_paths
   and xtv.results_id = rid;

      AND values.path IS NOT NULL
      AND value = 'true';

  select count(*) into db_polling_location_errors
  from xml_tree_validations xtv
  where xtv.path <@ db_polling_location_paths
  and xtv.results_id = rid;

create function v5_dashboard.polling_locations_by_type(rid int)
returns table(results_id int,
              polling_location_count int,
              pl_errors int,
              pl_completion int,
              db_polling_location_count int,
              db_pl_errors int,
              db_pl_completion int,
              ev_polling_location_count int,
              ev_pl_errors int,
              ev_pl_completion int)
as $$
  declare
    polling_location_all_paths ltree[];
    polling_location_paths ltree[];
    polling_location_count int;
    pl_errors int;
    pl_completion int;
    db_polling_location_paths ltree[];
    db_polling_location_count int;
    db_pl_errors int;
    db_pl_completion int;
    ev_polling_location_paths ltree[];
    ev_polling_location_count int;
    ev_pl_errors int;
    ev_pl_completion int;
  begin

  select array_agg(distinct countable_path(path)) into polling_location_all_paths
