Index: trunk/ippMonitor/czartool/czartool/CzarDb.pm
===================================================================
--- trunk/ippMonitor/czartool/czartool/CzarDb.pm	(revision 32760)
+++ trunk/ippMonitor/czartool/czartool/CzarDb.pm	(revision 32761)
@@ -8,5 +8,28 @@
 use File::Temp;
 
-my @stages = ("burntool", "chip", "cam", "fake", "warp", "stack", "diff", "magic", "magicDS", "dist", "pub"); # TODO put elsewhere
+my @stages = (
+        "burntool", 
+        "chip", 
+        "cam", 
+        "fake", 
+        "warp", 
+        "stack", 
+        "diff", 
+        "magic", 
+        "magicDS", 
+        "dist", 
+        "pub"); # TODO put elsewhere
+
+my @ippToPspsStages = (
+        "processed",
+        "loaded_to_datastore",
+        "loaded_to_ODM",
+        "merge_worthy",
+        "deleted_datastore",
+        "deleted_dxlayer",
+        "merged",
+        "deleted_local");
+
+my @allStages = (@stages, @ippToPspsStages);
 
 use base 'czartool::MySQLDb';
@@ -33,5 +56,28 @@
 ###########################################################################
 #
-# Gets current_labels table
+# Gets current ippToPsps labels
+#
+###########################################################################
+sub getCurrentIppToPspsLabels {
+    my ($self, $begin, $end, $labels) = @_;
+
+    my $query = $self->{_db}->prepare(<<SQL);
+
+    SELECT DISTINCT label
+        FROM processed
+        WHERE timestamp >= '$begin' 
+        AND timestamp <= '$end' 
+SQL
+
+    if (!$query->execute) {return 0;}
+
+    ${$labels} = $query->fetchall_arrayref();
+
+    return 1;
+}
+
+###########################################################################
+#
+# Gets current labels from the current_labels table
 #
 ###########################################################################
@@ -1107,5 +1153,5 @@
         my $stage = undef;
         $totalDeleted = 0;
-        foreach $stage (@stages) {
+        foreach $stage (@allStages) {
 
             if (!$self->getLabelsInThisTimePeriod($stage, $fromTime, $toTime, \$labels)) {next;}
@@ -1213,5 +1259,5 @@
 
     my $stage = undef;
-    foreach $stage (@stages) {
+    foreach $stage (@allStages) {
 
         $self->optimizeTable($stage);
