i've been using this little function to update tickets date opened
times to match the date the message was sent, as often messages
incoming into this particular mailmanager instance have been sitting
around for a few days. my working copy of mailmanager is patched
appropriately to do this on ticket creation based on config settings,
but i thought the update function might be of use to others in and of
itself. for postgres only.
-- sets the ticket opened date to the date the first ticket message was
create or replace function mm_ticket_time_update() returns integer as '
FOR msg_info in select ticket_id, min( msg_date ) as min_date
group by ticket_id
set date_opened = msg_info.min_date
where id = msg_info.ticket_id;
END;' LANGUAGE plpgsql;
-- select mm_ticket_time_update();