Skip to content

Commit 09d6874

Browse files
committed
Issues-523: Set 'update' type for a query and recalculate count of watched categories if it's null
1 parent 7188a77 commit 09d6874

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

config/vanilla/bootstrap.early.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,13 @@
162162
// Set count of WatchedCategories for users
163163
Gdn::sql()->query('update GDN_User u set u.CountWatchedCategories = (
164164
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)');
165+
where um.Name LIKE "Preferences.%" AND UserID = u.UserID and Value = 1) ws where ws.CategoryID = c.CategoryID)', 'update');
166166

167167
}
168+
169+
// 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');
168174
}

0 commit comments

Comments
 (0)