Skip to content

Commit 210ce05

Browse files
committed
Issues-523: recalculated CountWatchedCategories
1 parent 2607a53 commit 210ce05

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

config/vanilla/bootstrap.early.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -159,16 +159,17 @@
159159
->column('CountWatchedCategories', 'int', null)
160160
->set(false, false);
161161

162-
// Set count of WatchedCategories for users
162+
// Set count of Watched Categories for users
163163
Gdn::sql()->query('update GDN_User u set u.CountWatchedCategories = (
164-
select count(c.CategoryID) from GDN_Category c, (select distinct CAST(SUBSTRING_INDEX(um.Name, ".", -1) as UNSIGNED) as CategoryID from GDN_UserMeta um
165-
where um.Name LIKE "Preferences.%" AND UserID = u.UserID and Value = 1) ws where ws.CategoryID = c.CategoryID)', 'update');
166-
164+
select count(c.CategoryID) from GDN_Category c, (select distinct SUBSTRING_INDEX(um.Name, ".", -1) as CategoryID from GDN_UserMeta um
165+
where um.Name LIKE "Preferences.%" AND um.UserID = u.UserID and Value = 1) ws where ws.CategoryID = c.CategoryID)', 'update');
167166
}
168167

169168
// FIX: https://github.com/topcoder-platform/forums/issues/479
170-
// Re-calculate count of WatchedCategories if WatchedCategories is null
171-
// Gdn::sql()->query('update GDN_User u set u.CountWatchedCategories = (
172-
// select count(c.CategoryID) from GDN_Category c, (select distinct CAST(SUBSTRING_INDEX(um.Name, ".", -1) as UNSIGNED) as CategoryID from GDN_UserMeta um
173-
// where um.Name LIKE "Preferences.%" AND UserID = u.UserID and Value = 1) ws where ws.CategoryID = c.CategoryID) where CountWatchedCategories is null', 'update');
169+
// Re-calculate count of Watched Categories if CountWatchedCategories is null
170+
// Remove it later. It should be executed only once when the column is added
171+
Gdn::sql()->query('update GDN_User u set u.CountWatchedCategories = (
172+
select count(c.CategoryID) from GDN_Category c, (select distinct SUBSTRING_INDEX(um.Name, ".", -1) as CategoryID from GDN_UserMeta um
173+
where um.Name LIKE "Preferences.%" AND um.UserID = u.UserID and Value = 1) ws where ws.CategoryID = c.CategoryID) where CountWatchedCategories is null', 'update');
174+
174175
}

0 commit comments

Comments
 (0)