Open DavidRoy opened 1 year ago
Hello again. How is this task going? I have several users that would like to change, training mode surveys into live surveys to appear properly on the website and database.
with to_change as (
select p.id p_id, p.training p_training, s.id s_id, s.training, o.id o_id, o.training
from cache_samples_functional s
join cache_occurrences_functional o
on o.sample_id = s.id
join cache_samples_functional p
on p.id = s.parent_sample_id
where s.created_by_id = 326171
and s.survey_id = 562
order by s.parent_sample_id
),
update_o as (
update occurrences o
set training = false, updated_on = now(), updated_by_id = 2
from to_change
where to_change.o_id = o.id
),
update_s as (
update samples s
set training = false, updated_on = now(), updated_by_id = 2
from to_change
where to_change.s_id = s.id
),
update_s as (
update samples p
set training = false, updated_on = now(), updated_by_id = 2
from to_change
where to_change.p_id = p.id
),
update_p_cache as (
insert into work_queue(task, entity, record_id, params, cost_estimate, priority, created_on)
select distinct on (p_id) 'task_cache_builder_update', 'sample', p_id, null, 100, 2, now()
from to_change
order by p_id
),
update_s_cache as (
insert into work_queue(task, entity, record_id, params, cost_estimate, priority, created_on)
select distinct on (s_id) 'task_cache_builder_update', 'sample', s_id, null, 100, 2, now()
from to_change
order by s_id
),
update_o_cache as (
insert into work_queue(task, entity, record_id, params, cost_estimate, priority, created_on)
select 'task_cache_builder_update', 'occurrence', o_id, null, 100, 2, now()
from to_change
order by o_id
)
select * from work_queue
with to_change as (
select p.id p_id, p.training p_training, s.id s_id, s.training, o.id o_id, o.training
from cache_samples_functional s
join cache_occurrences_functional o
on o.sample_id = s.id
join cache_samples_functional p
on p.id = s.parent_sample_id
where s.created_by_id = 297313
and s.survey_id = 565
and s.training = true
order by s.parent_sample_id
)
where s.created_by_id = 332002
and s.training = true
where p.location_id = 240215
and s.survey_id = 562
and o.training = true
This completes all the actions requested in this issue.
Request to transfer some counts that were made on training mode to 'live'
240215 - A Rocha Cruzinha I 240222 - A Rocha Cruzinha II 243008 - Mata dos Sete Montes 240301 - Parque Ambiental de Santa Margarida 256572 - ICNF PNA Serra do Louro 272901 - ICNF RNES Gambia