This repository has been archived by the owner on Sep 23, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- refactor code of Updater, - introduce activities instead of texts, - removed useless exception, - refatored creation of bundle into one BundleManager, - fixed and simplified creation of owners for background processes, - removed unused tags from bundle - fixed incomplete tests!
- Loading branch information
Showing
42 changed files
with
1,597 additions
and
830 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace Application\Migrations; | ||
|
||
use Doctrine\DBAL\Migrations\AbstractMigration, | ||
Doctrine\DBAL\Schema\Schema; | ||
|
||
/** | ||
* Auto-generated Migration: Please modify to your need! | ||
*/ | ||
class Version20121010101749 extends AbstractMigration | ||
{ | ||
public function up(Schema $schema) | ||
{ | ||
// this up() migration is autogenerated, please modify it to your needs | ||
$this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql"); | ||
|
||
$this->addSql("CREATE TABLE activities (id INT AUTO_INCREMENT NOT NULL, bundle_id INT DEFAULT NULL, developer_id INT DEFAULT NULL, type INT NOT NULL, state INT NOT NULL, createdAt DATETIME NOT NULL, message VARCHAR(255) DEFAULT NULL, author VARCHAR(255) DEFAULT NULL, bundleName VARCHAR(255) DEFAULT NULL, bundleOwnerName VARCHAR(255) DEFAULT NULL, INDEX IDX_B5F1AFE5F1FAD9D3 (bundle_id), INDEX IDX_B5F1AFE564DD9267 (developer_id), INDEX type_state (type, state), INDEX created_at (createdAt), PRIMARY KEY(id)) ENGINE = InnoDB"); | ||
$this->addSql("ALTER TABLE activities ADD CONSTRAINT FK_B5F1AFE5F1FAD9D3 FOREIGN KEY (bundle_id) REFERENCES bundle (id)"); | ||
$this->addSql("ALTER TABLE activities ADD CONSTRAINT FK_B5F1AFE564DD9267 FOREIGN KEY (developer_id) REFERENCES owner (id)"); | ||
$this->addSql("ALTER TABLE owner ADD lastCommitAt DATE DEFAULT NULL"); | ||
$this->addSql("ALTER TABLE bundle DROP lastCommits, DROP tags"); | ||
} | ||
|
||
public function down(Schema $schema) | ||
{ | ||
// this down() migration is autogenerated, please modify it to your needs | ||
$this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql"); | ||
|
||
$this->addSql("DROP TABLE activities"); | ||
$this->addSql("ALTER TABLE bundle ADD lastCommits LONGTEXT NOT NULL, ADD tags LONGTEXT NOT NULL"); | ||
$this->addSql("ALTER TABLE owner DROP lastCommitAt"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
src/Knp/Bundle/KnpBundlesBundle/Command/MigrateCommitsCommand.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
|
||
namespace Knp\Bundle\KnpBundlesBundle\Command; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Symfony\Component\Console\Output\NullOutput; | ||
|
||
use Pagerfanta\Pagerfanta; | ||
use Pagerfanta\Adapter\DoctrineORMAdapter; | ||
|
||
use Knp\Bundle\KnpBundlesBundle\Entity\Bundle; | ||
use Knp\Bundle\KnpBundlesBundle\Github\Repo; | ||
|
||
/** | ||
* @todo Remove this command on next week or so | ||
*/ | ||
class MigrateCommitsCommand extends ContainerAwareCommand | ||
{ | ||
protected function configure() | ||
{ | ||
$this | ||
->setDefinition(array()) | ||
->setName('kb:migrate:commits') | ||
; | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
/** @var $repo Repo */ | ||
$em = $this->getContainer()->get('doctrine.orm.entity_manager'); | ||
$repo = $this->getContainer()->get('knp_bundles.github_repository_api'); | ||
|
||
$page = 1; | ||
$pager = new Pagerfanta(new DoctrineORMAdapter($em->getRepository('KnpBundlesBundle:Bundle')->queryAllSortedBy('updatedAt'), false)); | ||
$pager | ||
->setMaxPerPage(100) | ||
->setCurrentPage($page, false, true) | ||
; | ||
|
||
if (1 === $page) { | ||
$this->output->writeln(sprintf('[%s] Loaded <comment>%d</comment> bundles from the DB', date('d-m-y H:i:s'), $pager->getNbResults())); | ||
} | ||
|
||
do { | ||
/** @var $bundle Bundle */ | ||
foreach ($pager as $bundle) { | ||
// Check that API not failed | ||
if (!$repo->updateCommits($bundle)) { | ||
// Sleep a while, and check again | ||
sleep(60); | ||
|
||
$repo->updateCommits($bundle); | ||
} | ||
} | ||
|
||
$this->output->writeln(sprintf('[%s] Migrated %d from %d bundles', date('d-m-y H:i:s'), $page * 100, $pager->getNbResults())); | ||
|
||
++$page; | ||
} while ($pager->haveToPaginate() && $pager->setCurrentPage($page, false, true)); | ||
|
||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.