Skip to content

Commit

Permalink
#1470 Del proj w/ invalid geometries
Browse files Browse the repository at this point in the history
  • Loading branch information
ramyaragupathy authored and arunasank committed May 30, 2019
1 parent a7ce079 commit 267e9d9
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions devops/database-scripts/proj-geom-cleanup.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

SELECT
projects.id
INTO TEMPORARY TABLE
project_list
FROM
projects
WHERE ST_XMin(geometry) < -180
or ST_XMax(geometry) > 180
or ST_YMin(geometry) < -90
or ST_YMax(geometry) > 90;


CREATE OR REPLACE FUNCTION delete_results()
RETURNS SETOF text AS
$func$
DECLARE
elem int;
BEGIN
FOR elem IN
SELECT * FROM project_list
LOOP
DELETE FROM public.project_info WHERE project_id = elem;
DELETE FROM public.project_chat WHERE project_id = elem;
DELETE FROM public.task_history WHERE project_id = elem;
DELETE FROM public.task_invalidation_history WHERE project_id = elem;
DELETE FROM public.tasks WHERE project_id = elem;
RETURN NEXT elem;
RAISE NOTICE 'Project: %', elem;
END LOOP;
END
$func$ LANGUAGE plpgsql;

SELECT * from delete_results()

0 comments on commit 267e9d9

Please sign in to comment.