-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Catalog completeness #25
Open
dimensi0n
wants to merge
17
commits into
isics:master
Choose a base branch
from
dimensi0n:catalog-completeness
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 15 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
5e82226
Add design
dimensi0n 8d42e7b
Add Translation
dimensi0n c1cc253
Add completeness to Product
dimensi0n 27aa93c
Remove completeness_quality
dimensi0n 1c2da00
Add Product Insight
dimensi0n efcdc42
Add FillCompletenessCommand
dimensi0n 6faa3d2
Update FillCompletenessCommand
dimensi0n df26888
Update EntityProduct
dimensi0n a293ed4
Add edit page design
dimensi0n 3f9a314
Update FillCompletenessCommand
dimensi0n 88833c3
Update Completeness
dimensi0n f1e8f1c
Add edit form translation
dimensi0n 54547c6
Fix translation
dimensi0n 51b020b
Add Completeness estimation on edit & create
dimensi0n f2d7133
Add SendMail command
dimensi0n d30772a
Update ProductInsightManager.php
dimensi0n d0f20f8
Update edit.html.twig
dimensi0n File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
namespace Isics\Bundle\OpenMiamMiamBundle\Command; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Symfony\Component\Console\Helper\ProgressBar; | ||
use Isics\Bundle\OpenMiamMiamBundle\Entity\Product; | ||
use Isics\Bundle\OpenMiamMiamBundle\Entity\ProductInsight; | ||
|
||
class FillCompletenessCommand extends ContainerAwareCommand | ||
{ | ||
protected function configure() | ||
{ | ||
$this | ||
->setName('openmiammiam:fill-completeness') | ||
->setDescription('Fill completeness fields for products in database'); | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
$output->writeln('<comment>Computing products insights...</comment>'); | ||
$output->writeln(''); | ||
|
||
$productInsightManager = $this->getContainer()->get('open_miam_miam.product_insight_manager'); | ||
|
||
$progressBar = new ProgressBar($output, $productInsightManager->count()); | ||
$progressBar->setBarCharacter('<fg=green>•</>'); | ||
$progressBar->setEmptyBarCharacter('<fg=red>•</>'); | ||
$progressBar->setProgressCharacter('<fg=green>➤</>'); | ||
$progressBar->setFormat( | ||
"%memory% %current%/%max% [%bar%] %percent:3s%%\n Elapsed : %elapsed% Remaining : %remaining:-6s%" | ||
); | ||
|
||
$callback = function() use ($progressBar) { | ||
$progressBar->advance(1); | ||
}; | ||
|
||
$productInsightManager->updateProductInsights($callback); | ||
} | ||
|
||
} |
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,77 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the OpenMiamMiam project. | ||
* | ||
* (c) Isics <[email protected]> | ||
* | ||
* This source file is subject to the AGPL v3 license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace Isics\Bundle\OpenMiamMiamBundle\Command; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
class SendMailCompletenessCommand extends ContainerAwareCommand | ||
{ | ||
protected function configure() | ||
{ | ||
$this | ||
->setName('openmiammiam:send-mail-completeness') | ||
->setDescription('Send Mail with completeness quality info'); | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
$mailer = $this->getContainer()->get('open_miam_miam.mailer'); | ||
$translator = $mailer->getTranslator(); | ||
$translator->setLocale($this->getContainer()->getParameter('locale')); | ||
|
||
$associations = $this->getContainer() | ||
->get('doctrine.orm.entity_manager') | ||
->getRepository('IsicsOpenMiamMiamBundle:Association') | ||
->findAll(); | ||
|
||
foreach($associations as $association) | ||
{ | ||
$producers = $association->getProducers(); | ||
|
||
foreach ($producers as $producer) { | ||
/**$message = $mailer->getNewMessage(); | ||
$message | ||
->setFrom(array($association->getEmail() => $association->getName())) | ||
->setTo($this->getContainer()->get('doctrine.orm.entity_manager')->getRepository('IsicsOpenMiamMiamUserBundle:User')->findManager($producer)[0]->getEmail()) | ||
->setSubject( | ||
$mailer->translate( | ||
'mail.completeness' | ||
) | ||
) | ||
->setBody( | ||
$mailer->render($this->getContainer()->get('doctrine.orm.entity_manager')->getRepository('IsicsOpenMiamMiamUserBundle:User')->findManager($producer) | ||
'IsicsOpenMiamMiamBundle:Mail:ordersClosed.html.twig', | ||
array( | ||
'salesOrder' => $salesOrder, | ||
'branchOccurrence' => $nextBranchOccurrence | ||
) | ||
), | ||
'text/html' | ||
); | ||
|
||
$mailer->send($message); | ||
|
||
++$mailNumber; | ||
|
||
$output->writeln(sprintf('<info>- %s</info>', $this->getContainer()->get('doctrine.orm.entity_manager')->getRepository('IsicsOpenMiamMiamUserBundle:User')->findManager($producer)->getEmail()));**/ | ||
$output->writeln(var_dump($producer->getName())); | ||
$managers = $this->getContainer()->get('doctrine.orm.entity_manager')->getRepository('IsicsOpenMiamMiamUserBundle:User')->findManager($producer); | ||
$output->writeln(var_dump(count($managers))); | ||
} | ||
} | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the OpenMiamMiam project. | ||
* | ||
* (c) Isics <[email protected]> | ||
* | ||
* This source file is subject to the AGPL v3 license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace Isics\Bundle\OpenMiamMiamBundle\Entity; | ||
|
||
use Doctrine\ORM\Mapping as ORM; | ||
use Isics\Bundle\OpenMiamMiamBundle\Entity\Product; | ||
|
||
/** | ||
* ProductInsight | ||
* | ||
* @ORM\Table(name="product_insight") | ||
* @ORM\Entity(repositoryClass="Isics\Bundle\OpenMiamMiamBundle\Repository\ProductInsightRepository") | ||
*/ | ||
class ProductInsight | ||
{ | ||
/** | ||
* @var int | ||
* | ||
* @ORM\Column(name="id", type="integer") | ||
* @ORM\Id | ||
* @ORM\GeneratedValue(strategy="AUTO") | ||
*/ | ||
private $id; | ||
|
||
/** | ||
* @var Product | ||
* | ||
* @ORM\ManyToOne(targetEntity="Product", inversedBy="insights") | ||
* | ||
*/ | ||
private $product; | ||
|
||
/** | ||
* @var string | ||
* | ||
* @ORM\Column(name="type", type="string", length=255) | ||
*/ | ||
private $type; | ||
|
||
/** | ||
* @var string | ||
* | ||
* @ORM\Column(name="code", type="integer") | ||
*/ | ||
private $code; | ||
|
||
public function __construct($type, $code, Product $product) | ||
{ | ||
$this->product = $product; | ||
$this->code = $code; | ||
$this->type = $type; | ||
$product->addProductInsight($this); | ||
} | ||
|
||
/** | ||
* Get id | ||
* | ||
* @return integer | ||
*/ | ||
public function getId() | ||
{ | ||
return $this->id; | ||
} | ||
|
||
/** | ||
* Set product | ||
* | ||
* @param integer $product | ||
* @return ProductInsight | ||
*/ | ||
public function setProduct($productId) | ||
{ | ||
$this->productId = $productId; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Get product | ||
* | ||
* @return integer | ||
*/ | ||
public function getProduct() | ||
{ | ||
return $this->productId; | ||
} | ||
|
||
/** | ||
* Set type | ||
* | ||
* @param string $type | ||
* @return ProductInsight | ||
*/ | ||
public function setType($type) | ||
{ | ||
$this->type = $type; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Get type | ||
* | ||
* @return string | ||
*/ | ||
public function getType() | ||
{ | ||
return $this->type; | ||
} | ||
|
||
/** | ||
* Set code | ||
* | ||
* @param integer $code | ||
* @return ProductInsight | ||
*/ | ||
public function setCode($code) | ||
{ | ||
$this->code = $code; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Get code | ||
* | ||
* @return integer | ||
*/ | ||
public function getCode() | ||
{ | ||
return $this->code; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would be smarter to use Doctrine Events to add this behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll take a look at it