Completed the Longterm Plugin. It seems to drain performance quite a bit though....
[onis.git] / lib / Onis / Data / Core.pm
index 701e086..0eb9230 100644 (file)
@@ -44,7 +44,7 @@ qw(
        store unsharp calculate_nicks 
 
        get_all_nicks get_channel get_main_nick nick_to_ident ident_to_nick nick_to_name
-       get_total_lines nick_rename print_output register_plugin
+       get_total_lines get_most_recent_time nick_rename print_output register_plugin
 );
 @Onis::Data::Core::ISA = ('Exporter');
 
@@ -199,6 +199,11 @@ sub store
                $counter++;
                $GeneralCounters->put ('lines_total', $counter);
 
+               my ($time) = $GeneralCounters->get ('most_recent_time');
+               $time ||= 0;
+               $time = $data->{'epoch'} if ($time < $data->{'epoch'});
+               $GeneralCounters->put ('most_recent_time', $time);
+
                $LinesThisRun++;
        }
 
@@ -645,6 +650,20 @@ sub get_total_lines
        return ($total, $LinesThisRun);
 }
 
+=item I<$epoch> = B<get_most_recent_time> ()
+
+Returns the epoch of the most recent line received from the parser.
+
+=cut
+
+sub get_most_recent_time
+{
+       my ($time) = $GeneralCounters->get ('most_recent_time');
+       $time ||= 0;
+
+       return ($time);
+}
+
 =item B<nick_rename> (I<$old_nick>, I<$new_nick>)
 
 Keeps track of a nick's hostname if the nick changes.