/** * Returns either an existing aggregate-bucket for a given user+month combination - or creates * a new one to which the commits can be added later on. * * @param \Mrimann\CoMo\Domain\Model\Commit $commit * @return \Mrimann\CoMo\Domain\Model\AggregatedDataPerUser|object */ public function findByCommitterAndMonth(\Mrimann\CoMo\Domain\Model\Commit $commit) { $this->initializeOurSettings(); if ($this->settings['whoGetsCredits'] == 'committer') { $email = $commit->getCommitterEmail(); $name = $commit->getCommitterName(); } else { $email = $commit->getAuthorEmail(); $name = $commit->getAuthorName(); } $query = $this->createQuery(); $query->matching($query->logicalAnd($query->equals('month', $commit->getMonthIdentifier()), $query->equals('userEmail', $email))); $query->setLimit(1); $result = $query->execute(); if ($result->count()) { $result = $result->getFirst(); } else { $result = new \Mrimann\CoMo\Domain\Model\AggregatedDataPerUser(); $result->setMonth($commit->getMonthIdentifier()); $result->setUserEmail($email); $result->setUserName($name); $this->add($result); $this->persistenceManager->persistAll(); } return $result; }
/** * @test */ public function getMonthIdentifierReturnsProperValue() { $date = new \DateTime('2013-03-01'); $this->fixture->setDate($date); $this->assertEquals($this->fixture->getMonthIdentifier(), '2013-03'); }
/** * Adds a given commit (without further checking). Adding in this case means that some counters * in this object are raised - depending on some properties of the commit. * * @param Commit $commit * @return void */ public function addCommit(\Mrimann\CoMo\Domain\Model\Commit $commit) { // Update the generic commit counter $this->commitCount++; // Update the topic commit counter, depending on the commit class of the commit switch ($commit->getCommitClass()) { case \Mrimann\CoMo\Domain\Model\Commit::CLASS_FEATURE: $this->commitCountFeature++; break; case \Mrimann\CoMo\Domain\Model\Commit::CLASS_RELEASE: $this->commitCountRelease++; break; case \Mrimann\CoMo\Domain\Model\Commit::CLASS_DOCUMENTATION: $this->commitCountDocumentation++; break; case \Mrimann\CoMo\Domain\Model\Commit::CLASS_TASK: $this->commitCountTask++; break; case \Mrimann\CoMo\Domain\Model\Commit::CLASS_BUGFIX: $this->commitCountBugfix++; break; case \Mrimann\CoMo\Domain\Model\Commit::CLASS_TEST: $this->commitCountTest++; break; case \Mrimann\CoMo\Domain\Model\Commit::CLASS_UNKNOWN: // fallthrough intended! // fallthrough intended! default: $this->commitCountUnknown++; break; } }