Update to generateCount

- generateCount used to just run through all attributes and save them, to
  generate the count. It led to VERY long execution times on larger
  databases (25k+ attributes). With the extra processing that each save()
  does for attributes, this was horribly slow.

- new generateCount just saves the events based on the number of
  associated attributes, only having to save the events (of which there
  are considerably less).
pull/64/merge
iglocska 2013-03-12 12:00:49 +01:00
parent d9a01197ac
commit 80967b2ddd
1 changed files with 5 additions and 6 deletions

View File

@ -631,12 +631,11 @@ class AppController extends Controller {
public function generateCount() {
if (!self::_isSiteAdmin()) throw new NotFoundException();
$this->loadModel('Attribute');
$attributes = $this->Attribute->find('all', array('recursive' => 0));
// for all attributes..
foreach ($attributes as $attribute) {
$this->Attribute->save($attribute);
$this->loadModel('Event');
$events = $this->Event->find('all', array('recursive' => 1));
foreach ($events as $event) {
$event['Event']['attribute_count'] = sizeof($event['Attribute']);
$this->Event->save($event);
}
}