budget performance

This commit is contained in:
2018-04-09 22:39:35 +02:00
parent a350bc7228
commit 6247ec5037
2 changed files with 15286 additions and 45 deletions

View File

@@ -150,30 +150,45 @@ class BudgetController extends AppController
$this->autoRender = false; $this->autoRender = false;
$myfile = fopen(WWW_ROOT . DS . 'files' . DS . 'debug.txt', "w"); $myfile = fopen(WWW_ROOT . DS . 'files' . DS . 'debug.txt', "w");
$query = $this->Budget->find('all', [
'conditions' => array('wl_schooltype_id' => $schooltype_id)
]);
$count = $query->count();
fwrite($myfile,json_encode($count) . PHP_EOL);
$dbdata = $query->toArray();
$search_arr = array();
foreach($dbdata as $entry) {
$key = $entry['snr'] . '_' . $entry['wl_budget_id'];
fwrite($myfile,json_encode($key) . PHP_EOL);
$search_arr[$key]['count'] = $entry['count'];
$search_arr[$key]['comment'] = $entry['comment'];
fwrite($myfile,json_encode($search_arr[$key]) . PHP_EOL);
}
$data = $this->request->input('json_decode'); $data = $this->request->input('json_decode');
//fwrite($myfile,json_encode($data) . PHP_EOL); //fwrite($myfile,json_encode($dbdata) . PHP_EOL);
//fwrite($myfile,'hallo' . PHP_EOL); //fwrite($myfile,'hallo' . PHP_EOL);
// neue und geänderte Daten eintragen // neue und geänderte Daten eintragen
foreach($data as $line) { foreach($data as $line) {
for($i=2;$i < sizeof($line);$i++) { for($i=2;$i < sizeof($line);$i++) {
if($line[$i] > 0) { if($line[$i] > 0) {
//$regexp = "<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\/a>"; $key = $line[0] . '_' . ($i+$wl_offset);
preg_match_all("/$regexp/siU", $line[0], $matches); fwrite($myfile,json_encode($key) . PHP_EOL);
//fwrite($myfile,$matches[3][0] . PHP_EOL); if(isset($search_arr[$key])) {
$query = $this->Budget->find('all', [ if($search_arr[$key]['count'] != $line[$i] ) {
'conditions' => array('snr' => $line[0], 'wl_budget_id' => $i+$wl_offset) $query = $this->Budget->find('all', [
]); 'conditions' => array('snr' => $line[0], 'wl_budget_id' => $i+$wl_offset)
]);
if(!($query->isEmpty())) { $budget = $query->first();
$budget = $query->first();
if($budget['count'] != $line[$i] ) {
$budget['count'] = $line[$i]; $budget['count'] = $line[$i];
$this->Budget->save($budget); $this->Budget->save($budget);
} }
//fwrite($myfile,'full' . PHP_EOL); fwrite($myfile,'full' . PHP_EOL);
} }
else { else {
//fwrite($myfile,'empty' . PHP_EOL); fwrite($myfile,'empty' . PHP_EOL);
$new = $this->Budget->newEntity(); $new = $this->Budget->newEntity();
$new_budget['wl_schooltype_id'] = $schooltype_id; $new_budget['wl_schooltype_id'] = $schooltype_id;
$new_budget['snr'] = $line[0]; $new_budget['snr'] = $line[0];
@@ -183,19 +198,14 @@ class BudgetController extends AppController
$new_budget['year'] = '2018'; $new_budget['year'] = '2018';
$new = $this->Budget->patchEntity($new, $new_budget); $new = $this->Budget->patchEntity($new, $new_budget);
$this->Budget->save($new);
$this->Budget->save($new);
} }
//fwrite($myfile,serialize($budget). PHP_EOL);
//fwrite($myfile,$line[0] . ' ' .($i+$wl_offset) . ' ' . $line[$i]. PHP_EOL);
} }
} }
} }
// wurde etwas gelöscht? // wurde etwas gelöscht?
$dbdata = $this->Budget->find('all', [
'conditions' => array('wl_schooltype_id' => $schooltype_id)
]);
foreach($dbdata as $entry) { foreach($dbdata as $entry) {
fwrite($myfile,json_encode($entry) . PHP_EOL); fwrite($myfile,json_encode($entry) . PHP_EOL);
fwrite($myfile,$entry->snr . PHP_EOL); fwrite($myfile,$entry->snr . PHP_EOL);

File diff suppressed because it is too large Load Diff