but what im not sure, is how i can configure this notifications, i asume should be a query in postgresql to get the values? or should i create one workflow per notification?
Seems like I'm replying to you in several threads this morning haha
Wanted to link @sophie's video here Retool Workflows - as I think some of the data problems might be resolved after copying some of the syntax in the video.
Could you potentially use a web hook? I also think it'd be nice if there were multiple start blocks
and with the app itself? you think is possible? or at least how i can create a query to get or to know if something if expiring 60 days before or 30 days etc?
You can certainly write a query based on date as you initially tried - it may be that the query itself isn't correct...I will try to look further into this for you as soon as I can.
You could write the query in a way that it looks at today's date and compares it to the seguro_expiracion date value and say if greater than or equal to 60 send a notification...
So for example....
select * from vehiculos where {{moment()}} - seguro_expiraction = 60
or try select * from vehiculos where seguro_expiraction = (current_date - interval '60 days')
SELECT
seguro_expiracion_date,
case when seguro_expiracion_date between now() - Interval ' 30 Day'
and now() then 'Last 30 days' when seguro_expiracion _date between now() - Interval ' 60 Day'
and now() then 'Last 60 days'
from vehiculos
SELECT seguro_expiracion_date,
CASE
when seguro_expiracion_date between now() - Interval ' 30 Day'
and now() then 'Last 30 days'
when seguro_expiracion _date between now() - Interval ' 60 Day'
and now() then 'Last 60 days'
END
from vehiculos
SELECT seguro_expiracion_date,
CASE
when seguro_expiracion_date between CURRENT_DATE - Interval ' 30 Day'
and CURRENT_DATE then 'Last 30 days'
when seguro_expiracion_date between CURRENT_DATE - Interval ' 60 Day'
and CURRENT_DATE then 'Last 60 days'
END
from vehiculos
I think select * from vehiculos where seguro_expiraction = (current_date - interval '60 days') should work but October has 31 days so 2022-10-22 is actually 61 days before 2022-12-22. You could do something like
select
*
from
vehiculos
where
seguro_expiraction = (current_date - interval '60 days')
or seguro_expiraction = (current_date - interval '30 days')
or seguro_expiraction = (current_date - interval '15 days')
(Note: If you want to send these notifications before the expiration date you might need to switch from - to + I could me misunderstanding here but just want to make sure )
If you only want to send one notification it might be important to use = instead of <= or between so you don't end up with duplicate notifications... Unless you have some way to mark which notifications have already been sent for a particular renewal date!