From 210ce05ff9afe2716adbe647caf6aa183038f8e4 Mon Sep 17 00:00:00 2001 From: Bogdanova Olga Date: Sun, 4 Apr 2021 17:36:40 +0300 Subject: [PATCH 1/4] Issues-523: recalculated CountWatchedCategories --- config/vanilla/bootstrap.early.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/config/vanilla/bootstrap.early.php b/config/vanilla/bootstrap.early.php index 62dcc72..bce936c 100644 --- a/config/vanilla/bootstrap.early.php +++ b/config/vanilla/bootstrap.early.php @@ -159,16 +159,17 @@ ->column('CountWatchedCategories', 'int', null) ->set(false, false); - // Set count of WatchedCategories for users + // Set count of Watched Categories for users Gdn::sql()->query('update GDN_User u set u.CountWatchedCategories = ( - select count(c.CategoryID) from GDN_Category c, (select distinct CAST(SUBSTRING_INDEX(um.Name, ".", -1) as UNSIGNED) as CategoryID from GDN_UserMeta um - where um.Name LIKE "Preferences.%" AND UserID = u.UserID and Value = 1) ws where ws.CategoryID = c.CategoryID)', 'update'); - + select count(c.CategoryID) from GDN_Category c, (select distinct SUBSTRING_INDEX(um.Name, ".", -1) as CategoryID from GDN_UserMeta um + where um.Name LIKE "Preferences.%" AND um.UserID = u.UserID and Value = 1) ws where ws.CategoryID = c.CategoryID)', 'update'); } // FIX: https://github.com/topcoder-platform/forums/issues/479 - // Re-calculate count of WatchedCategories if WatchedCategories is null - // Gdn::sql()->query('update GDN_User u set u.CountWatchedCategories = ( - // select count(c.CategoryID) from GDN_Category c, (select distinct CAST(SUBSTRING_INDEX(um.Name, ".", -1) as UNSIGNED) as CategoryID from GDN_UserMeta um - // where um.Name LIKE "Preferences.%" AND UserID = u.UserID and Value = 1) ws where ws.CategoryID = c.CategoryID) where CountWatchedCategories is null', 'update'); + // Re-calculate count of Watched Categories if CountWatchedCategories is null + // Remove it later. It should be executed only once when the column is added + Gdn::sql()->query('update GDN_User u set u.CountWatchedCategories = ( + select count(c.CategoryID) from GDN_Category c, (select distinct SUBSTRING_INDEX(um.Name, ".", -1) as CategoryID from GDN_UserMeta um + where um.Name LIKE "Preferences.%" AND um.UserID = u.UserID and Value = 1) ws where ws.CategoryID = c.CategoryID) where CountWatchedCategories is null', 'update'); + } \ No newline at end of file From 27ebb5ae9883ed0a2dd91fadffd05cfa21d8c1b2 Mon Sep 17 00:00:00 2001 From: Bogdanova Olga Date: Sun, 4 Apr 2021 17:55:22 +0300 Subject: [PATCH 2/4] Issues-529: updated auto-save interval(15 secs) --- vanilla/applications/vanilla/js/autosave.js | 33 +++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 vanilla/applications/vanilla/js/autosave.js diff --git a/vanilla/applications/vanilla/js/autosave.js b/vanilla/applications/vanilla/js/autosave.js new file mode 100644 index 0000000..e0e666c --- /dev/null +++ b/vanilla/applications/vanilla/js/autosave.js @@ -0,0 +1,33 @@ +jQuery(document).ready(function($) { + /* Autosave functionality for comment & discussion drafts */ + $.fn.autosave = function(opts) { + // Interval - 15 sec + var options = $.extend({interval: 15000, button: false}, opts); + var textarea = this; + if (!options.button) + return false; + + var lastVal = $(textarea).val(); + + var save = function() { + var currentVal = $(textarea).val(); + var defaultValues = [ + undefined, + null, + '', + '[{\"insert\":\"\\n\"}]', + lastVal + ]; + if (!defaultValues.includes(currentVal)) { + lastVal = currentVal; + $(options.button).click(); + } + }; + + if (options.interval > 0) { + setInterval(save, options.interval); + } + + return this; + } +}); From ab8a13f5046e347f144a6cd8f5f715e2dccc744f Mon Sep 17 00:00:00 2001 From: Bogdanova Olga Date: Sun, 4 Apr 2021 17:56:57 +0300 Subject: [PATCH 3/4] Issues-529: updated auto-save interval(15 secs) --- vanilla/applications/vanilla/js/autosave.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vanilla/applications/vanilla/js/autosave.js b/vanilla/applications/vanilla/js/autosave.js index e0e666c..147a2d0 100644 --- a/vanilla/applications/vanilla/js/autosave.js +++ b/vanilla/applications/vanilla/js/autosave.js @@ -1,7 +1,7 @@ jQuery(document).ready(function($) { /* Autosave functionality for comment & discussion drafts */ $.fn.autosave = function(opts) { - // Interval - 15 sec + // Interval - 15 secs var options = $.extend({interval: 15000, button: false}, opts); var textarea = this; if (!options.button) From 3863e14e97058d0c2a2c5b7bc072c8b2ee0b8b55 Mon Sep 17 00:00:00 2001 From: Bogdanova Olga Date: Sun, 4 Apr 2021 18:42:53 +0300 Subject: [PATCH 4/4] Issues-528: Updated the format of Discussion Date --- vanilla/applications/vanilla/views/discussion/discussion.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/vanilla/applications/vanilla/views/discussion/discussion.php b/vanilla/applications/vanilla/views/discussion/discussion.php index 7e020ae..9ece006 100644 --- a/vanilla/applications/vanilla/views/discussion/discussion.php +++ b/vanilla/applications/vanilla/views/discussion/discussion.php @@ -4,6 +4,8 @@ * @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2 */ +use Vanilla\Formatting\DateTimeFormatter; + if (!defined('APPLICATION')) { exit(); } @@ -51,7 +53,8 @@
- DateInserted, 'html'); ?> + get(DateTimeFormatter::class)->formatDate($Discussion->DateInserted, true, + DateTimeFormatter::FORCE_FULL_FORMAT); ?> ', '']);