Skip to content

Commit

Permalink
Merge branch 'pkp:main' into f5502
Browse files Browse the repository at this point in the history
  • Loading branch information
jyhein committed Aug 24, 2023
2 parents 77bc392 + f1fa735 commit 1ac4515
Show file tree
Hide file tree
Showing 36 changed files with 1,355 additions and 1,151 deletions.
47 changes: 33 additions & 14 deletions classes/migration/install/MetricsMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
namespace APP\migration\install;

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema as Schema;

class MetricsMigration extends \PKP\migration\Migration
Expand All @@ -28,7 +29,7 @@ public function up(): void
$table->comment('Daily statistics for views of the homepage.');
$table->bigIncrements('metrics_context_id');

$table->string('load_id', 255);
$table->string('load_id', 50);
$table->index(['load_id'], 'metrics_context_load_id');

$table->bigInteger('context_id');
Expand All @@ -42,7 +43,7 @@ public function up(): void
$table->comment('Daily statistics for views of published submissions in each series.');
$table->bigIncrements('metrics_series_id');

$table->string('load_id', 255);
$table->string('load_id', 50);
$table->index(['load_id'], 'metrics_series_load_id');

$table->bigInteger('context_id');
Expand All @@ -62,7 +63,7 @@ public function up(): void
$table->comment('Daily statistics for views and downloads of published submissions and files.');
$table->bigIncrements('metrics_submission_id');

$table->string('load_id', 255);
$table->string('load_id', 50);
$table->index(['load_id'], 'ms_load_id');

$table->bigInteger('context_id');
Expand Down Expand Up @@ -96,7 +97,7 @@ public function up(): void
$table->comment('Daily statistics matching the COUNTER R5 protocol for views and downloads of published submissions and files.');
$table->bigIncrements('metrics_counter_submission_daily_id');

$table->string('load_id', 255);
$table->string('load_id', 50);
$table->index(['load_id'], 'msd_load_id');

$table->bigInteger('context_id');
Expand Down Expand Up @@ -153,7 +154,7 @@ public function up(): void
$table->comment('Daily statistics matching the COUNTER R5 protocol for views and downloads from institutions.');
$table->bigIncrements('metrics_counter_submission_institution_daily_id');

$table->string('load_id', 255);
$table->string('load_id', 50);
$table->index(['load_id'], 'msid_load_id');

$table->bigInteger('context_id');
Expand Down Expand Up @@ -218,7 +219,7 @@ public function up(): void
$table->comment('Daily statistics by country, region and city for views and downloads of published submissions and files.');
$table->bigIncrements('metrics_submission_geo_daily_id');

$table->string('load_id', 255);
$table->string('load_id', 50);
$table->index(['load_id'], 'msgd_load_id');

$table->bigInteger('context_id');
Expand All @@ -237,7 +238,16 @@ public function up(): void
$table->integer('metric_unique');

$table->index(['context_id', 'submission_id'], 'msgd_context_id_submission_id');
$table->unique(['load_id', 'context_id', 'submission_id', 'country', 'region', 'city', 'date'], 'msgd_uc_load_context_submission_c_r_c_date');
switch (DB::getDriverName()) {
case 'mysql':
// See "Create a database table" here: https://db-ip.com/db/format/ip-to-city-lite/csv.html
// where city is defined as varchar(80)
$table->unique([DB::raw('load_id, context_id, submission_id, country, region, city(80), date')], 'msgd_uc_load_context_submission_c_r_c_date');
break;
case 'pgsql':
$table->unique(['load_id', 'context_id', 'submission_id', 'country', 'region', 'city', 'date'], 'msgd_uc_load_context_submission_c_r_c_date');
break;
}
});
Schema::create('metrics_submission_geo_monthly', function (Blueprint $table) {
$table->comment('Monthly statistics by country, region and city for views and downloads of published submissions and files.');
Expand All @@ -259,7 +269,16 @@ public function up(): void
$table->integer('metric_unique');

$table->index(['context_id', 'submission_id'], 'msgm_context_id_submission_id');
$table->unique(['context_id', 'submission_id', 'country', 'region', 'city', 'month'], 'msgm_uc_context_submission_c_r_c_month');
switch (DB::getDriverName()) {
case 'mysql':
// See "Create a database table" here: https://db-ip.com/db/format/ip-to-city-lite/csv.html
// where city is defined as varchar(80)
$table->unique([DB::raw('context_id, submission_id, country, region, city(80), month')], 'msgm_uc_context_submission_c_r_c_month');
break;
case 'pgsql':
$table->unique(['context_id', 'submission_id', 'country', 'region', 'city', 'month'], 'msgm_uc_context_submission_c_r_c_month');
break;
}
});
// Usage stats total book and chapter item temporary records
Schema::create('usage_stats_total_temporary_records', function (Blueprint $table) {
Expand Down Expand Up @@ -301,7 +320,7 @@ public function up(): void
$table->string('country', 2)->default('');
$table->string('region', 3)->default('');
$table->string('city', 255)->default('');
$table->string('load_id', 255);
$table->string('load_id', 50);
});
// Usage stats unique book and chapter item investigations temporary records
// No need to consider series_id here because investigations are only relevant/calculated on submission level.
Expand Down Expand Up @@ -339,7 +358,7 @@ public function up(): void
$table->string('country', 2)->default('');
$table->string('region', 3)->default('');
$table->string('city', 255)->default('');
$table->string('load_id', 255);
$table->string('load_id', 50);
});
// Usage stats unique book and chapter item requests temporary records
// No need to consider series_id here because requests are only relevant/calculated on submission level.
Expand Down Expand Up @@ -377,7 +396,7 @@ public function up(): void
$table->string('country', 2)->default('');
$table->string('region', 3)->default('');
$table->string('city', 255)->default('');
$table->string('load_id', 255);
$table->string('load_id', 50);
});
// Usage stats unique title investigations temporary records
// No need to consider series_id here because investigations are only relevant/calculated on submission level.
Expand Down Expand Up @@ -414,7 +433,7 @@ public function up(): void
$table->string('country', 2)->default('');
$table->string('region', 3)->default('');
$table->string('city', 255)->default('');
$table->string('load_id', 255);
$table->string('load_id', 50);
});
// Usage stats unique title requests temporary records
// No need to consider series_id here because requests are only relevant/calculated on submission level.
Expand Down Expand Up @@ -452,14 +471,14 @@ public function up(): void
$table->string('country', 2)->default('');
$table->string('region', 3)->default('');
$table->string('city', 255)->default('');
$table->string('load_id', 255);
$table->string('load_id', 50);
});
// Usage stats institution temporary records
Schema::create('usage_stats_institution_temporary_records', function (Blueprint $table) {
$table->comment('Temporary stats by institution. Data in this table is provisional. See the metrics_* tables for compiled stats.');
$table->bigIncrements('usage_stats_temp_institution_id');

$table->string('load_id', 255);
$table->string('load_id', 50);
$table->bigInteger('line_number');

$table->bigInteger('institution_id');
Expand Down
88 changes: 88 additions & 0 deletions classes/migration/upgrade/v3_4_0/I9231_FixMetricsIndexes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?php

/**
* @file classes/migration/upgrade/v3_4_0/I9231_FixMetricsIndexes.php
*
* Copyright (c) 2023 Simon Fraser University
* Copyright (c) 2023 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class I9231_FixMetricsIndexes
*
* @brief Use smaller data type for load_id, and use city column prefix index for MySQL.
*/

namespace APP\migration\upgrade\v3_4_0;

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema as Schema;
use PKP\install\DowngradeNotSupportedException;
use PKP\migration\Migration;

class I9231_FixMetricsIndexes extends Migration
{
/**
* Run the migration.
*/
public function up(): void
{
// Decrease the size of the column load_id to 50 characters
$loadIdTables = [
'metrics_context',
'metrics_submission',
'metrics_series',
'metrics_counter_submission_daily',
'metrics_counter_submission_institution_daily',
'metrics_submission_geo_daily',
'usage_stats_total_temporary_records',
'usage_stats_unique_item_investigations_temporary_records',
'usage_stats_unique_item_requests_temporary_records',
'usage_stats_unique_title_investigations_temporary_records',
'usage_stats_unique_title_requests_temporary_records',
'usage_stats_institution_temporary_records'
];
foreach ($loadIdTables as $loadIdTable) {
Schema::table($loadIdTable, function (Blueprint $table) {
$table->string('load_id', 50)->change();
});
}

// Drop the too big unique indexes
// msgd_uc_load_context_submission_c_r_c_date and
// msgm_uc_context_submission_c_r_c_month,
// and create new ones using city column prefix for MySQL
Schema::table('metrics_submission_geo_daily', function (Blueprint $table) {
$table->dropUnique('msgd_uc_load_context_submission_c_r_c_date');
switch (DB::getDriverName()) {
case 'mysql':
$table->unique([DB::raw('load_id, context_id, submission_id, country, region, city(80), date')], 'msgd_uc_load_context_submission_c_r_c_date');
break;
case 'pgsql':
$table->unique(['load_id', 'context_id', 'submission_id', 'country', 'region', 'city', 'date'], 'msgd_uc_load_context_submission_c_r_c_date');
break;
}
});
Schema::table('metrics_submission_geo_monthly', function (Blueprint $table) {
$table->dropUnique('msgm_uc_context_submission_c_r_c_month');
switch (DB::getDriverName()) {
case 'mysql':
$table->unique([DB::raw('context_id, submission_id, country, region, city(80), month')], 'msgm_uc_context_submission_c_r_c_month');
break;
case 'pgsql':
$table->unique(['context_id', 'submission_id', 'country', 'region', 'city', 'month'], 'msgm_uc_context_submission_c_r_c_month');
break;
}
});
}

/**
* Reverse the downgrades
*
* @throws DowngradeNotSupportedException
*/
public function down(): void
{
throw new DowngradeNotSupportedException();
}
}
2 changes: 2 additions & 0 deletions classes/migration/upgrade/v3_4_0/InstallEmailTemplates.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ protected function getEmailTemplateKeys(): array
'DISCUSSION_NOTIFICATION_REVIEW',
'DISCUSSION_NOTIFICATION_COPYEDITING',
'DISCUSSION_NOTIFICATION_PRODUCTION',
'SUBMISSION_SAVED_FOR_LATER',
'SUBMISSION_NEEDS_EDITOR',
'REVIEW_REQUEST_SUBSEQUENT',
'REVISED_VERSION_NOTIFY',
'VERSION_CREATED',
Expand Down
9 changes: 9 additions & 0 deletions config.TEMPLATE.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -566,3 +566,12 @@
; Remove failed jobs from the database after the following number of days.
; Remove this setting to leave failed jobs in the database.
delete_failed_jobs_after = 180


;;;;;;;;;;;;;;;;;;;;;;;;;
; New Features Settings ;
;;;;;;;;;;;;;;;;;;;;;;;;;

[features]

enable_new_submission_listing = Off
5 changes: 5 additions & 0 deletions dbscripts/xml/upgrade.xml
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@
<migration class="PKP\migration\upgrade\v3_4_0\I7249_UpdateUsersUniqueIndex"/>
</upgrade>

<upgrade minversion="3.1.0.0" maxversion="3.4.0.9">
<migration class="PKP\migration\upgrade\v3_4_0\I9136_MigrateUniqueSiteId"/>
<migration class="APP\migration\upgrade\v3_4_0\I9231_FixMetricsIndexes"/>
</upgrade>

<!-- Update plugin configuration - should be done as the final upgrade task -->
<code function="addPluginVersions" />
</install>
3 changes: 2 additions & 1 deletion js/load.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ import WorkflowPage from '@/components/Container/WorkflowPageOMP.vue';
import JobsPage from '@/components/Container/JobsPage.vue';
import FailedJobsPage from '@/components/Container/FailedJobsPage.vue';
import FailedJobDetailsPage from '@/components/Container/FailedJobDetailsPage.vue';

import CatalogListPanel from '@/components/ListPanel/submissions/CatalogListPanel.vue';
import SubmissionsPage from '@/components/Container/SubmissionsPage.vue';

// Required by the URN plugin
import FieldText from '@/components/Form/fields/FieldText.vue';
Expand Down Expand Up @@ -61,6 +61,7 @@ window.pkp = Object.assign(PkpLoad, {
StatsUsersPage,
SubmissionWizardPage,
WorkflowPage,
SubmissionsPage,
},
});

Expand Down
2 changes: 1 addition & 1 deletion lib/pkp
Submodule pkp updated 108 files
2 changes: 1 addition & 1 deletion lib/ui-library
Submodule ui-library updated 115 files
Loading

0 comments on commit 1ac4515

Please sign in to comment.