Esempio n. 1
0
 public static function getInstance()
 {
     if (empty(self::$instance)) {
         self::$instance = new Database_Sprint();
     }
     return self::$instance;
 }
Esempio n. 2
0
 public function testHistory()
 {
     $database = Database_Sprint::getInstance();
     // Expect no history at all for January 2014.
     $history = $database->getHistory("phpunit", 2014, 1);
     $this->assertEquals(array(), $history);
     // Log values for January 2014, and check that the database returns those values.
     $database->logHistory("phpunit", 2014, 1, 10, 15, 50);
     $history = $database->getHistory("phpunit", 2014, 1);
     $standard = array(array('day' => 10, 'tasks' => 15, 'complete' => 50));
     $this->assertEquals($standard, $history);
     // Log values for February 2014, and don't expect them when requesting the history for January ...
     $database->logHistory("phpunit", 2014, 2, 10, 15, 51);
     $history = $database->getHistory("phpunit", 2014, 1);
     $standard = array(array('day' => 10, 'tasks' => 15, 'complete' => 50));
     $this->assertEquals($standard, $history);
     // ... but get those values when requesting history for February.
     $history = $database->getHistory("phpunit", 2014, 2);
     $standard = array(array('day' => 10, 'tasks' => 15, 'complete' => 51));
     $this->assertEquals($standard, $history);
     // Log another history entry for January 2014, and expect two correct entries for this month.
     $database->logHistory("phpunit", 2014, 1, 11, 16, 55);
     $history = $database->getHistory("phpunit", 2014, 1);
     $standard = array(array('day' => 10, 'tasks' => 15, 'complete' => 50), array('day' => 11, 'tasks' => 16, 'complete' => 55));
     $this->assertEquals($standard, $history);
 }
Esempio n. 3
0
 public static function createTextBasedBurndownChart($bible, $year, $month)
 {
     // Number of days in the month for on the X-axis.
     $time = mktime(0, 0, 0, $month, 15, $year);
     $days_in_month = date("t", $time);
     // Assemble history of this sprint.
     $database_sprint = Database_Sprint::getInstance();
     $history = $database_sprint->getHistory($bible, $year, $month);
     $data = array();
     for ($day = 1; $day <= $days_in_month; $day++) {
         if (Filter_Datetime::isBusinessDay($year, $month, $day)) {
             $data[$day] = "";
             foreach ($history as $item) {
                 if ($day == $item['day']) {
                     $tasks = $item['tasks'];
                     $complete = $item['complete'];
                     $tasks = $tasks * (100 - $complete) / 100;
                     $tasks = intval($tasks);
                     $data[$day] = $tasks;
                 }
             }
         }
     }
     unset($item);
     $lines = array();
     $lines[] = '<table style="text-align:center;">';
     $lines[] = '<tr style="vertical-align: bottom;">';
     foreach ($data as $day => $tasks) {
         $text = str_repeat("▓<br>", intval($tasks));
         $lines[] = "<td>{$text}</td>";
     }
     $lines[] = "</tr>";
     // Write number of days along the x-axis.
     $lines[] = '<tr>';
     foreach ($data as $day => $tasks) {
         $lines[] = "<td style=\"width:1em\">{$day}</td>";
     }
     $lines[] = "</tr>";
     // Write "days" below the x-axis.
     $lines[] = '<tr>';
     $columncount = count($data);
     $text = Locale_Translate::_("days");
     $lines[] = "<td colspan=\"{$columncount}\">{$text}</td>";
     $lines[] = "</tr>";
     $lines[] = "</table>";
     $chart = implode("\n", $lines);
     return $chart;
 }
Esempio n. 4
0
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.

This program 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 this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
include "utils.php";
ob_start();
require_once "../database/sqlite.php";
require_once "../database/sqliteinjection.php";
require_once "../database/sprint.php";
$database_sprint = Database_Sprint::getInstance();
$database_sprint->create();
$okay = !ob_get_flush();
display_header($okay);
if ($okay) {
    display_okay();
    display_paragraph("Sprint database okay.");
} else {
    display_paragraph("Errors creating or upgrading the sprint database");
    open_paragraph();
    display_link("check1.php", "Retry");
    close_paragraph();
}
display_footer();
Esempio n. 5
0
 public function testOptimize()
 {
     $database = Database_Sprint::getInstance();
     $database->optimize();
 }