Skip to content

Commit 826a322

Browse files
committed
Increase 'seen' db field length (#27), add js source maps
1 parent 4a23378 commit 826a322

11 files changed

+39
-11
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Changelog
22

3+
## v1.4.1 - 06/01/2021
4+
5+
### Added
6+
* JS source maps.
7+
8+
### Changed
9+
* Increased 'precision'/length of `seen` field in database (from 4 to 10).
10+
* Minor Moodle code-check fixes.
11+
* Bumped version number.
12+
313
## v1.4.0 - 18/12/2020
414

515
### Added

amd/build/custom.min.js

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

amd/build/custom.min.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

amd/build/notif.min.js

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

amd/build/notif.min.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

amd/src/custom.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint no-console: ["error", { allow: ["error"] }] */
1+
/* eslint no-console: ["error", { allow: ["error"] }], max-nested-callbacks: ["error", 7] */
22
/**
33
* @package block_advnotifications
44
* @copyright 2019 onwards LearningWorks Ltd {@link https://learningworks.co.nz/}

amd/src/notif.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint no-console: ["error", { allow: ["error"] }] */
1+
/* eslint no-console: ["error", { allow: ["error"] }], max-nested-callbacks: ["error", 7] */
22
/**
33
* @package block_advnotifications
44
* @copyright 2019 onwards LearningWorks Ltd {@link https://learningworks.co.nz/}

db/install.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<FIELD NAME="user_id" TYPE="int" LENGTH="20" NOTNULL="true" SEQUENCE="false" COMMENT="User related to occurrence of notification"/>
3131
<FIELD NAME="not_id" TYPE="int" LENGTH="20" NOTNULL="true" SEQUENCE="false" COMMENT="Notification user interaction relates to"/>
3232
<FIELD NAME="dismissed" TYPE="int" LENGTH="1" NOTNULL="true" SEQUENCE="false" COMMENT="Flag of whether user dismissed occurrence of notification or not"/>
33-
<FIELD NAME="seen" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Record of number of times a user has seen the notification"/>
33+
<FIELD NAME="seen" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Record of number of times a user has seen the notification"/>
3434
</FIELDS>
3535
<KEYS>
3636
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>

db/upgrade.php

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,18 @@
2525

2626
defined('MOODLE_INTERNAL') || die;
2727

28-
2928
/**
3029
* When upgrading plugin, execute the following code.
3130
*
32-
* @param int $oldversion - previous version of plugin (from DB).
31+
* @param int $oldversion Previous version of plugin (from DB).
32+
* @return bool Successful upgrade or not.
3333
*/
3434
function xmldb_block_advnotifications_upgrade($oldversion) {
3535
global $DB;
3636
$dbman = $DB->get_manager();
3737

38+
// This was needed to add tables during development - probably not even need anymore. Leaving just-in-case (for now).
3839
if ($oldversion < 2017100217) {
39-
4040
// Define table block_advnotifications to be created.
4141
$table = new xmldb_table('block_advnotifications');
4242

@@ -88,6 +88,20 @@ function xmldb_block_advnotifications_upgrade($oldversion) {
8888
upgrade_block_savepoint(true, 2017100217, 'advnotifications');
8989
}
9090

91+
// If upgrading from version earlier than v1.4.1 - max for 'seen' needs to be increased.
92+
if ($oldversion < 2021010616) {
93+
94+
// Increase length/precision of field 'seen' in table 'block_advnotificationsdissed' to '10'.
95+
$table = new xmldb_table('block_advnotificationsdissed');
96+
$field = new xmldb_field('seen', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
97+
98+
// Update DB.
99+
$dbman->change_field_precision($table, $field);
100+
101+
// Upgrade savepoint reached.
102+
upgrade_block_savepoint(true, 2021010616, 'advnotifications');
103+
}
104+
91105
// Add future upgrade points here.
92106

93107
return true;

0 commit comments

Comments
 (0)