Fixing logs that overlap
There's really only rather small things I'd change / adapt




CREATE OR REPLACE FUNCTION normalize_moderation_log_overflow() RETURNS INTEGER AS



Since you always return 1, this function actually should be a void.

CREATE OR REPLACE FUNCTION normalize_moderation_log_oveflow () RETURNS VOID AS




Your Indentation seems off a little:


BEGIN
    FOR logs ...
  FROM ...



I'd prefer to indent the SELECT statement in reference to the FOR .. LOOP like this:

BEGIN
  FOR logs IN SELECT ...
      FROM errors





AND error_type_id = (SELECT id FROM error_types WHERE normalizer_type = 'moderation_log_overflow')



This can (and probably should be) extracted into a constant

log_overflow CONSTANT INT := SELECT id FROM error_types WHERE normalizer_type = 'moderation_log_overflow' LIMIT 1;


Which makes the condition look like this:

AND error_type_id = log_overflow





    UPDATE errors 
    SET state = #{ Error.states[:resolved] };



All other DML statements you have are in a single line, why not this one, too?

UPDATE errors SET state = #{ Error.states[:resolved] };