],
]);
- $this->set(compact('software'));
- $this->set('_serialize', ['software']);
+ $averageStatistics = $this->getAverageStatistics();
+
+ $this->set(compact(['software','averageStatistics']));
+
+ $this->set('_serialize', ['software','averageStatistics']);
}
// no id specified => ALL software listed
$this->set('_serialize', ['softwares', 'pagination', 'paging']);
}
+ protected function getAverageStatistics () {
+
+ $tableAverageStatistics = TableRegistry::get("statistics_averages");
+
+ $LastAverageStatistics = $tableAverageStatistics->find("all")->last();
+
+ return $LastAverageStatistics;
+
+ }
+
public function initialize() {
parent::initialize();
--- /dev/null
+<?php
+namespace App\Model\Entity;
+
+use Cake\ORM\Entity;
+
+/**
+ * StatisticsAverage Entity
+ *
+ * @property int $id
+ * @property float $delta_commit_one_month
+ * @property float $delta_commit_twelve_month
+ * @property float $number_of_contributors
+ * @property \Cake\I18n\Time $created
+ * @property \Cake\I18n\Time $modified
+ */
+class StatisticsAverage extends Entity
+{
+
+ /**
+ * Fields that can be mass assigned using newEntity() or patchEntity().
+ *
+ * Note that when '*' is set to true, this allows all unspecified fields to
+ * be mass assigned. For security purposes, it is advised to set '*' to false
+ * (or remove it), and explicitly make individual fields accessible as needed.
+ *
+ * @var array
+ */
+ protected $_accessible = [
+ '*' => true,
+ 'id' => false
+ ];
+}
--- /dev/null
+<?php
+namespace App\Model\Table;
+
+use Cake\ORM\Query;
+use Cake\ORM\RulesChecker;
+use Cake\ORM\Table;
+use Cake\Validation\Validator;
+
+/**
+ * StatisticsAverages Model
+ *
+ * @method \App\Model\Entity\StatisticsAverage get($primaryKey, $options = [])
+ * @method \App\Model\Entity\StatisticsAverage newEntity($data = null, array $options = [])
+ * @method \App\Model\Entity\StatisticsAverage[] newEntities(array $data, array $options = [])
+ * @method \App\Model\Entity\StatisticsAverage|bool save(\Cake\Datasource\EntityInterface $entity, $options = [])
+ * @method \App\Model\Entity\StatisticsAverage patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
+ * @method \App\Model\Entity\StatisticsAverage[] patchEntities($entities, array $data, array $options = [])
+ * @method \App\Model\Entity\StatisticsAverage findOrCreate($search, callable $callback = null)
+ *
+ * @mixin \Cake\ORM\Behavior\TimestampBehavior
+ */
+class StatisticsAveragesTable extends Table
+{
+
+ /**
+ * Initialize method
+ *
+ * @param array $config The configuration for the Table.
+ * @return void
+ */
+ public function initialize(array $config)
+ {
+ parent::initialize($config);
+
+ $this->table('statistics_averages');
+ $this->displayField('id');
+ $this->primaryKey('id');
+
+ $this->addBehavior('Timestamp');
+ }
+
+ /**
+ * Default validation rules.
+ *
+ * @param \Cake\Validation\Validator $validator Validator instance.
+ * @return \Cake\Validation\Validator
+ */
+ public function validationDefault(Validator $validator)
+ {
+ $validator
+ ->integer('id')
+ ->allowEmpty('id', 'create');
+
+ $validator
+ ->numeric('delta_commit_one_month')
+ ->requirePresence('delta_commit_one_month', 'create')
+ ->notEmpty('delta_commit_one_month');
+
+ $validator
+ ->numeric('delta_commit_twelve_month')
+ ->requirePresence('delta_commit_twelve_month', 'create')
+ ->notEmpty('delta_commit_twelve_month');
+
+ $validator
+ ->numeric('number_of_contributors')
+ ->requirePresence('number_of_contributors', 'create')
+ ->notEmpty('number_of_contributors');
+
+ return $validator;
+ }
+}
--- /dev/null
+<?php
+namespace App\Test\Fixture;
+
+use Cake\TestSuite\Fixture\TestFixture;
+
+/**
+ * StatisticsAveragesFixture
+ *
+ */
+class StatisticsAveragesFixture extends TestFixture
+{
+
+ /**
+ * Fields
+ *
+ * @var array
+ */
+ // @codingStandardsIgnoreStart
+ public $fields = [
+ 'id' => ['type' => 'integer', 'length' => 10, 'autoIncrement' => true, 'default' => null, 'null' => false, 'comment' => null, 'precision' => null, 'unsigned' => null],
+ 'delta_commit_one_month' => ['type' => 'float', 'length' => null, 'default' => null, 'null' => false, 'comment' => null, 'precision' => null, 'unsigned' => null],
+ 'delta_commit_twelve_month' => ['type' => 'float', 'length' => null, 'default' => null, 'null' => false, 'comment' => null, 'precision' => null, 'unsigned' => null],
+ 'number_of_contributors' => ['type' => 'float', 'length' => null, 'default' => null, 'null' => false, 'comment' => null, 'precision' => null, 'unsigned' => null],
+ 'created' => ['type' => 'timestamp', 'length' => null, 'default' => null, 'null' => false, 'comment' => null, 'precision' => null],
+ 'modified' => ['type' => 'timestamp', 'length' => null, 'default' => null, 'null' => true, 'comment' => null, 'precision' => null],
+ '_constraints' => [
+ 'primary' => ['type' => 'primary', 'columns' => ['id'], 'length' => []],
+ ],
+ ];
+ // @codingStandardsIgnoreEnd
+
+ /**
+ * Records
+ *
+ * @var array
+ */
+ public $records = [
+ [
+ 'id' => 1,
+ 'delta_commit_one_month' => 1,
+ 'delta_commit_twelve_month' => 1,
+ 'number_of_contributors' => 1,
+ 'created' => 1470408066,
+ 'modified' => 1470408066
+ ],
+ ];
+}
--- /dev/null
+<?php
+namespace App\Test\TestCase\Model\Table;
+
+use App\Model\Table\StatisticsAveragesTable;
+use Cake\ORM\TableRegistry;
+use Cake\TestSuite\TestCase;
+
+/**
+ * App\Model\Table\StatisticsAveragesTable Test Case
+ */
+class StatisticsAveragesTableTest extends TestCase
+{
+
+ /**
+ * Test subject
+ *
+ * @var \App\Model\Table\StatisticsAveragesTable
+ */
+ public $StatisticsAverages;
+
+ /**
+ * Fixtures
+ *
+ * @var array
+ */
+ public $fixtures = [
+ 'app.statistics_averages'
+ ];
+
+ /**
+ * setUp method
+ *
+ * @return void
+ */
+ public function setUp()
+ {
+ parent::setUp();
+ $config = TableRegistry::exists('StatisticsAverages') ? [] : ['className' => 'App\Model\Table\StatisticsAveragesTable'];
+ $this->StatisticsAverages = TableRegistry::get('StatisticsAverages', $config);
+ }
+
+ /**
+ * tearDown method
+ *
+ * @return void
+ */
+ public function tearDown()
+ {
+ unset($this->StatisticsAverages);
+
+ parent::tearDown();
+ }
+
+ /**
+ * Test initialize method
+ *
+ * @return void
+ */
+ public function testInitialize()
+ {
+ $this->markTestIncomplete('Not implemented yet.');
+ }
+
+ /**
+ * Test validationDefault method
+ *
+ * @return void
+ */
+ public function testValidationDefault()
+ {
+ $this->markTestIncomplete('Not implemented yet.');
+ }
+}