gforge-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gforge-commits] gforge/common/reporting ReportGroupAdded.class, NONE, 1


From: cbayle
Subject: [Gforge-commits] gforge/common/reporting ReportGroupAdded.class, NONE, 1.1 ReportGroupCum.class, NONE, 1.1 ReportSetup.class, 1.1, 1.2
Date: Fri, 15 Oct 2004 14:53:21 -0500

Update of /cvsroot/gforge/gforge/common/reporting
In directory db.perdue.net:/tmp/cvs-serv26588/common/reporting

Modified Files:
        ReportSetup.class 
Added Files:
        ReportGroupAdded.class ReportGroupCum.class 
Log Message:
Add Projects (Groups) reporting 


--- NEW FILE: ReportGroupAdded.class ---
<?php
/**
 * Reporting System
 *
 * Copyright 2004 (c) GForge LLC
 *
 * @version   $Id: ReportGroupAdded.class,v 1.1 2004/10/15 19:53:18 cbayle Exp $
 * @author Tim Perdue address@hidden
 * @date 2003-03-16
 *
 * This file is part of GForge.
 *
 * GForge is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * GForge is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with GForge; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

require_once('common/reporting/Report.class');

class ReportGroupAdded extends Report {

function ReportGroupAdded($span,$start=0,$end=0) {
        $this->Report();

        if (!$start) {
                $start=mktime(0,0,0,date('m'),1,date('Y'));;
        }
        if (!$end) {
                $end=time();
        } else {
                $end--;
        }

        if (!$span || $span == REPORT_TYPE_MONTHLY) {

                $res=db_query("SELECT * FROM rep_groups_added_monthly 
                        WHERE month BETWEEN '$start' AND '$end' ORDER BY 
month");

        } elseif ($span == REPORT_TYPE_WEEKLY) {

                $res=db_query("SELECT * FROM rep_groups_added_weekly 
                        WHERE week BETWEEN '$start' AND '$end' ORDER BY week");

        } elseif ($span == REPORT_TYPE_DAILY) {

                $res=db_query("SELECT * FROM rep_groups_added_daily 
                        WHERE day BETWEEN '$start' AND '$end' ORDER BY day 
ASC");

        }

        $this->start_date=$start;
        $this->end_date=$end;

        if (!$res || db_error()) {
                $this->setError('ReportGroupAdded:: '.db_error());
                return false;
        }
        $this->setSpan($span);
        $this->setDates($res,0);
        $this->setData($res,1);
        return true;
}

}

?>

--- NEW FILE: ReportGroupCum.class ---
<?php
/**
 * Reporting System
 *
 * Copyright 2004 (c) GForge LLC
 *
 * @version   $Id: ReportGroupCum.class,v 1.1 2004/10/15 19:53:18 cbayle Exp $
 * @author Tim Perdue address@hidden
 * @date 2003-03-16
 *
 * This file is part of GForge.
 *
 * GForge is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * GForge is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with GForge; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

require_once('common/reporting/Report.class');

class ReportGroupCum extends Report {

function ReportGroupCum($span,$start=0,$end=0) {
        $this->Report();

        if (!$start) {
                $start=mktime(0,0,0,date('m'),1,date('Y'));;
        }
        if (!$end) {
                $end=time();
        } else {
                $end--;
        }

        if (!$span || $span == REPORT_TYPE_MONTHLY) {

                $res=db_query("SELECT * FROM rep_groups_cum_monthly 
                        WHERE month BETWEEN '$start' AND '$end' ORDER BY 
month");

        } elseif ($span == REPORT_TYPE_WEEKLY) {

                $res=db_query("SELECT * FROM rep_groups_cum_weekly 
                        WHERE week BETWEEN '$start' AND '$end' ORDER BY week");

        } elseif ($span == REPORT_TYPE_DAILY) {

                $res=db_query("SELECT * FROM rep_groups_cum_daily 
                        WHERE day BETWEEN '$start' AND '$end' ORDER BY day 
ASC");

        }

        $this->start_date=$start;
        $this->end_date=$end;

        if (!$res || db_error()) {
                $this->setError('ReportGroupAdded:: '.db_error());
                return false;
        }
        $this->setSpan($span);
        $this->setDates($res,0);
        $this->setData($res,1);
        return true;
}

}

?>

Index: ReportSetup.class
===================================================================
RCS file: /cvsroot/gforge/gforge/common/reporting/ReportSetup.class,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ReportSetup.class   28 Jul 2004 17:31:26 -0000      1.1
+++ ReportSetup.class   15 Oct 2004 19:53:18 -0000      1.2
@@ -102,6 +102,38 @@
        month int not null primary key,
        total int not null default 0);";
 
+//added groups
+       $sql[]="DROP TABLE rep_groups_added_daily;";
+       $sql[]="CREATE TABLE rep_groups_added_daily (
+       day int not null primary key,
+       added int not null default 0);";
+
+       $sql[]="DROP TABLE rep_groups_added_weekly";
+       $sql[]="CREATE TABLE rep_groups_added_weekly (
+       week int not null primary key,
+       added int not null default 0);";
+
+       $sql[]="DROP TABLE rep_groups_added_monthly";
+       $sql[]="CREATE TABLE rep_groups_added_monthly (
+       month int not null primary key,
+       added int not null default 0);";
+
+//cumulative groups
+       $sql[]="DROP TABLE rep_groups_cum_daily";
+       $sql[]="CREATE TABLE rep_groups_cum_daily (
+       day int not null primary key,
+       total int not null default 0);";
+
+       $sql[]="DROP TABLE rep_groups_cum_weekly";
+       $sql[]="CREATE TABLE rep_groups_cum_weekly (
+       week int not null primary key,
+       total int not null default 0);";
+
+       $sql[]="DROP TABLE rep_groups_cum_monthly";
+       $sql[]="CREATE TABLE rep_groups_cum_monthly (
+       month int not null primary key,
+       total int not null default 0);";
+
 //per-user activity
        $sql[]="DROP TABLE rep_user_act_daily";
        $sql[]="CREATE TABLE rep_user_act_daily (
@@ -303,6 +335,24 @@
        if (!$this->backfill_users_cum_monthly()) {
                return false;
        }
+       if (!$this->backfill_groups_added_daily()) {
+               return false;
+       }
+       if (!$this->backfill_groups_added_weekly()) {
+               return false;
+       }
+       if (!$this->backfill_groups_added_monthly()) {
+               return false;
+       }
+       if (!$this->backfill_groups_cum_daily()) {
+               return false;
+       }
+       if (!$this->backfill_groups_cum_weekly()) {
+               return false;
+       }
+       if (!$this->backfill_groups_cum_monthly()) {
+               return false;
+       }
        if (!$this->backfill_user_act_daily()) {
                return false;
        }
@@ -408,6 +458,49 @@
 }
 
 /**
+ *     Add a row to the groups_added_daily report table.
+ *
+ *     @param  int     Day - the unix time of the beginning of the day.
+ *     @return boolean Success.
+ */
+function groups_added_daily($day) {
+       db_query("DELETE FROM rep_groups_added_daily WHERE day='$day'");
+
+       $sql="INSERT INTO rep_groups_added_daily (day,added) 
+               VALUES ('$day',(SELECT count(*) FROM groups WHERE status='A' 
AND register_time 
+               BETWEEN '$day' AND '". ($day + REPORT_DAY_SPAN - 1) ."' ))";
+       return db_query($sql);
+}
+
+/**
+ *     Populate the groups_added_daily report table.
+ *
+ *     @return boolean Success.
+ */
+function backfill_groups_added_daily($count=10000) {
+       $today=mktime(0,0,0,date('m'),date('d')-1,date('Y'));
+       if (!$start_date=$this->getMinDate()) {
+               $this->setError('backfill_groups_added_daily:: Could Not Get 
Start Date');
+               return false;
+       }
+       while (true) {
+               $day=($today-($i*REPORT_DAY_SPAN));
+               if (!$this->groups_added_daily($day)) {
+                       $this->setError('backfill_groups_added_daily:: Error 
adding daily row: '.db_error());
+                       return false;
+               }
+               if ($day < $start_date) {
+                       break;
+               }
+               $i++;
+               if ($i >= $count) {
+                       break;
+               }
+       }
+       return true;
+}
+
+/**
  *  Add a row to the users_added_weekly report table.
  *
  *  @param  int Week - the unix time of the beginning of the sunday for this 
week.
@@ -444,6 +537,42 @@
 }
 
 /**
+ *  Add a row to the groups_added_weekly report table.
+ *
+ *  @param  int Week - the unix time of the beginning of the sunday for this 
week.
+ *  @return boolean Success.
+ */
+function groups_added_weekly($week) {
+       db_query("DELETE FROM rep_groups_added_weekly WHERE week='$week'");
+
+       $sql="INSERT INTO rep_groups_added_weekly (week,added)
+               VALUES ('$week',(SELECT count(*) FROM groups WHERE status='A' 
AND register_time
+               BETWEEN '$week' AND '". ($week+REPORT_WEEK_SPAN-1) ."' ))";
+       return db_query($sql);
+}
+
+/**
+ *  Populate the users_added_weekly report table.
+ *
+ *  @return boolean Success.
+ */
+function backfill_groups_added_weekly($count=10000) {
+
+       $arr =& $this->getWeekStartArr();
+
+       for ($i=0; $i<count($arr); $i++) {
+               if (!$this->groups_added_weekly($arr[$i])) {
+                       $this->setError('backfill_groups_added_weekly:: Error 
adding weekly row: '.db_error());
+                       return false;
+               }
+               if ($i >= $count) {
+                       break;
+               }
+       }
+       return true;
+}
+
+/**
  *  Add a row to the users_added_monthly report table.
  *
  *  @param  int month_start - the unix time of the beginning of the month.
@@ -481,6 +610,44 @@
        return true;
 }
 
+/**
+ *  Add a row to the groups_added_monthly report table.
+ *
+ *  @param  int month_start - the unix time of the beginning of the month.
+ *  @param  int month_end - the unix time of the end of the month.
+ *  @return boolean Success.
+ */
+function groups_added_monthly($month,$end) {
+       db_query("DELETE FROM rep_groups_added_monthly WHERE month='$month'");
+
+       $sql="INSERT INTO rep_groups_added_monthly (month,added)
+               VALUES ('$month',(SELECT count(*) FROM groups WHERE status='A' 
AND register_time
+               BETWEEN '$month' AND '$end' ))";
+       return db_query($sql);
+}
+
+/**
+ *  Populate the groups_added_monthly report table.
+ *
+ *  @return boolean Success.
+ */
+function backfill_groups_added_monthly($count=10000) {
+
+       $arr =& $this->getMonthStartArr();
+
+//skipping first one
+       for ($i=1; $i<count($arr); $i++) {
+               if (!$this->groups_added_monthly($arr[$i],($arr[$i-1]-1))) {
+                       $this->setError('backfill_groups_added_monthly:: Error 
adding monthly row: '.db_error());
+                       return false;
+               }
+               if ($i >= $count) {
+                       break;
+               }
+       }
+       return true;
+}
+
 
 // ******************************
 
@@ -529,6 +696,49 @@
 }
 
 /**
+ *     Add a row to the groups_cum_daily report table.
+ *
+ *     @param  int     Day - the unix time of the beginning of the day.
+ *     @return boolean Success.
+ */
+function groups_cum_daily($day) {
+       db_query("DELETE FROM rep_groups_cum_daily WHERE day='$day'");
+
+       $sql="INSERT INTO rep_groups_cum_daily (day,total) 
+               VALUES ('$day',(SELECT count(*) FROM groups WHERE status='A' 
AND register_time 
+               BETWEEN '0' AND '$day'))";
+       return db_query($sql);
+}
+
+/**
+ *     Populate the groups_cum_daily report table.
+ *
+ *     @return boolean Success.
+ */
+function backfill_groups_cum_daily($count=10000) {
+       $today=mktime(0,0,0,date('m'),date('d')-1,date('Y'));
+       if (!$start_date=$this->getMinDate()) {
+               $this->setError('backfill_groups_cum_daily:: Could Not Get 
Start Date');
+               return false;
+       }
+       while (true) {
+               $day=$today-($i*REPORT_DAY_SPAN);
+               if (!$this->groups_cum_daily($day)) {
+                       $this->setError('backfill_groups_cum_daily:: Error 
adding daily row: '.db_error());
+                       return false;
+               }
+               if ($day < $start_date) {
+                       break;
+               }
+               $i++;
+               if ($i >= $count) {
+                       break;
+               }
+       }
+       return true;
+}
+
+/**
  *  Add a row to the users_cum_weekly report table.
  *
  *  @param  int Week - the unix time of the beginning of the sunday for this 
week.
@@ -553,7 +763,7 @@
        $arr =& $this->getWeekStartArr();
 
        for ($i=0; $i<count($arr); $i++) {
-               if (!$this->users_cum_weekly($arr[$i])) {
+               if (!$this->groups_cum_weekly($arr[$i])) {
                        $this->setError('backfill_users_cum_weekly:: Error 
adding weekly row: '.db_error());
                        return false;
                }
@@ -565,6 +775,42 @@
 }
 
 /**
+ *  Add a row to the groups_cum_weekly report table.
+ *
+ *  @param  int Week - the unix time of the beginning of the sunday for this 
week.
+ *  @return boolean Success.
+ */
+function groups_cum_weekly($week) {
+       db_query("DELETE FROM rep_groups_cum_weekly WHERE week='$week'");
+
+       $sql="INSERT INTO rep_groups_cum_weekly (week,total)
+               VALUES ('$week',(SELECT count(*) FROM groups WHERE status='A' 
AND register_time
+               BETWEEN '0' AND '". ($week+REPORT_WEEK_SPAN-1 ). "'))";
+       return db_query($sql);
+}
+
+/**
+ *  Populate the groups_cum_weekly report table.
+ *
+ *  @return boolean Success.
+ */
+function backfill_groups_cum_weekly($count=10000) {
+
+       $arr =& $this->getWeekStartArr();
+
+       for ($i=0; $i<count($arr); $i++) {
+               if (!$this->users_cum_weekly($arr[$i])) {
+                       $this->setError('backfill_groups_cum_weekly:: Error 
adding weekly row: '.db_error());
+                       return false;
+               }
+               if ($i >= $count) {
+                       break;
+               }
+       }
+       return true;
+}
+
+/**
  *  Add a row to the users_cum_monthly report table.
  *
  *  @param  int month_start - the unix time of the beginning of the month.
@@ -602,6 +848,44 @@
        return true;
 }
 
+/**
+ *  Add a row to the groups_cum_monthly report table.
+ *
+ *  @param  int month_start - the unix time of the beginning of the month.
+ *  @param  int month_end - the unix time of the end of the month.
+ *  @return boolean Success.
+ */
+function groups_cum_monthly($month,$end) {
+       db_query("DELETE FROM rep_groups_cum_monthly WHERE month='$month'");
+
+       $sql="INSERT INTO rep_groups_cum_monthly (month,total)
+               VALUES ('$month',(SELECT count(*) FROM groups WHERE status='A' 
AND register_time
+               BETWEEN '0' AND '$end'))";
+       return db_query($sql);
+}
+
+/**
+ *  Populate the groups_cum_monthly report table.
+ *
+ *  @return boolean Success.
+ */
+function backfill_groups_cum_monthly($count=10000) {
+
+       $arr =& $this->getMonthStartArr();
+
+//skip first one
+       for ($i=1; $i<count($arr); $i++) {
+               if (!$this->groups_cum_monthly($arr[$i],($arr[$i-1]-1))) {
+                       $this->setError('backfill_groups_cum_monthly:: Error 
adding monthly row: '.db_error());
+                       return false;
+               }
+               if ($i >= $count) {
+                       break;
+               }
+       }
+       return true;
+}
+
 
 // ************************
 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]