Skip to content

Commit

Permalink
Refactoring snippets misinformed in the code.
Browse files Browse the repository at this point in the history
Signed-off-by: vitor <vitor@lepidus.com.br>
Signed-off-by: hilton <hilton@lepidus.com.br>
  • Loading branch information
vitor committed Nov 26, 2020
1 parent 57aeba3 commit a924f02
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions KeywordCloudBlockPlugin.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

define('KEYWORD_BLOCK_MAX_ITEMS', 50);
define('KEYWORD_BLOCK_CACHE_DAYS', 2);
define('ONE_DAY_SECONDS', 60 * 60 * 24);
define('TWO_DAYS_SECONDS',ONE_DAY_SECONDS * KEYWORD_BLOCK_CACHE_DAYS);

import('lib.pkp.classes.plugins.BlockPlugin');
import ('classes.submission.SubmissionDAO');
Expand Down Expand Up @@ -59,8 +61,9 @@ function getContents($templateMgr, $request = null) {
);

$keywords =& $cache->getContents();
$currentCacheTime = time() - $cache->getCacheTime();

if (time() - $cache->getCacheTime() > 60 * 60 * 24 * KEYWORD_BLOCK_CACHE_DAYS){
if ($currentCacheTime > TWO_DAYS_SECONDS){
$cache->flush();
$cache->setEntireCache($this->getKeywordsJournal($journal->getId()));
}
Expand Down Expand Up @@ -107,11 +110,11 @@ function getKeywordsJournal($journalId){
$top_keywords = array_slice($count_keywords, 0, KEYWORD_BLOCK_MAX_ITEMS);
$keywords = array();

foreach ($top_keywords as $k => $c) {
$kw = new stdClass();
$kw->text = $k;
$kw->size = $c;
$keywords[] = $kw;
foreach ($top_keywords as $key => $countKey) {
$keyWords = new stdClass();
$keyWords->text = $key;
$keyWords->size = $countKey;
$keywords[] = $keyWords;
}

return json_encode($keywords);
Expand Down

0 comments on commit a924f02

Please sign in to comment.