mirror of
https://github.com/joomla-extensions/patchtester.git
synced 2024-12-23 03:19:00 +00:00
Improve performance by only making 1 query
This commit is contained in:
parent
9033f2a4df
commit
fe839a077d
@ -328,23 +328,32 @@ class PullsModel extends \JModelDatabase
|
|||||||
// Dump the old data now
|
// Dump the old data now
|
||||||
$this->getDb()->truncateTable('#__patchtester_pulls');
|
$this->getDb()->truncateTable('#__patchtester_pulls');
|
||||||
|
|
||||||
foreach ($pulls as &$pull)
|
// If there are no pulls to insert then bail
|
||||||
|
if (empty($pulls))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = array();
|
||||||
|
|
||||||
|
foreach ($pulls as $pull)
|
||||||
{
|
{
|
||||||
// Build the data object to store in the database
|
// Build the data object to store in the database
|
||||||
$data = new \stdClass;
|
$pullData = array($pull->number, $pull->title, $pull->body, $pull->html_url);
|
||||||
$data->pull_id = $pull->number;
|
$data[] = implode($pullData, ',');
|
||||||
$data->title = $pull->title;
|
}
|
||||||
$data->description = $pull->body;
|
|
||||||
$data->pull_url = $pull->html_url;
|
|
||||||
|
|
||||||
try
|
$query = $this->getDb()->getQuery();
|
||||||
{
|
$query->insert('#__patchtester_pulls')->columns('pull_id, title, description, pull_url')->values($data);
|
||||||
$this->getDb()->insertObject('#__patchtester_pulls', $data, 'id');
|
$this->getDb()->setQuery($query);
|
||||||
}
|
|
||||||
catch (\RuntimeException $e)
|
try
|
||||||
{
|
{
|
||||||
throw new \RuntimeException(\JText::sprintf('COM_PATCHTESTER_ERROR_INSERT_DATABASE', $e->getMessage()));
|
$this->getDb()->execute();
|
||||||
}
|
}
|
||||||
|
catch (\RuntimeException $e)
|
||||||
|
{
|
||||||
|
throw new \RuntimeException(\JText::sprintf('COM_PATCHTESTER_ERROR_INSERT_DATABASE', $e->getMessage()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user