Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/permissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/ListingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
60 changes: 59 additions & 1 deletion src/Controller/ReleasesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand All @@ -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'];
Expand Down
7 changes: 4 additions & 3 deletions src/Controller/SubmissionsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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([
Expand Down
2 changes: 1 addition & 1 deletion src/Model/Table/SubmissionsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
]);
Expand Down