Skip to content

Commit

Permalink
[#71] setting up duplicates patch to run every 6 months
Browse files Browse the repository at this point in the history
  • Loading branch information
j-h-s committed Feb 12, 2018
1 parent b9907d1 commit 2f6eec5
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/AppBundle/Command/PatchCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,21 @@ public function patchDuplicateEntries($partyCode = null, $resumePoint = null) {
}

$this->log->info("Getting posts from " . $party->getCode());
$posts = $this->em->getRepository('AppBundle:SocialMedia')->findBy(['code' => $party->getCode()], ['id' => 'DESC']);

$dateLimit = strtotime("-6 months");
$dateString = date('Y-m-d H:i:s', $dateLimit);

$posts = $this->em->createQueryBuilder()->select('p')
->from('AppBundle:SocialMedia', 'p')
->where(sprintf("p.code = '%s'", $party->getCode()))
->andWhere(sprintf("p.postTime > '%s'", $dateString))
->orderBy("p.id", 'DESC')
->getQuery()->getResult();

// $posts = $this->em->getRepository('AppBundle:SocialMedia')->findBy(['code' => $party->getCode()], ['id' => 'DESC']);

$size = sizeof($posts);
$this->log->info($size . " posts found...");
$this->log->info($size . " posts found from the past 6 months");

$estLow = ($size / 4) / 60; // estimation of minutes based on 4 posts per second
$estHigh = ($size / 3) / 60; // estimation of minutes based on 3 posts per second
Expand All @@ -155,6 +166,7 @@ public function patchDuplicateEntries($partyCode = null, $resumePoint = null) {
continue;
}

$this->output->writeln("");
$this->log->notice($postCount . " - " . (sizeof($dupes) -1) . " duplicates found for " . $prime->getPostId());

foreach ($dupes as $dupe) {
Expand Down

0 comments on commit 2f6eec5

Please sign in to comment.