diff --git a/config/permissions.php b/config/permissions.php index f149c46..01d333f 100644 --- a/config/permissions.php +++ b/config/permissions.php @@ -187,7 +187,7 @@ [ 'role' => 'user', 'controller' => 'Submissions', - 'action' => ['add', 'edit', 'mine', 'prepare', 'model', 'results', 'confirmation'] + 'action' => ['add', 'edit', 'mine', 'prepare', 'model', 'results', 'confirmation', 'configuration', 'system'] ], [ 'role' => ['user'], diff --git a/src/Controller/ListingsController.php b/src/Controller/ListingsController.php index 69267ef..c999214 100644 --- a/src/Controller/ListingsController.php +++ b/src/Controller/ListingsController.php @@ -370,10 +370,10 @@ public function delete($id = null) $table = strtolower('list_' . $listing->release->acronym . '_' . str_replace('ten', '10node', $listing->type->url)); $table = str_replace('-', '_', $table); - if (date('Y-m-d') > $listing->release->release_date->i18nFormat('yyyy-MM-dd')) { + if (date('Y-m-d') > $listing->release->release_date->addMonth()->i18nFormat('yyyy-MM-dd')) { $this->Flash->error(__('You are not allowed to delete an already released list!')); - return $this->redirect(['action' => 'index']); + return $this->redirect(['controller' => 'releases', 'action' => 'index']); } $listing = $this->Listings->get($id); diff --git a/src/Controller/ReleasesController.php b/src/Controller/ReleasesController.php index 503614c..142c202 100644 --- a/src/Controller/ReleasesController.php +++ b/src/Controller/ReleasesController.php @@ -128,6 +128,64 @@ public function synchronize() # We will re-create the view with all submissions $connection = ConnectionManager::get('default'); + $found = $connection->execute( + "SELECT + COUNT(TABLE_NAME) AS total + FROM + information_schema.TABLES + WHERE + TABLE_SCHEMA = 'io500_db' AND + TABLE_NAME = 'listings_submissions' + " + )->fetch('assoc')['total']; + + # Use a transaction to avoid data corruption + $connection->begin(); + + if ($found) { + $connection->execute('DROP VIEW listings_submissions'); + } + + $releases = $connection->execute( + "SELECT + TABLE_NAME + FROM + information_schema.TABLES + WHERE + TABLE_SCHEMA = 'io500_db' AND + TABLE_NAME LIKE 'list\_%' + " + )->fetchAll('assoc'); + + $query = 'CREATE VIEW listings_submissions AS '; + + $lists = []; + + foreach ($releases as $release) { + $lists[] = 'SELECT * FROM ' . $release['TABLE_NAME']; + } + + $query .= implode(' UNION ALL ', $lists); + + $connection->execute($query); + + $connection->commit(); + + $this->Flash->success(__('The releases have been synchronized!')); + + return $this->redirect(['action' => 'index']); + } + + /** + * Synchronize method + * + * @return \Cake\Http\Response|null|void Redirects to index. + */ + public function synchronize_broken() + { + # We will re-create the view with all submissions + $connection = ConnectionManager::get('default'); + # We need the name of each table that should be in the view (for valid and released lists) $releases = $this->Releases->find('all') ->where([ @@ -145,7 +203,7 @@ public function synchronize() FROM information_schema.TABLES WHERE - TABLE_SCHEMA = 'io500_db_shadow' AND + TABLE_SCHEMA = 'io500_db' AND TABLE_NAME = 'listings_submissions' " )->fetch('assoc')['total']; diff --git a/src/Controller/SubmissionsController.php b/src/Controller/SubmissionsController.php index d94f41d..7a9f8f8 100644 --- a/src/Controller/SubmissionsController.php +++ b/src/Controller/SubmissionsController.php @@ -957,6 +957,7 @@ private function metrics($submission) $submission->ior_easy_write = $results['ior-easy-write'] ?? null; $submission->ior_easy_read = $results['ior-easy-read'] ?? null; + $submission->ior_easy_read_random = $results['ior-rnd4K-easy-read'] ?? null; $submission->ior_hard_write = $results['ior-hard-write'] ?? null; $submission->ior_hard_read = $results['ior-hard-read'] ?? null; @@ -1386,10 +1387,10 @@ public function build($release_acronym, $type_url) ]); // Find all releases - $releases = $this->Submissions->Releases->find('list') + $releases = $this->Submissions->Releases->find('list'); /* ->where([ - 'Releases.release_date >=' => date('Y-m-d'), - ]); + 'Releases.release_date' => date('Y-m-d'), + ]);*/ $last_release = $this->Submissions->Releases->find('all') ->where([ diff --git a/src/Model/Table/SubmissionsTable.php b/src/Model/Table/SubmissionsTable.php index 1ab07d1..5753f8c 100644 --- a/src/Model/Table/SubmissionsTable.php +++ b/src/Model/Table/SubmissionsTable.php @@ -50,7 +50,7 @@ public function initialize(array $config): void ]); $this->belongsTo('Users', [ - 'className' => 'CakeDC/Users.Users', + 'className' => \App\Model\Table\UsersTable::class, 'foreignKey' => 'user_id', 'joinType' => 'LEFT', ]);