 		CREATE TEMP TABLE _to_agg AS
 
 		WITH RECURSIVE region_tree AS
-		    (
-		    -- non-recursive term ( rows where the components aren't
-		    -- master_indicators in another calculation )
+				(
+				-- non-recursive term ( rows where the components aren't
+				-- master_indicators in another calculation )
 
-		  	SELECT
-		  		rg.parent_region_id
-		  		,rg.id as region_id
-		  		,0 as lvl
-		  	FROM region rg
- 			WHERE EXISTS (
+				SELECT
+					rg.parent_region_id
+					,rg.id as region_id
+					,0 as lvl
+				FROM region rg
+			WHERE EXISTS (
 				SELECT 1 FROM datapoint d
 				WHERE d.region_id = rg.id
-				AND d.cache_job_id = 7130
+				AND d.cache_job_id = $1
 			)
 
-		  	UNION ALL
+				UNION ALL
 
-		  	-- recursive term --
-		  	SELECT
-		  		 r_recurs.parent_region_id
-		  		,rt.region_id
-		  		,rt.lvl + 1
-		  	FROM region AS r_recurs
-		  	INNER JOIN region_tree AS rt
-		  	ON (r_recurs.id = rt.parent_region_id)
+				-- recursive term --
+				SELECT
+					r_recurs.parent_region_id
+					,rt.region_id
+					,rt.lvl + 1
+				FROM region AS r_recurs
+				INNER JOIN region_tree AS rt
+				ON (r_recurs.id = rt.parent_region_id)
 			AND r_recurs.parent_region_id IS NOT NULL
-		    )
+				)
 
 		SELECT DISTINCT
 			d.id as datapoint_id

		AND ta.campaign_id = d.campaign_id
		AND ta.indicator_id = d.indicator_id;


		--- UPDATE THE REST OF THE DATAPOINT TABLE --

		UPDATE datapoint d
		SET cache_job_id = $1
		WHERE d.id in (

			,d.value
		FROM _to_agg d

		UNION ALL

		SELECT
			CAST(NULL AS INT) as id
			,d.parent_region_id
			,d.campaign_id
