From 0648689d248251e062f596ef03b363fe1beb76a7 Mon Sep 17 00:00:00 2001 From: Lufei Date: Tue, 6 Jun 2023 16:28:39 +0800 Subject: [PATCH] * Optimize convert2Pinyin, and cache executions for bug browse. --- module/bug/control.php | 13 +++++++++++-- module/common/model.php | 7 +++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/module/bug/control.php b/module/bug/control.php index 57fbf0b6d3..0041c667f4 100755 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -164,8 +164,17 @@ class bug extends control if($this->app->getViewType() == 'mhtml' || $this->app->getViewType() == 'xhtml') $recPerPage = 10; $pager = new pager($recTotal, $recPerPage, $pageID); - /* Get executios. */ - $executions = $this->loadModel('execution')->getPairs($this->projectID, 'all', 'empty|withdelete|hideMultiple'); + /* Get executions. */ + $cacheKey = "bugBrowse{$this->projectID}"; + if($this->config->cache->enable && $this->cache->has($cacheKey)) + { + $executions = $this->cache->get($cacheKey); + } + else + { + $executions = $this->loadModel('execution')->getPairs($this->projectID, 'all', 'empty|withdelete|hideMultiple'); + if($this->config->cache->enable) $this->cache->set($cacheKey, $executions); + } /* Get product id list. */ $productIDList = $productID ? $productID : array_keys($this->products); diff --git a/module/common/model.php b/module/common/model.php index 90ddd5cb76..69145e100e 100644 --- a/module/common/model.php +++ b/module/common/model.php @@ -2869,11 +2869,14 @@ EOF; $itemsPinYin = explode(trim($sign), $convertedPinYin); foreach($notConvertedItems as $item) { - $itemPinYin = array_shift($itemsPinYin); + $key = key($itemsPinYin); + $itemPinYin = $itemsPinYin[$key]; + unset($itemsPinYin[$key]); + $wordsPinYin = explode("\t", trim($itemPinYin)); $abbr = ''; - foreach($wordsPinYin as $i => $wordPinyin) + foreach($wordsPinYin as $wordPinyin) { if($wordPinyin) {