2heoh (2heoh) wrote in changelog,
2heoh
2heoh
changelog

[ljcom] r10795: https://jira.sup.com/browse/LJSUP-9213

Committer: slobin
https://jira.sup.com/browse/LJSUP-9213

M smsru_stats.pl
U   trunk/bin/misc/smsru_stats.pl
Modified: trunk/bin/misc/smsru_stats.pl
===================================================================
--- trunk/bin/misc/smsru_stats.pl	2011-08-04 06:27:09 UTC (rev 10794)
+++ trunk/bin/misc/smsru_stats.pl	2011-08-04 06:34:09 UTC (rev 10795)
@@ -18,7 +18,7 @@
 my $DAYS_IN_PERIOD = 7;
 my @OPERATORS = qw(ksell beeline megafon mts total);
 
-my @stat_recipients = ('dnikolaev@sup.com', 'lj_rusms_notifications_stats@sup.com');
+my @stat_recipients = ('sergey.lobin@sup.com', 'dnikolaev@sup.com', 'lj_rusms_notifications_stats@sup.com');
 
 my $now = time();
 my $time_from = $now - $SECONDS_IN_DAY * $DAYS_IN_PERIOD;
@@ -28,9 +28,10 @@
 my %USERS;
 my %PHONES;
 
-my $stats_sms = {};
-my $stats_users = {};
-my $stats_phones = {};
+my $stats_sms       = {};
+my $stats_users     = {};
+my $stats_phones    = {};
+my $stats_mts       = {};
 
 # iterate over all clusters and query for stats
 foreach my $cid (@LJ::CLUSTERS) {
@@ -48,7 +49,7 @@
 
     while (my ($userid, $to_number, $msg, $added, $msg_type) = $sth->fetchrow_array) {
 
-        next unless $msg_type =~ /[VI]/;
+        next unless $msg_type =~ /[VIPSM]/;
 
         my $provider_name = get_provider_name($to_number) || '';
 
@@ -65,6 +66,17 @@
         # Number of SMS by different types ('V' or 'I')
         $stats_day->{"T=$msg_type&P=total"}++;
         $stats_day->{"T=$msg_type&P=$provider_name"}++;
+
+        # MTS special features
+        $stats_mts->{$added}{notification}++
+            if $msg_type eq 'P';
+
+        $stats_mts->{$added}{sms}++
+            if $msg_type eq 'S';
+
+        $stats_mts->{$added}{mms}++
+            if $msg_type eq 'M';
+
     }
 }
 
@@ -108,11 +120,6 @@
     $_ = scalar keys %$_;
 }
 
-# use Data::Dumper;
-# print STDERR Dumper($stats_sms), "\n";
-# print STDERR Dumper($stats_users), "\n";
-# print STDERR Dumper($stats_phones), "\n";
-
 my $operators_count = scalar @OPERATORS;
 
 my $columns1 = [
@@ -186,6 +193,22 @@
 }
 $message .= "</table><br>\n";
 
+$message .= "<strong>MTS special features</strong>\n";
+$message .= "<table border=1>\n";
+$message .= "    <tr><td>Date</td><td>Message<br />notifications<br />with text</td><td>Messages<br />total reply</td><td>Message<br />reply via<br />SMS</td><td>Message<br />reply via<br />MMS</td></tr>";
+for (my $time = $time_from; $time < $now; $time += $SECONDS_IN_DAY) {
+    my $date = to_date($time);
+    $message .= "    <tr><td>$date</td>";
+    $message .= "<td align=center>".int($stats_mts->{$date}{notification})."</td>";
+    $message .= "<td align=center>".int($stats_mts->{$date}{sms}+$stats_mts->{$date}{mms})."</td>";
+    $message .= "<td align=center>".int($stats_mts->{$date}{sms})."</td>";
+    $message .= "<td align=center>".int($stats_mts->{$date}{mms})."</td>";
+    $message .= "</tr>\n";
+}
+$message .= "</table><br>\n";
+$message .= "<br>\n";
+
+
 $message .= "</body></html>\n";
 
 print "Sending email(s)\n" if $verbose;

Tags: 2heoh, ljcom, pl
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments