From c33d8878ffdb67b3bbf9c8cdb68239c1efd86c0c Mon Sep 17 00:00:00 2001 From: alice-blue Date: Wed, 4 Dec 2024 17:41:14 -0500 Subject: [PATCH 01/72] incoming-schema-changes.sql: Add game_filter column to users table --- sql/incoming-schema-changes.sql | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sql/incoming-schema-changes.sql b/sql/incoming-schema-changes.sql index 5191b47c..7c62d0e7 100644 --- a/sql/incoming-schema-changes.sql +++ b/sql/incoming-schema-changes.sql @@ -7,3 +7,7 @@ alter table reviewvotes add column `createdate` datetime NOT NULL DEFAULT current_timestamp(), add PRIMARY KEY (`reviewvoteid`) ; + +-- Add column for game search filter to the users table + +ALTER TABLE `users` ADD COLUMN `game_filter` VARCHAR(150) DEFAULT ''; From 15dd836814dfe53a980c6544deb7bc626594c19d Mon Sep 17 00:00:00 2001 From: alice-blue Date: Wed, 4 Dec 2024 17:47:07 -0500 Subject: [PATCH 02/72] editprofile: add game filter section to settings page --- www/editprofile | 47 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 7 deletions(-) diff --git a/www/editprofile b/www/editprofile index 95aee77a..532d0e78 100644 --- a/www/editprofile +++ b/www/editprofile @@ -56,6 +56,7 @@ $emailcloaked = (get_req_data('emailcloaked') != 0); $gender = get_req_data('gender'); $offsite = get_req_data('offsite'); $accessibility = (get_req_data('accessibility') ? 1 : 0); +$game_filter = get_req_data('game_filter'); if (strlen($gender) != 1 || strpos("MF", $gender) === false) $gender = ""; @@ -72,7 +73,7 @@ function showHiddenFields() global $email, $email2, $pubemail, $dname, $loc, $profile, $pic, $defaultOS, $mirror, $noExes, $playlistPub, $wishlistPub, $unwishlistPub, $gender, - $emailcaptcha, $emailcloaked; + $emailcaptcha, $emailcloaked, $game_filter; echo "" @@ -103,6 +104,7 @@ function showHiddenFields() . "" . "" . "" + . "" . "" . " noexedownloads = '$qNoExes', publiclists = '$qPublicLists', gender = '$qGender', emailflags = '$emailflags', offsite_display = '$qOffsite', - accessibility = '$qAccessibility' + accessibility = '$qAccessibility', + game_filter = '$qgamefilter' $setPic where id = '$usernum'", $db) == false) { $errFlagged = "An error occurred updating the database. You might @@ -924,6 +931,32 @@ captchaSupportScripts($captchaKey); +

5. Game Filtering

+ +
+

To limit what kinds of games appear on the + search page and on the + browse page, you can + create a filter using IFDB's + search prefixes. + For instance, to hide games in a certain language, games in a + certain genre, and games with a certain tag, you can type +
-language:example -genre:example -tag:example
+ (replacing "example" with the name of the language, genre, or tag). + While you are logged in, your saved filter will automatically be + be added to the end of your search terms when you search for games. + The filter will also be applied when you browse games on the browse + page. At the bottom of the page of results, there will be an option + to search again without the filter. (Note: Game information on IFDB + is incomplete and can have mistakes. A filter is not a reliable way + to make sure that games are kid-friendly.) +
+

+ + +

+ +

From 483be876e89d640265b1bd47db37807826e35af2 Mon Sep 17 00:00:00 2001 From: alice-blue Date: Wed, 4 Dec 2024 17:56:42 -0500 Subject: [PATCH 03/72] Update searchutil.php to handle custom game filters --- www/searchutil.php | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/www/searchutil.php b/www/searchutil.php index b8c31ad0..8cf69b56 100644 --- a/www/searchutil.php +++ b/www/searchutil.php @@ -43,7 +43,7 @@ function convertTimeStringToMinutes($h_m_string) { } -function doSearch($db, $term, $searchType, $sortby, $limit, $browse) +function doSearch($db, $term, $searchType, $sortby, $limit, $browse, $override_game_filter = 0) { // we need the current user for some types of queries checkPersistentLogin(); @@ -73,6 +73,9 @@ function doSearch($db, $term, $searchType, $sortby, $limit, $browse) // assume no badge info $badges = false; + // So far, we haven't applied a custom game filter + $games_were_filtered = false; + // set up the parameters for the type of search we're performing if ($searchType == "list") { @@ -297,7 +300,21 @@ function doSearch($db, $term, $searchType, $sortby, $limit, $browse) $matchCols = "title, author, `desc`, tags"; $likeCol = "title"; $summaryDesc = "Games"; - } + + + // Handle custom game filters + if ($curuser && $override_game_filter != 1) { + // We're logged in, and haven't been told to override a custom game filter, so check for one + $result = mysqli_execute_query($db, "select game_search_filter from users where id = ?", [$curuser]); + if (!$result) throw new Exception("Error: " . mysqli_error($db)); + [$gameFilter] = mysql_fetch_row($result); + if ($gameFilter) { + // We've found a custom game filter, so add it to the end of the search term + $games_were_filtered = true; + $term .= " $gameFilter"; + } + } + } // parse the search for ($ofs = 0, $len = strlen($term), $words = array(), @@ -1157,7 +1174,7 @@ function doSearch($db, $term, $searchType, $sortby, $limit, $browse) // return the results return array($rows, $rowcnt, $sortList, $errMsg, $summaryDesc, - $badges, $specials, $specialsUsed, $orderBy); + $badges, $specials, $specialsUsed, $orderBy, $games_were_filtered); } ?> From 6ec9ad0abd9b3ba880d7805bd7162e8c7aa055e2 Mon Sep 17 00:00:00 2001 From: alice-blue Date: Wed, 4 Dec 2024 18:09:29 -0500 Subject: [PATCH 04/72] Update search page to handle custom filters --- www/search | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/www/search b/www/search index 424e214c..e516e16d 100644 --- a/www/search +++ b/www/search @@ -58,6 +58,7 @@ if ($api_mode && !isset($_SESSION['logged_in_as']) && isset($_SERVER['PHP_AUTH_U $term = get_req_data('searchfor'); $bTerm = get_req_data('searchbar'); $extraLink = get_req_data('xlink'); +$override_game_filter = get_req_data('nogamefilter'); if ($term == "" && $bTerm != "") $term = $bTerm; @@ -294,8 +295,8 @@ if ($term || $browse) { // run the search list($rows, $rowcnt, $sortList, $errMsg, $summaryDesc, $badges, - $specials, $specialsUsed, $orderBy) = - doSearch($db, $term, $searchType, $sortby, $limit, $browse); + $specials, $specialsUsed, $orderBy, $games_were_filtered) = + doSearch($db, $term, $searchType, $sortby, $limit, $browse, $override_game_filter); // adjust our page limits to include the whole result set if desired if ($pgAll) { @@ -304,7 +305,7 @@ if ($term || $browse) { } // if there's exactly one row, jump directly to the result page - if ($rowcnt == 1 && !$browse && !$api_mode) { + if ($rowcnt == 1 && !$browse && !$api_mode && !$games_were_filtered) { $redir = false; switch ($searchType) { case "game": @@ -998,7 +999,7 @@ if ($api_mode) { $item['coverArtLink'] = get_root_url() . "coverart?id=$id&version={$row['pagevsn']}"; } - if (isset($row['rounded_median_time_in_minutes'])) { + if ($row['rounded_median_time_in_minutes']) { $item['playTimeInMinutes'] = $row['rounded_median_time_in_minutes']; } @@ -1133,6 +1134,16 @@ else if ($term || $browse) echo "No results were found."; + if ($games_were_filtered) { + echo '

You have configured your account to filter game results by default. You can '; + if (!$browse) { + echo 'search again'; + } else if ($browse) { + echo 'also browse'; + } + echo ' without the filter.

'; + } + if ($searchType == "game") { echo "
" . "

Can't find the game you're looking for?

" @@ -1554,6 +1565,17 @@ else if ($term || $browse) // add the page controls again at the bottom, if applicable if ($pg != 1 || $rowcnt > $perPage) echo "
$pageCtl
"; + + // Announce that the game results are filtered, if applicable + if ($games_were_filtered) { + echo '
You have configured your account to filter game results by default. You can '; + if (!$browse) { + echo 'search again.'; + } else if ($browse) { + echo 'also browse'; + } + echo ' without the filter
'; + } } From e0198efe7712d85045477c9b26ebd76115c55539 Mon Sep 17 00:00:00 2001 From: alice-blue Date: Wed, 4 Dec 2024 18:13:05 -0500 Subject: [PATCH 05/72] Update ifdb-recommends.php to handle custom game filters --- www/components/ifdb-recommends.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/www/components/ifdb-recommends.php b/www/components/ifdb-recommends.php index e1f3986c..5ca3208c 100644 --- a/www/components/ifdb-recommends.php +++ b/www/components/ifdb-recommends.php @@ -21,12 +21,13 @@ function sortBySortorder($a, $b) $maxpicks = 12; // Get the first twelve results. (We want extras so we're not always displaying the same games.) $limit = "limit 0, $maxpicks"; $browse = 0; +$override_game_filter = 0; // run the search for highly-rated games list($recs, $rowcnt, $sortList, $errMsg, $summaryDesc, $badges, - $specials, $specialsUsed, $orderBy) = - doSearch($db, $term, $searchType, $sortby, $limit, $browse); + $specials, $specialsUsed, $orderBy, $games_were_filtered) = + doSearch($db, $term, $searchType, $sortby, $limit, $browse, $override_game_filter); // show some recommendations From d6421d72a6e92057346a913cff569f56edf952bd Mon Sep 17 00:00:00 2001 From: alice-blue Date: Wed, 4 Dec 2024 23:29:53 +0000 Subject: [PATCH 06/72] Misc fixes --- www/search | 8 ++++---- www/searchutil.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/www/search b/www/search index e516e16d..02db420a 100644 --- a/www/search +++ b/www/search @@ -1135,7 +1135,7 @@ else if ($term || $browse) echo "No results were found."; if ($games_were_filtered) { - echo '

You have configured your account to filter game results by default. You can '; + echo '

You have set up your account to filter game results by default. You can '; if (!$browse) { echo 'search again'; } else if ($browse) { @@ -1568,13 +1568,13 @@ else if ($term || $browse) // Announce that the game results are filtered, if applicable if ($games_were_filtered) { - echo '

You have configured your account to filter game results by default. You can '; + echo '

You have set up your account to filter game results by default. You can '; if (!$browse) { - echo 'search again.'; + echo 'search again'; } else if ($browse) { echo 'also browse'; } - echo ' without the filter

'; + echo ' without the filter.

'; } } diff --git a/www/searchutil.php b/www/searchutil.php index 8cf69b56..106a3b98 100644 --- a/www/searchutil.php +++ b/www/searchutil.php @@ -305,7 +305,7 @@ function doSearch($db, $term, $searchType, $sortby, $limit, $browse, $override_g // Handle custom game filters if ($curuser && $override_game_filter != 1) { // We're logged in, and haven't been told to override a custom game filter, so check for one - $result = mysqli_execute_query($db, "select game_search_filter from users where id = ?", [$curuser]); + $result = mysqli_execute_query($db, "select game_filter from users where id = ?", [$curuser]); if (!$result) throw new Exception("Error: " . mysqli_error($db)); [$gameFilter] = mysql_fetch_row($result); if ($gameFilter) { From 84ec72734b64e8b2640fa094b46e5f5a94f01110 Mon Sep 17 00:00:00 2001 From: alice-blue Date: Thu, 5 Dec 2024 13:50:54 +0000 Subject: [PATCH 07/72] Revise message to make it clear that results were actually filtered --- www/search | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/www/search b/www/search index 02db420a..cf01828b 100644 --- a/www/search +++ b/www/search @@ -1135,13 +1135,13 @@ else if ($term || $browse) echo "No results were found."; if ($games_were_filtered) { - echo '

You have set up your account to filter game results by default. You can '; + echo '

Results have been filtered because your account has a game filter in place. You can '; if (!$browse) { - echo 'search again'; + echo 'search again without the filter'; } else if ($browse) { - echo 'also browse'; + echo 'also browse without the filter'; } - echo ' without the filter.

'; + echo '.

'; } if ($searchType == "game") { @@ -1568,13 +1568,13 @@ else if ($term || $browse) // Announce that the game results are filtered, if applicable if ($games_were_filtered) { - echo '

You have set up your account to filter game results by default. You can '; + echo '

Results have been filtered because your account has a game filter in place. You can '; if (!$browse) { - echo 'search again'; + echo 'search again without the filter'; } else if ($browse) { - echo 'also browse'; + echo 'also browse without the filter'; } - echo ' without the filter.

'; + echo '.

'; } } From 6b05a6012af0db8054cd44552462d5f3f16065d0 Mon Sep 17 00:00:00 2001 From: alice-blue Date: Thu, 5 Dec 2024 18:07:36 +0000 Subject: [PATCH 08/72] Make a function to generate the "games were filtered" message since it's used in more than one place --- www/search | 18 ++++-------------- www/searchutil.php | 10 ++++++++++ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/www/search b/www/search index cf01828b..9c89efce 100644 --- a/www/search +++ b/www/search @@ -1135,13 +1135,8 @@ else if ($term || $browse) echo "No results were found."; if ($games_were_filtered) { - echo '

Results have been filtered because your account has a game filter in place. You can '; - if (!$browse) { - echo 'search again without the filter'; - } else if ($browse) { - echo 'also browse without the filter'; - } - echo '.

'; + $games_filtered_announcement = writeGamesFilteredAnnouncement($browse, $term); + echo '

' . $games_filtered_announcement . '

'; } if ($searchType == "game") { @@ -1568,13 +1563,8 @@ else if ($term || $browse) // Announce that the game results are filtered, if applicable if ($games_were_filtered) { - echo '

Results have been filtered because your account has a game filter in place. You can '; - if (!$browse) { - echo 'search again without the filter'; - } else if ($browse) { - echo 'also browse without the filter'; - } - echo '.

'; + $games_filtered_announcement = writeGamesFilteredAnnouncement($browse, $term); + echo '

' . $games_filtered_announcement . '

'; } } diff --git a/www/searchutil.php b/www/searchutil.php index 106a3b98..b3650831 100644 --- a/www/searchutil.php +++ b/www/searchutil.php @@ -42,6 +42,16 @@ function convertTimeStringToMinutes($h_m_string) { return $time_in_minutes; } +// Construct a message telling the user that the game results were filtered +function writeGamesFilteredAnnouncement($browse, $term) { + $games_filtered_announcement = 'Results have been filtered because your account has a game filter in place. You can '; + if (!$browse) { + $games_filtered_announcement .= 'search again without the filter.'; + } else if ($browse) { + $games_filtered_announcement .= 'also browse without the filter.'; + } + return $games_filtered_announcement; +} function doSearch($db, $term, $searchType, $sortby, $limit, $browse, $override_game_filter = 0) { From a0f8cbf9e899869b79388cf694f98d51078ad561 Mon Sep 17 00:00:00 2001 From: alice-blue Date: Sat, 7 Dec 2024 22:52:31 -0500 Subject: [PATCH 09/72] newitems.php: Modify getNewItems function to deal with game filters --- www/newitems.php | 67 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 59 insertions(+), 8 deletions(-) diff --git a/www/newitems.php b/www/newitems.php index 78c9ff23..a05ef094 100644 --- a/www/newitems.php +++ b/www/newitems.php @@ -1,5 +1,7 @@ date_sub(now(), interval $days day)"; // query the recent reviews (minus plonks) $anp = str_replace('#USERID#', 'reviews.userid', $andNotPlonked); @@ -199,11 +236,25 @@ function getNewItems($db, $limit, $itemTypes = NEWITEMS_ALLITEMS, $options = []) and $dayWhere $anp order by d desc, id desc - limit $reviews_limit", $db); + $reviews_limit_clause", $db); $revcnt = mysql_num_rows($result); - for ($i = 0 ; $i < $revcnt ; $i++) { - $row = mysql_fetch_array($result, MYSQL_ASSOC); - $items[] = array('R', $row['d'], $row); + if ($game_filter != "") { + for ($i = 0 ; $i < $revcnt ; $i++) { + $row = mysql_fetch_array($result, MYSQL_ASSOC); + // Only add the review to $items if it matches a gameid + // in $gameids_after_filtering + if (in_array($row['gameid'], $gameids_after_filtering)) { + $items[] = array('R', $row['d'], $row); + if ( count($items) == $reviews_limit ) { + break; + } + } + } + } else { + for ($i = 0 ; $i < $revcnt ; $i++) { + $row = mysql_fetch_array($result, MYSQL_ASSOC); + $items[] = array('R', $row['d'], $row); + } } } @@ -252,7 +303,7 @@ function getNewItems($db, $limit, $itemTypes = NEWITEMS_ALLITEMS, $options = []) usort($items, "sortNewItemsByDate"); // return the item list - return $items; + return array($items, $game_filter_was_applied); } // sorting callback: sort from newest to oldest @@ -351,7 +402,7 @@ function showNewItems($db, $first, $last, $items, $options = []) $itemTypes = $options['itemTypes'] ?? NEWITEMS_ALLITEMS; // if the caller didn't provide the new item lists, query them if (!$items) - $items = getNewItems($db, $last, $itemTypes, $options); + list($items, $game_filter_was_applied) = getNewItems($db, $last, $itemTypes, $options); // show them showNewItemList($db, $first, $last, $items, $options); @@ -718,7 +769,7 @@ function showNewItemList($db, $first, $last, $items, $options) function showNewItemsRSS($db, $showcnt) { // query the new items - $items = getNewItems($db, $showcnt - 1); + list($items, $game_filter_was_applied) = getNewItems($db, $showcnt - 1); $totcnt = count($items); $lastBuildDate = false; From 5cfbedb6353c687d14ebd0426089ac8724990ef3 Mon Sep 17 00:00:00 2001 From: alice-blue Date: Sat, 7 Dec 2024 22:54:45 -0500 Subject: [PATCH 10/72] allnew: show "games were filtered" message --- www/allnew | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/www/allnew b/www/allnew index 10b47e0d..bea9ee49 100644 --- a/www/allnew +++ b/www/allnew @@ -18,12 +18,13 @@ if ($pg < 1) $showFlagged = isset($_GET['showFlagged']) && $_GET['showFlagged']; + // calculate where that puts us in the results $firstOnPage = ($pg - 1) * PER_PAGE; $lastOnPage = $firstOnPage + PER_PAGE - 1; // query the items -$items = getNewItems($db, $lastOnPage + 1, $type); +list($items, $game_filter_was_applied) = getNewItems($db, $lastOnPage + 1, $type, $override_game_filter); $tot = count($items); $params = []; @@ -53,6 +54,11 @@ showNewItems($db, $firstOnPage, $lastOnPage, $items, ['showFlagged' => $showFlag echo "


$pageCtl
\n"; echo "

"; // prerender-moderate +if ($game_filter_was_applied) { + $games_filtered_announcement = writeGamesFilteredAnnouncement("all_new_reviews", null, null); + echo "

" . $games_filtered_announcement . "

"; +} + // end the page pageFooter(); From 9066155b20c1629fd7b58b12705ad6ddc0fca9a8 Mon Sep 17 00:00:00 2001 From: alice-blue Date: Sat, 7 Dec 2024 22:59:00 -0500 Subject: [PATCH 11/72] searchutil.php: revise the games filtered announcement function so that the message can be used on more pages --- www/searchutil.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/www/searchutil.php b/www/searchutil.php index b3650831..6bbe0ad8 100644 --- a/www/searchutil.php +++ b/www/searchutil.php @@ -42,17 +42,21 @@ function convertTimeStringToMinutes($h_m_string) { return $time_in_minutes; } + // Construct a message telling the user that the game results were filtered -function writeGamesFilteredAnnouncement($browse, $term) { +function writeGamesFilteredAnnouncement($page, $sort_order, $search_term) { $games_filtered_announcement = 'Results have been filtered because your account has a game filter in place. You can '; - if (!$browse) { - $games_filtered_announcement .= 'search again without the filter.'; - } else if ($browse) { - $games_filtered_announcement .= 'also browse without the filter.'; + if ($page == "search_games") { + $games_filtered_announcement .= 'search again without the filter.'; + } else if ($page == "browse_games") { + $games_filtered_announcement .= 'also browse without the filter.'; + } else if ($page == "all_new_reviews") { + $games_filtered_announcement .= 'also browse without the filter.'; } return $games_filtered_announcement; } + function doSearch($db, $term, $searchType, $sortby, $limit, $browse, $override_game_filter = 0) { // we need the current user for some types of queries From 9fd214345a813a17a542b7cb2c28bb56534804f1 Mon Sep 17 00:00:00 2001 From: alice-blue Date: Sat, 7 Dec 2024 23:05:15 -0500 Subject: [PATCH 12/72] search: use new parameters for filtered game message function --- www/search | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/www/search b/www/search index 9c89efce..337ceb45 100644 --- a/www/search +++ b/www/search @@ -1135,7 +1135,13 @@ else if ($term || $browse) echo "No results were found."; if ($games_were_filtered) { - $games_filtered_announcement = writeGamesFilteredAnnouncement($browse, $term); + $page = ""; + if ($browse) { + $page = "browse_games"; + } else { + $page = "search_games"; + } + $games_filtered_announcement = writeGamesFilteredAnnouncement($page, $sortby, $term); echo '

' . $games_filtered_announcement . '

'; } @@ -1563,7 +1569,13 @@ else if ($term || $browse) // Announce that the game results are filtered, if applicable if ($games_were_filtered) { - $games_filtered_announcement = writeGamesFilteredAnnouncement($browse, $term); + $page = ""; + if ($browse) { + $page = "browse_games"; + } else { + $page = "search_games"; + } + $games_filtered_announcement = writeGamesFilteredAnnouncement($page, $sortby, $term); echo '

' . $games_filtered_announcement . '

'; } } From afb1b7d72e02ce83c1deb95d65512d50898eabc9 Mon Sep 17 00:00:00 2001 From: alice-blue Date: Sat, 7 Dec 2024 23:20:24 -0500 Subject: [PATCH 13/72] home: add $game_filter_was_applied --- www/home | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/home b/www/home index 0378c2d5..1a31cd88 100644 --- a/www/home +++ b/www/home @@ -123,7 +123,7 @@ if ($debugflag) echo "debug mode enabled...
"; 1, 'lists_limit' => 2, 'polls_limit' => 2, @@ -137,7 +137,7 @@ if ($debugflag) echo "debug mode enabled...
"; 'enableImages' => false, ]); } else { - $items = getNewItems($db, 1, $itemTypes); + list($items, $game_filter_was_applied) = getNewItems($db, 1, $itemTypes); showNewItems($db, 0, 0, $items, [ 'allowHiddenBanner' => false, 'showDescriptions' => false, From d5e78b522b2fa8119dd302226b1944775580c019 Mon Sep 17 00:00:00 2001 From: alice-blue Date: Sat, 7 Dec 2024 23:24:24 -0500 Subject: [PATCH 14/72] Update competitions.php: add $game_filter_was_applied --- www/components/competitions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/components/competitions.php b/www/components/competitions.php index 7b8ae1fe..f9e11767 100644 --- a/www/components/competitions.php +++ b/www/components/competitions.php @@ -9,7 +9,7 @@ Browse competitions | Search competitions -

\ No newline at end of file +

From 1b15649a100b823bd757078089cdca6eae5c7ac5 Mon Sep 17 00:00:00 2001 From: alice-blue Date: Sat, 7 Dec 2024 23:37:19 -0500 Subject: [PATCH 15/72] Update recommended-lists.php: add $game_filter_was_applied --- www/components/recommended-lists.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/components/recommended-lists.php b/www/components/recommended-lists.php index 9ea9e703..15acbf7c 100644 --- a/www/components/recommended-lists.php +++ b/www/components/recommended-lists.php @@ -8,7 +8,7 @@ Browse lists | Search lists -

\ No newline at end of file +

From 7740129c5a5a535443b477216b1096111cde0e57 Mon Sep 17 00:00:00 2001 From: alice-blue Date: Sat, 7 Dec 2024 23:38:06 -0500 Subject: [PATCH 16/72] Update reviews.php: add $game_filter_was_applied --- www/components/reviews.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/components/reviews.php b/www/components/reviews.php index 89c591fd..03f70baf 100644 --- a/www/components/reviews.php +++ b/www/components/reviews.php @@ -1,7 +1,7 @@

Reviews

Date: Sun, 8 Dec 2024 04:47:35 +0000 Subject: [PATCH 17/72] games.php: add $game_filter_was_applied --- www/components/games.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/components/games.php b/www/components/games.php index 05c73cf4..711f88b1 100644 --- a/www/components/games.php +++ b/www/components/games.php @@ -17,7 +17,7 @@ define("ENABLE_IMAGES", 1); // get the latest games and game news -$items = getNewItems($db, 6, NEWITEMS_GAMES | NEWITEMS_GAMENEWS); +list($items, $game_filter_was_applied) = getNewItems($db, 6, NEWITEMS_GAMES | NEWITEMS_GAMENEWS); // show the items $totcnt = count($items); From 08b3e2b88f828e305e77bff31353a97790eec080 Mon Sep 17 00:00:00 2001 From: alice-blue Date: Sun, 8 Dec 2024 14:13:17 -0500 Subject: [PATCH 18/72] allnew: Remember if we're overriding the game filter when going to another page of results --- www/allnew | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/www/allnew b/www/allnew index bea9ee49..25593971 100644 --- a/www/allnew +++ b/www/allnew @@ -17,7 +17,7 @@ if ($pg < 1) $pg = 1; $showFlagged = isset($_GET['showFlagged']) && $_GET['showFlagged']; - +$override_game_filter = get_req_data('nogamefilter'); // calculate where that puts us in the results $firstOnPage = ($pg - 1) * PER_PAGE; @@ -32,8 +32,12 @@ if ($showFlagged) $params['showFlagged'] = 1; if ($reviews) $params['reviews'] = ""; // set up the page controls +$game_filter_parameter = ""; +if ($override_game_filter) { + $game_filter_parameter = "&nogamefilter=1"; +} $pageCtl = "" - . makePageControl("allnew?" . http_build_query($params), $pg, $pg + ($tot > PER_PAGE ? 1 : 0), + . makePageControl("allnew?" . http_build_query($params) . $game_filter_parameter, $pg, $pg + ($tot > PER_PAGE ? 1 : 0), $firstOnPage, $lastOnPage, -1, false, false, false) . ""; From acfc5b2dc6cd822994e7e66b63c89ae0c5854901 Mon Sep 17 00:00:00 2001 From: alice-blue Date: Sun, 8 Dec 2024 14:15:50 -0500 Subject: [PATCH 19/72] search: When we go to the next page of results, remember if we're overriding the game filter --- www/search | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/www/search b/www/search index 337ceb45..c9bf4d82 100644 --- a/www/search +++ b/www/search @@ -1122,7 +1122,8 @@ else if ($term || $browse) . ($searchType == "poll" ? "&poll" : "") . ($searchType == "member" ? "&member" : "") . ($searchType == "comp" ? "&comp" : "") - . ($searchType == "tag" ? "&tag" : ""), + . ($searchType == "tag" ? "&tag" : "") + . ($override_game_filter ? "&nogamefilter=1" : ""), $pg, $lastPage, $firstOnPage, $lastOnPage, $rowcnt, true, $rowcnt < $showAllMaxRows, $pgAll) From 6768a7904b77c7079f16f854ef2f4f591723c87c Mon Sep 17 00:00:00 2001 From: alice-blue Date: Sun, 8 Dec 2024 14:50:42 -0500 Subject: [PATCH 20/72] searchutil.php: Avoid implying that results were hidden, since we don't know if they were. --- www/searchutil.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/searchutil.php b/www/searchutil.php index 6bbe0ad8..924d65a4 100644 --- a/www/searchutil.php +++ b/www/searchutil.php @@ -45,7 +45,7 @@ function convertTimeStringToMinutes($h_m_string) { // Construct a message telling the user that the game results were filtered function writeGamesFilteredAnnouncement($page, $sort_order, $search_term) { - $games_filtered_announcement = 'Results have been filtered because your account has a game filter in place. You can '; + $games_filtered_announcement = 'Your account is set up to use a game filter by default, and the filter was applied on this page. You can '; if ($page == "search_games") { $games_filtered_announcement .= 'search again without the filter.'; } else if ($page == "browse_games") { From 89abff70ab4f1b99c5c4fe996d4b272e3ead7527 Mon Sep 17 00:00:00 2001 From: alice-blue Date: Sun, 8 Dec 2024 15:01:22 -0500 Subject: [PATCH 21/72] searchutil.php: the --> that --- www/searchutil.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/searchutil.php b/www/searchutil.php index 924d65a4..a2327195 100644 --- a/www/searchutil.php +++ b/www/searchutil.php @@ -45,7 +45,7 @@ function convertTimeStringToMinutes($h_m_string) { // Construct a message telling the user that the game results were filtered function writeGamesFilteredAnnouncement($page, $sort_order, $search_term) { - $games_filtered_announcement = 'Your account is set up to use a game filter by default, and the filter was applied on this page. You can '; + $games_filtered_announcement = 'Your account is set up to use a game filter by default, and that filter was applied on this page. You can '; if ($page == "search_games") { $games_filtered_announcement .= 'search again without the filter.'; } else if ($page == "browse_games") { From 61fbf4ca02438831670b198973bcfee1127af3d8 Mon Sep 17 00:00:00 2001 From: alice-blue Date: Sat, 11 Jan 2025 04:56:07 +0000 Subject: [PATCH 22/72] add lastReviewDate column to gameRatingsSandbox0_mv --- sql/incoming-schema-changes.sql | 11 +++++++++++ sql/unscrub-ifarchive.sql | 5 ++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/sql/incoming-schema-changes.sql b/sql/incoming-schema-changes.sql index 7c62d0e7..99ef67b7 100644 --- a/sql/incoming-schema-changes.sql +++ b/sql/incoming-schema-changes.sql @@ -11,3 +11,14 @@ alter table reviewvotes -- Add column for game search filter to the users table ALTER TABLE `users` ADD COLUMN `game_filter` VARCHAR(150) DEFAULT ''; + + + +-- Add column for the publication date of the most recent review to the +-- game ratings sandbox materialized view + +ALTER TABLE `gameRatingsSandbox0_mv` ADD COLUMN `lastReviewDate` tinyint NOT NULL; + + + + diff --git a/sql/unscrub-ifarchive.sql b/sql/unscrub-ifarchive.sql index 4a13bbc3..689e9847 100644 --- a/sql/unscrub-ifarchive.sql +++ b/sql/unscrub-ifarchive.sql @@ -911,7 +911,8 @@ where gameid = new_gameid into @gameid, @numMemberReviews, @avgRating, @stdDevRating, - @starsort; + @starsort, + @lastReviewDate; if @gameid is null then delete from gameRatingsSandbox0_mv where gameid = new_gameid; else @@ -929,6 +930,7 @@ values ( @avgRating, @stdDevRating, @starsort, + @lastReviewDate, now() ) on duplicate key update gameid = @gameid, @@ -943,6 +945,7 @@ update gameid = @gameid, avgRating = @avgRating, stdDevRating = @stdDevRating, starsort = @starsort, + lastReviewDate = @lastReviewDate, updated = now(); END IF; END; From 5b7854f53cdce03f5f33550f7985366ad886e7d8 Mon Sep 17 00:00:00 2001 From: alice-blue Date: Thu, 16 Jan 2025 01:17:32 +0000 Subject: [PATCH 23/72] add lastreviewdate to line 430 --- sql/unscrub-ifarchive.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql/unscrub-ifarchive.sql b/sql/unscrub-ifarchive.sql index 689e9847..731e8734 100644 --- a/sql/unscrub-ifarchive.sql +++ b/sql/unscrub-ifarchive.sql @@ -426,7 +426,8 @@ from ( `ifdb`.`reviews`.`rating` AS `rating`, `ifdb`.`games`.`id` AS `gameid`, ifnull(`ifdb`.`reviews`.`RFlags`, 0) & 2 AS `omitted`, - `ifdb`.`reviews`.`review` is not null AS `hasReview` + `ifdb`.`reviews`.`review` is not null AS `hasReview`, + max(ifnull(embargodate, createdate)) AS `lastReviewDate` from ( `ifdb`.`games` left outer join `ifdb`.`reviews` on (`ifdb`.`games`.`id` = `ifdb`.`reviews`.`gameid`) From ee2c725295e9ee3f2502a4b76793ca5ec50e2098 Mon Sep 17 00:00:00 2001 From: alice-blue Date: Thu, 16 Jan 2025 02:01:08 +0000 Subject: [PATCH 24/72] compute the maximum lastReviewDate of all of the grouped rows where hasReview is true --- sql/unscrub-ifarchive.sql | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sql/unscrub-ifarchive.sql b/sql/unscrub-ifarchive.sql index 731e8734..b81fdbc4 100644 --- a/sql/unscrub-ifarchive.sql +++ b/sql/unscrub-ifarchive.sql @@ -420,7 +420,13 @@ from ( when `grouped`.`hasReview` then `grouped`.`count` else 0 end - ) AS `numMemberReviews` + ) AS `numMemberReviews`, + max( + case + when `grouped`.`hasReview` then `grouped`.`lastReviewDate` + else null + end + ) AS `lastReviewDate` from ( select count(`ifdb`.`reviews`.`id`) AS `count`, `ifdb`.`reviews`.`rating` AS `rating`, From 235cde76b3b95b4c120445977f59349acf805acd Mon Sep 17 00:00:00 2001 From: alice-blue Date: Thu, 16 Jan 2025 03:03:34 +0000 Subject: [PATCH 25/72] game id for testing --- sql/unscrub-ifarchive.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sql/unscrub-ifarchive.sql b/sql/unscrub-ifarchive.sql index b81fdbc4..95b7f472 100644 --- a/sql/unscrub-ifarchive.sql +++ b/sql/unscrub-ifarchive.sql @@ -445,6 +445,8 @@ from ( 1 ) and `ifdb`.`reviews`.`special` is null +-- testing on Rendition + and games.id = 'uamh4vrhqkcfdsu' group by `ifdb`.`reviews`.`rating`, `ifdb`.`games`.`id`, ifnull(`ifdb`.`reviews`.`RFlags`, 0) & 2, From e30b238b5a3c2748ad5f3c77572fb4e8e2b3646d Mon Sep 17 00:00:00 2001 From: alice-blue Date: Thu, 16 Jan 2025 19:05:58 +0000 Subject: [PATCH 26/72] comment out specific game that we were testing --- sql/unscrub-ifarchive.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/unscrub-ifarchive.sql b/sql/unscrub-ifarchive.sql index 95b7f472..b9f407ee 100644 --- a/sql/unscrub-ifarchive.sql +++ b/sql/unscrub-ifarchive.sql @@ -446,7 +446,7 @@ from ( ) and `ifdb`.`reviews`.`special` is null -- testing on Rendition - and games.id = 'uamh4vrhqkcfdsu' +-- and games.id = 'uamh4vrhqkcfdsu' group by `ifdb`.`reviews`.`rating`, `ifdb`.`games`.`id`, ifnull(`ifdb`.`reviews`.`RFlags`, 0) & 2, From 5afce900ffd8868b0881172eb22cd45862011d95 Mon Sep 17 00:00:00 2001 From: alice-blue Date: Fri, 17 Jan 2025 00:38:03 +0000 Subject: [PATCH 27/72] lastReviewDate --> lastRatingDate --- sql/unscrub-ifarchive.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/unscrub-ifarchive.sql b/sql/unscrub-ifarchive.sql index b9f407ee..042e658e 100644 --- a/sql/unscrub-ifarchive.sql +++ b/sql/unscrub-ifarchive.sql @@ -423,7 +423,7 @@ from ( ) AS `numMemberReviews`, max( case - when `grouped`.`hasReview` then `grouped`.`lastReviewDate` + when `grouped`.`hasReview` then `grouped`.`lastRatingDate` else null end ) AS `lastReviewDate` @@ -433,7 +433,7 @@ from ( `ifdb`.`games`.`id` AS `gameid`, ifnull(`ifdb`.`reviews`.`RFlags`, 0) & 2 AS `omitted`, `ifdb`.`reviews`.`review` is not null AS `hasReview`, - max(ifnull(embargodate, createdate)) AS `lastReviewDate` + max(ifnull(embargodate, createdate)) AS `lastRatingDate` from ( `ifdb`.`games` left outer join `ifdb`.`reviews` on (`ifdb`.`games`.`id` = `ifdb`.`reviews`.`gameid`) From e81351febd7c01a5de2bf8968c829bcd2b294e53 Mon Sep 17 00:00:00 2001 From: alice-blue Date: Fri, 17 Jan 2025 01:16:45 +0000 Subject: [PATCH 28/72] lastRatingDate --> lastRatingOrReviewDate --- sql/unscrub-ifarchive.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/unscrub-ifarchive.sql b/sql/unscrub-ifarchive.sql index 042e658e..8e91bfc0 100644 --- a/sql/unscrub-ifarchive.sql +++ b/sql/unscrub-ifarchive.sql @@ -423,7 +423,7 @@ from ( ) AS `numMemberReviews`, max( case - when `grouped`.`hasReview` then `grouped`.`lastRatingDate` + when `grouped`.`hasReview` then `grouped`.`lastRatingOrReviewDate` else null end ) AS `lastReviewDate` @@ -433,7 +433,7 @@ from ( `ifdb`.`games`.`id` AS `gameid`, ifnull(`ifdb`.`reviews`.`RFlags`, 0) & 2 AS `omitted`, `ifdb`.`reviews`.`review` is not null AS `hasReview`, - max(ifnull(embargodate, createdate)) AS `lastRatingDate` + max(ifnull(embargodate, createdate)) AS `lastRatingOrReviewDate` from ( `ifdb`.`games` left outer join `ifdb`.`reviews` on (`ifdb`.`games`.`id` = `ifdb`.`reviews`.`gameid`) From 1c43e3071b1a1de2d6f4a5c0c38ca23f566a6965 Mon Sep 17 00:00:00 2001 From: alice-blue Date: Fri, 17 Jan 2025 01:36:35 +0000 Subject: [PATCH 29/72] put lastReviewDate in all the right places --- sql/incoming-schema-changes.sql | 5 ----- sql/unscrub-ifarchive.sql | 3 +++ 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/sql/incoming-schema-changes.sql b/sql/incoming-schema-changes.sql index 99ef67b7..33cc5a4b 100644 --- a/sql/incoming-schema-changes.sql +++ b/sql/incoming-schema-changes.sql @@ -14,11 +14,6 @@ ALTER TABLE `users` ADD COLUMN `game_filter` VARCHAR(150) DEFAULT ''; --- Add column for the publication date of the most recent review to the --- game ratings sandbox materialized view - -ALTER TABLE `gameRatingsSandbox0_mv` ADD COLUMN `lastReviewDate` tinyint NOT NULL; - diff --git a/sql/unscrub-ifarchive.sql b/sql/unscrub-ifarchive.sql index 8e91bfc0..df51f727 100644 --- a/sql/unscrub-ifarchive.sql +++ b/sql/unscrub-ifarchive.sql @@ -311,6 +311,7 @@ select `averaged`.`gameid` AS `gameid`, `averaged`.`numRatingsInAvg` AS `numRatingsInAvg`, `averaged`.`numRatingsTotal` AS `numRatingsTotal`, `averaged`.`numMemberReviews` AS `numMemberReviews`, + `averaged`.`lastReviewDate` AS `lastReviewDate`, `averaged`.`avgRating` AS `avgRating`, pow( ( @@ -358,6 +359,7 @@ from ( `rating_counts`.`numRatingsInAvg` AS `numRatingsInAvg`, `rating_counts`.`numRatingsTotal` AS `numRatingsTotal`, `rating_counts`.`numMemberReviews` AS `numMemberReviews`, + `rating_counts`.`lastReviewDate` AS `lastReviewDate`, ( `rating_counts`.`rated1` + `rating_counts`.`rated2` * 2 @@ -882,6 +884,7 @@ create table gameRatingsSandbox0_mv ( `numRatingsInAvg` int unsigned, `numRatingsTotal` int unsigned, `numMemberReviews` int unsigned, + `lastReviewDate` tinyint NOT NULL; `avgRating` double, `stdDevRating` double, `starsort` double, From 86352e05e7e846daf3d0d4247f681fd7068c618e Mon Sep 17 00:00:00 2001 From: alice-blue Date: Fri, 17 Jan 2025 01:52:43 +0000 Subject: [PATCH 30/72] ; --> , --- sql/unscrub-ifarchive.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/unscrub-ifarchive.sql b/sql/unscrub-ifarchive.sql index df51f727..aa061468 100644 --- a/sql/unscrub-ifarchive.sql +++ b/sql/unscrub-ifarchive.sql @@ -884,7 +884,7 @@ create table gameRatingsSandbox0_mv ( `numRatingsInAvg` int unsigned, `numRatingsTotal` int unsigned, `numMemberReviews` int unsigned, - `lastReviewDate` tinyint NOT NULL; + `lastReviewDate` tinyint NOT NULL, `avgRating` double, `stdDevRating` double, `starsort` double, From f6d99847e1344876984852fef865fac6f532d5bd Mon Sep 17 00:00:00 2001 From: alice-blue Date: Fri, 17 Jan 2025 02:20:39 +0000 Subject: [PATCH 31/72] + key --- sql/unscrub-ifarchive.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql/unscrub-ifarchive.sql b/sql/unscrub-ifarchive.sql index aa061468..37a121ed 100644 --- a/sql/unscrub-ifarchive.sql +++ b/sql/unscrub-ifarchive.sql @@ -895,7 +895,8 @@ create table gameRatingsSandbox0_mv ( KEY `numMemberReviews` (`numMemberReviews`), KEY `avgRating` (`avgRating`), KEY `stdDevRating` (`stdDevRating`), - KEY `starsort` (`starsort`) + KEY `starsort` (`starsort`), + KEY `lastReviewDate` (`lastReviewDate`) ) ENGINE = MyISAM DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci; lock tables gameRatingsSandbox0_mv write, gameRatingsSandbox0 read; From 5753fb88222125934545293ea8d442947bb74e2f Mon Sep 17 00:00:00 2001 From: alice-blue Date: Fri, 17 Jan 2025 04:15:33 +0000 Subject: [PATCH 32/72] trying to sort by the lastReview column --- www/newitems.php | 2 +- www/searchutil.php | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/www/newitems.php b/www/newitems.php index a05ef094..541e60ce 100644 --- a/www/newitems.php +++ b/www/newitems.php @@ -186,7 +186,7 @@ function getNewItems($db, $limit, $itemTypes = NEWITEMS_ALLITEMS, $options = [], // Find games that have at least one review, and use the custom game filter to filter them $term = "#reviews:1-"; $searchType = "game"; - $sortby = "lnew"; + $sortby = "recently_reviewed"; $limit = null; $browse = 0; list($game_rows_after_filtering, $rowcnt, $sortList, $errMsg, $summaryDesc, $badges, $specials, $specialsUsed, $orderBy) = diff --git a/www/searchutil.php b/www/searchutil.php index a2327195..f23e05a2 100644 --- a/www/searchutil.php +++ b/www/searchutil.php @@ -293,6 +293,7 @@ function doSearch($db, $term, $searchType, $sortby, $limit, $browse, $override_g stdDevRating as ratingdev, numRatingsTotal, numMemberReviews, + lastReviewDate, starsort, games.sort_title as sort_title, games.sort_author as sort_author, @@ -956,6 +957,7 @@ function doSearch($db, $term, $searchType, $sortby, $limit, $browse, $override_g 'Rating Deviation - Low to High'), 'new' => array('published desc,', 'Latest Publication First'), 'old' => array('sort_pub,', 'Earliest Publication First'), + 'recently_reviewed' => array('lastReviewDate desc,', 'Recently Reviewed First'), 'rand' => array('rand(),', 'Random Order')); if (count($words)) { $defSortBy = 'rel'; From b2dfe67aa04a86787e302c158b08ef34f1e702ce Mon Sep 17 00:00:00 2001 From: alice-blue Date: Sat, 18 Jan 2025 01:06:35 +0000 Subject: [PATCH 33/72] remove lines for specific game being tested --- sql/unscrub-ifarchive.sql | 2 -- 1 file changed, 2 deletions(-) diff --git a/sql/unscrub-ifarchive.sql b/sql/unscrub-ifarchive.sql index 37a121ed..bc477f03 100644 --- a/sql/unscrub-ifarchive.sql +++ b/sql/unscrub-ifarchive.sql @@ -447,8 +447,6 @@ from ( 1 ) and `ifdb`.`reviews`.`special` is null --- testing on Rendition --- and games.id = 'uamh4vrhqkcfdsu' group by `ifdb`.`reviews`.`rating`, `ifdb`.`games`.`id`, ifnull(`ifdb`.`reviews`.`RFlags`, 0) & 2, From f6276fbd4484970d30886468c519efb55bad18f7 Mon Sep 17 00:00:00 2001 From: alice-blue Date: Sat, 18 Jan 2025 01:10:22 +0000 Subject: [PATCH 34/72] limit to 100 resuults --- www/newitems.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/newitems.php b/www/newitems.php index 541e60ce..f857b38e 100644 --- a/www/newitems.php +++ b/www/newitems.php @@ -187,7 +187,7 @@ function getNewItems($db, $limit, $itemTypes = NEWITEMS_ALLITEMS, $options = [], $term = "#reviews:1-"; $searchType = "game"; $sortby = "recently_reviewed"; - $limit = null; + $limit = 100; $browse = 0; list($game_rows_after_filtering, $rowcnt, $sortList, $errMsg, $summaryDesc, $badges, $specials, $specialsUsed, $orderBy) = doSearch($db, $term, $searchType, $sortby, $limit, $browse); From a55a0ed21eae1a55f94fe87d676a75febb765659 Mon Sep 17 00:00:00 2001 From: alice-blue Date: Sat, 18 Jan 2025 01:36:28 +0000 Subject: [PATCH 35/72] Update comments --- www/newitems.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/www/newitems.php b/www/newitems.php index f857b38e..63bfcd77 100644 --- a/www/newitems.php +++ b/www/newitems.php @@ -183,7 +183,10 @@ function getNewItems($db, $limit, $itemTypes = NEWITEMS_ALLITEMS, $options = [], if (!$result) throw new Exception("Error: " . mysqli_error($db)); [$game_filter] = mysql_fetch_row($result); if ($game_filter != "") { - // Find games that have at least one review, and use the custom game filter to filter them + // Find games that have at least one review, + // sort recently reviewed games to the top, + // and retrieve the first 100 filtered game results. + // Custom game filter gets applied in doSearch. $term = "#reviews:1-"; $searchType = "game"; $sortby = "recently_reviewed"; @@ -199,8 +202,9 @@ function getNewItems($db, $limit, $itemTypes = NEWITEMS_ALLITEMS, $options = [], } } if (!$game_filter_was_applied) { - // We're not applying a game filter, so we don't need extra reviews. (We only need extras if some of them might get filtered out.) - // That means we can use a limit clause for reviews. + // We're not applying a game filter, so we don't need extra reviews. + // (We only need extras if some of them might get filtered out.) + // We can limit results to the exact number we want to display. $reviews_limit_clause = "limit $reviews_limit"; } // prepare to query reviews From 255a5dfa14ef65a1b592493da8fe04bb8e1b8b18 Mon Sep 17 00:00:00 2001 From: alice-blue Date: Sat, 18 Jan 2025 01:41:45 +0000 Subject: [PATCH 36/72] oops, $limit should be a clause --- www/newitems.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/newitems.php b/www/newitems.php index 63bfcd77..55abd659 100644 --- a/www/newitems.php +++ b/www/newitems.php @@ -190,7 +190,7 @@ function getNewItems($db, $limit, $itemTypes = NEWITEMS_ALLITEMS, $options = [], $term = "#reviews:1-"; $searchType = "game"; $sortby = "recently_reviewed"; - $limit = 100; + $limit = "limit 100"; $browse = 0; list($game_rows_after_filtering, $rowcnt, $sortList, $errMsg, $summaryDesc, $badges, $specials, $specialsUsed, $orderBy) = doSearch($db, $term, $searchType, $sortby, $limit, $browse); From fe0e521a50601420ba14fb880317a7b79b67f6bb Mon Sep 17 00:00:00 2001 From: alice-blue Date: Sat, 18 Jan 2025 13:51:05 +0000 Subject: [PATCH 37/72] unscrub-ifarchive.sql: tinyint --> datetime --- sql/unscrub-ifarchive.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/unscrub-ifarchive.sql b/sql/unscrub-ifarchive.sql index bc477f03..5f8f3406 100644 --- a/sql/unscrub-ifarchive.sql +++ b/sql/unscrub-ifarchive.sql @@ -882,7 +882,7 @@ create table gameRatingsSandbox0_mv ( `numRatingsInAvg` int unsigned, `numRatingsTotal` int unsigned, `numMemberReviews` int unsigned, - `lastReviewDate` tinyint NOT NULL, + `lastReviewDate` datetime NOT NULL, `avgRating` double, `stdDevRating` double, `starsort` double, From 207acf62615af40343f5996dd7012fe85a007529 Mon Sep 17 00:00:00 2001 From: alice-blue Date: Sat, 18 Jan 2025 13:51:59 +0000 Subject: [PATCH 38/72] add "lastreview:" search prefix --- www/searchutil.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/www/searchutil.php b/www/searchutil.php index f23e05a2..165020aa 100644 --- a/www/searchutil.php +++ b/www/searchutil.php @@ -267,7 +267,8 @@ function doSearch($db, $term, $searchType, $sortby, $limit, $browse, $override_g "rated:" => array("rated", 99), "license:" => array("license", 0), "competitionid:" => array("competitionid", 99), - "format:" => array("/gameformat/", 99)); + "format:" => array("/gameformat/", 99), + "lastreview:" => array("lastReviewDate", 4)); // SELECT parameters for game queries From b0de4045d310e8a02b4fd5164d9f268b55428494 Mon Sep 17 00:00:00 2001 From: alice-blue Date: Sat, 18 Jan 2025 13:53:52 +0000 Subject: [PATCH 39/72] newitems.php: Add "lastReviewDate:90d-" to search term when looking for filtered games --- www/newitems.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/www/newitems.php b/www/newitems.php index 55abd659..3d4928dd 100644 --- a/www/newitems.php +++ b/www/newitems.php @@ -183,14 +183,15 @@ function getNewItems($db, $limit, $itemTypes = NEWITEMS_ALLITEMS, $options = [], if (!$result) throw new Exception("Error: " . mysqli_error($db)); [$game_filter] = mysql_fetch_row($result); if ($game_filter != "") { - // Find games that have at least one review, + // Find games that have been reviewed in the last 90 days, // sort recently reviewed games to the top, - // and retrieve the first 100 filtered game results. + // and retrieve the number of results we need. // Custom game filter gets applied in doSearch. - $term = "#reviews:1-"; + $term = "lastReviewDate:90d-"; $searchType = "game"; $sortby = "recently_reviewed"; - $limit = "limit 100"; +// $limit = "limit 100"; + $limit = "limit $review_limit"; $browse = 0; list($game_rows_after_filtering, $rowcnt, $sortList, $errMsg, $summaryDesc, $badges, $specials, $specialsUsed, $orderBy) = doSearch($db, $term, $searchType, $sortby, $limit, $browse); From a6d0fcdc04df7b79fe98df52a8fdd75064f00e98 Mon Sep 17 00:00:00 2001 From: alice-blue Date: Sat, 18 Jan 2025 14:30:31 +0000 Subject: [PATCH 40/72] newitems: when fetching reviews and a filter is applied, look for games reviewed within the past 365 days --- www/newitems.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/www/newitems.php b/www/newitems.php index 3d4928dd..d3572c7e 100644 --- a/www/newitems.php +++ b/www/newitems.php @@ -187,11 +187,10 @@ function getNewItems($db, $limit, $itemTypes = NEWITEMS_ALLITEMS, $options = [], // sort recently reviewed games to the top, // and retrieve the number of results we need. // Custom game filter gets applied in doSearch. - $term = "lastReviewDate:90d-"; + $term = "lastreview:365d-"; $searchType = "game"; $sortby = "recently_reviewed"; -// $limit = "limit 100"; - $limit = "limit $review_limit"; + $limit = "limit $reviews_limit"; $browse = 0; list($game_rows_after_filtering, $rowcnt, $sortList, $errMsg, $summaryDesc, $badges, $specials, $specialsUsed, $orderBy) = doSearch($db, $term, $searchType, $sortby, $limit, $browse); From 9519782a02fe7dcc917ba6ce68a6ed70da7479e0 Mon Sep 17 00:00:00 2001 From: alice-blue Date: Sat, 18 Jan 2025 14:41:55 +0000 Subject: [PATCH 41/72] revise comments --- www/newitems.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/www/newitems.php b/www/newitems.php index d3572c7e..4abb6847 100644 --- a/www/newitems.php +++ b/www/newitems.php @@ -183,10 +183,11 @@ function getNewItems($db, $limit, $itemTypes = NEWITEMS_ALLITEMS, $options = [], if (!$result) throw new Exception("Error: " . mysqli_error($db)); [$game_filter] = mysql_fetch_row($result); if ($game_filter != "") { - // Find games that have been reviewed in the last 90 days, - // sort recently reviewed games to the top, - // and retrieve the number of results we need. - // Custom game filter gets applied in doSearch. + // Find games that have been reviewed in the last 365 days + // (the date limit is to avoid a full table scan). + // Sort the most recently reviewed games to the top, + // and get the number of results we need. + // The custom game filter gets applied in doSearch. $term = "lastreview:365d-"; $searchType = "game"; $sortby = "recently_reviewed"; From 2449900079e5293f27c7b282be32a73aced1e36f Mon Sep 17 00:00:00 2001 From: alice-blue Date: Sat, 18 Jan 2025 15:27:07 +0000 Subject: [PATCH 42/72] misc fixes --- www/newitems.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/www/newitems.php b/www/newitems.php index 4abb6847..0ce25822 100644 --- a/www/newitems.php +++ b/www/newitems.php @@ -183,18 +183,20 @@ function getNewItems($db, $limit, $itemTypes = NEWITEMS_ALLITEMS, $options = [], if (!$result) throw new Exception("Error: " . mysqli_error($db)); [$game_filter] = mysql_fetch_row($result); if ($game_filter != "") { - // Find games that have been reviewed in the last 365 days - // (the date limit is to avoid a full table scan). + // Find games that have been reviewed in the past 365 days. + // (This condition is to avoid a slow full table scan.) // Sort the most recently reviewed games to the top, - // and get the number of results we need. - // The custom game filter gets applied in doSearch. + // and fetch the correct number of games (at most, we'll + // need the same number of games as the number of reviews + // we're ultimately looking for). The custom game filter + // gets applied in doSearch. $term = "lastreview:365d-"; $searchType = "game"; $sortby = "recently_reviewed"; - $limit = "limit $reviews_limit"; + $games_limit_clause = "limit $reviews_limit"; $browse = 0; list($game_rows_after_filtering, $rowcnt, $sortList, $errMsg, $summaryDesc, $badges, $specials, $specialsUsed, $orderBy) = - doSearch($db, $term, $searchType, $sortby, $limit, $browse); + doSearch($db, $term, $searchType, $sortby, $games_limit_clause, $browse); // Note the gameids of games that we might want to display reviews for foreach ($game_rows_after_filtering as $game_row) { $gameids_after_filtering[] = $game_row['id']; From 69c1c3a65b65db500c6068b7a3a91adeab6d2278 Mon Sep 17 00:00:00 2001 From: alice-blue Date: Sat, 18 Jan 2025 15:38:43 +0000 Subject: [PATCH 43/72] explain "lastreview:" in the comments --- www/searchutil.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/www/searchutil.php b/www/searchutil.php index 165020aa..14eb8d2d 100644 --- a/www/searchutil.php +++ b/www/searchutil.php @@ -268,6 +268,8 @@ function doSearch($db, $term, $searchType, $sortby, $limit, $browse, $override_g "license:" => array("license", 0), "competitionid:" => array("competitionid", 99), "format:" => array("/gameformat/", 99), + // "lastreview:" is not documented for users. It's used in newitems.php + // to fetch new reviews when a custom game filter is applied. "lastreview:" => array("lastReviewDate", 4)); From d0f1a38a5a1c27fd3a6fb8a80792c2b48b3501d8 Mon Sep 17 00:00:00 2001 From: alice-blue Date: Sat, 18 Jan 2025 15:43:11 +0000 Subject: [PATCH 44/72] comment --- www/searchutil.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/www/searchutil.php b/www/searchutil.php index 14eb8d2d..63539743 100644 --- a/www/searchutil.php +++ b/www/searchutil.php @@ -269,7 +269,8 @@ function doSearch($db, $term, $searchType, $sortby, $limit, $browse, $override_g "competitionid:" => array("competitionid", 99), "format:" => array("/gameformat/", 99), // "lastreview:" is not documented for users. It's used in newitems.php - // to fetch new reviews when a custom game filter is applied. + // as part of finding new reviews to display when a custom game filter + // is applied. "lastreview:" => array("lastReviewDate", 4)); From 157bf5f1b593b6d8c38b554622b9632a12ceeef3 Mon Sep 17 00:00:00 2001 From: alice-blue Date: Sun, 19 Jan 2025 01:31:31 +0000 Subject: [PATCH 45/72] searchutil.php: Add $count_all_possible_rows parameter to doSearch --- www/searchutil.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/www/searchutil.php b/www/searchutil.php index 40d30122..e1849a43 100644 --- a/www/searchutil.php +++ b/www/searchutil.php @@ -57,7 +57,7 @@ function writeGamesFilteredAnnouncement($page, $sort_order, $search_term) { } -function doSearch($db, $term, $searchType, $sortby, $limit, $browse, $override_game_filter = 0) +function doSearch($db, $term, $searchType, $sortby, $limit, $browse, $count_all_possible_rows = false, $override_game_filter = 0) { // we need the current user for some types of queries checkPersistentLogin(); @@ -1155,6 +1155,14 @@ function doSearch($db, $term, $searchType, $sortby, $limit, $browse, $override_g // But when browsing for all games, we can do a fast `count(*)` query instead $sql_calc_found_rows = ""; } + if (!$count_all_possible_rows) { + // `sql_calc_found_rows` forces the query to ignore the `limit` clause + // in order to count all possible results, which means a slower full + // table scan. If the total number of rows is not needed, we can skip + // `sql_calc_found_rows` to speed up the query. + $sql_calc_found_rows = ""; + } + // build the SELECT statement $sql = "select $sql_calc_found_rows From 310ebac9bae9c7cd1304d77f68817d4f1b83ba26 Mon Sep 17 00:00:00 2001 From: alice-blue Date: Sun, 19 Jan 2025 01:33:07 +0000 Subject: [PATCH 46/72] ifdb-recommends.php: Use $count_all_possible_rows parameter in call to doSearch --- www/components/ifdb-recommends.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/www/components/ifdb-recommends.php b/www/components/ifdb-recommends.php index 5ca3208c..3f0f3220 100644 --- a/www/components/ifdb-recommends.php +++ b/www/components/ifdb-recommends.php @@ -21,13 +21,14 @@ function sortBySortorder($a, $b) $maxpicks = 12; // Get the first twelve results. (We want extras so we're not always displaying the same games.) $limit = "limit 0, $maxpicks"; $browse = 0; +$count_all_possible_rows = false; $override_game_filter = 0; // run the search for highly-rated games list($recs, $rowcnt, $sortList, $errMsg, $summaryDesc, $badges, $specials, $specialsUsed, $orderBy, $games_were_filtered) = - doSearch($db, $term, $searchType, $sortby, $limit, $browse, $override_game_filter); + doSearch($db, $term, $searchType, $sortby, $limit, $browse, $count_all_possible_rows, $override_game_filter); // show some recommendations From be1f66707246915135d07895b5a58122f0b820a1 Mon Sep 17 00:00:00 2001 From: alice-blue Date: Sun, 19 Jan 2025 01:34:03 +0000 Subject: [PATCH 47/72] review: Use $count_all_possible_rows parameter and $override_game_filter in call to doSearch --- www/review | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/www/review b/www/review index 08bb480b..38e8577c 100644 --- a/www/review +++ b/www/review @@ -142,8 +142,10 @@ if (isset($_REQUEST['browse'])) if ($searchFor) { // run the search + $count_all_possible_rows = false; + $override_game_filter = 0; list($rows, $rowcnt, $sortList, $errMsg) = - doSearch($db, $searchFor, "game", "rel", "limit 0, 10", false); + doSearch($db, $searchFor, "game", "rel", "limit 0, 10", false, $count_all_possible_rows, $override_game_filter); // show the results $term = htmlspecialcharx($searchFor); From 0954a8b7b43e39eae60502c3f103f887970b2d7b Mon Sep 17 00:00:00 2001 From: alice-blue Date: Sun, 19 Jan 2025 01:35:56 +0000 Subject: [PATCH 48/72] search: Use $count_all_possible_rows parameter in call to doSearch --- www/search | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/www/search b/www/search index 35abcd21..989db93b 100644 --- a/www/search +++ b/www/search @@ -292,11 +292,16 @@ if ($pg == 'all') { // if we have a search term, find it if ($term || $browse) { + + // We want a count of all possible results, regardless of + // limit clause, so we can display that number + $count_all_possible_rows = true; // run the search list($rows, $rowcnt, $sortList, $errMsg, $summaryDesc, $badges, $specials, $specialsUsed, $orderBy, $games_were_filtered) = - doSearch($db, $term, $searchType, $sortby, $limit, $browse, $override_game_filter); + doSearch($db, $term, $searchType, $sortby, $limit, $browse, + $count_all_possible_rows, $override_game_filter); // adjust our page limits to include the whole result set if desired if ($pgAll) { From db7086acfa397d94a68a48789cd5d19c53384f86 Mon Sep 17 00:00:00 2001 From: alice-blue Date: Sun, 19 Jan 2025 01:37:30 +0000 Subject: [PATCH 49/72] editgame: Use $count_all_possible_rows and $override_game_filter parameters in call to doSearch --- www/editgame | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/www/editgame b/www/editgame index d4f1d60f..625b035b 100644 --- a/www/editgame +++ b/www/editgame @@ -65,8 +65,11 @@ if (isset($_REQUEST['search'])) if ($searchFor) { // run the search + $count_all_possible_rows = false; + $override_game_filter = 0; list($rows, $rowcnt, $sortList, $errMsg) = - doSearch($db, $searchFor, "game", "rel", "limit 0, 10", false); + doSearch($db, $searchFor, "game", "rel", "limit 0, 10", false, + $count_all_possible_rows, $override_game_filter); // if the top result matches the title exactly, consider it a // one-row match, even if we found other less relevant titles From 9bc40d4a5e7cb3b7235e1ba9ce49fcfe548e61fb Mon Sep 17 00:00:00 2001 From: alice-blue Date: Sun, 19 Jan 2025 03:31:15 +0000 Subject: [PATCH 50/72] length($rows) --> count($rows) (to get rid of fatal error) --- www/searchutil.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/searchutil.php b/www/searchutil.php index e1849a43..af094447 100644 --- a/www/searchutil.php +++ b/www/searchutil.php @@ -1215,7 +1215,7 @@ function doSearch($db, $term, $searchType, $sortby, $limit, $browse, $count_all_ $result = mysql_query("select count(*) from games", $db); [$rowcnt] = mysql_fetch_row($result); } else { - $rowcnt = length($rows); + $rowcnt = count($rows); } } else { From 166f2f6a5168782614152189bcf9d27976364ea7 Mon Sep 17 00:00:00 2001 From: alice-blue Date: Sun, 19 Jan 2025 23:27:31 +0000 Subject: [PATCH 51/72] $where --> !$term --- www/searchutil.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/searchutil.php b/www/searchutil.php index af094447..bb5ad371 100644 --- a/www/searchutil.php +++ b/www/searchutil.php @@ -1150,7 +1150,7 @@ function doSearch($db, $term, $searchType, $sortby, $limit, $browse, $count_all_ } $sql_calc_found_rows = "sql_calc_found_rows"; - if ($searchType === "game" && $where === "1") { + if ($searchType === "game" && !$term) { // `sql_calc_found_rows` forces the query to ignore the `limit` clause in order to count all possible results. // But when browsing for all games, we can do a fast `count(*)` query instead $sql_calc_found_rows = ""; @@ -1210,7 +1210,7 @@ function doSearch($db, $term, $searchType, $sortby, $limit, $browse, $count_all_ if ($sql_calc_found_rows) { $result = mysql_query("select found_rows()", $db); [$rowcnt] = mysql_fetch_row($result); - } else if ($searchType === "game" && $where === "1") { + } else if ($searchType === "game" && !$term) { if ($logging_level) error_log("select count(*) from games"); $result = mysql_query("select count(*) from games", $db); [$rowcnt] = mysql_fetch_row($result); From b571fc54936cfc79ec68d53f77815d93aea437ab Mon Sep 17 00:00:00 2001 From: alice-blue Date: Sun, 19 Jan 2025 23:55:48 +0000 Subject: [PATCH 52/72] Combine conditions & comments --- www/searchutil.php | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/www/searchutil.php b/www/searchutil.php index bb5ad371..c2df5710 100644 --- a/www/searchutil.php +++ b/www/searchutil.php @@ -1150,19 +1150,16 @@ function doSearch($db, $term, $searchType, $sortby, $limit, $browse, $count_all_ } $sql_calc_found_rows = "sql_calc_found_rows"; - if ($searchType === "game" && !$term) { - // `sql_calc_found_rows` forces the query to ignore the `limit` clause in order to count all possible results. - // But when browsing for all games, we can do a fast `count(*)` query instead - $sql_calc_found_rows = ""; - } - if (!$count_all_possible_rows) { - // `sql_calc_found_rows` forces the query to ignore the `limit` clause - // in order to count all possible results, which means a slower full - // table scan. If the total number of rows is not needed, we can skip - // `sql_calc_found_rows` to speed up the query. + if (($searchType === "game" && !$term) || !$count_all_possible_rows) { + // `sql_calc_found_rows` forces the query to ignore the `limit` clause in order to + // count all possible results, which means a full table scan, which can be slow. + // But if we're browsing all games, we can skip `sql_calc_found_rows` and do a fast + // `count(*)` query instead. If we're searching but we don't need the number of + // possible rows, we can skip the counting altogether. + $sql_calc_found_rows = ""; } - + // build the SELECT statement $sql = "select $sql_calc_found_rows From 319a01ee3f5c7160f61a779af746f6fb1e033d7b Mon Sep 17 00:00:00 2001 From: alice-blue Date: Wed, 22 Jan 2025 17:57:53 -0500 Subject: [PATCH 53/72] searchutil.php: remove redundant lines --- www/searchutil.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/www/searchutil.php b/www/searchutil.php index a8aeb9c1..81d9175a 100644 --- a/www/searchutil.php +++ b/www/searchutil.php @@ -1120,14 +1120,6 @@ function doSearch($db, $term, $searchType, $sortby, $limit, $browse, $count_all_ $sql_calc_found_rows = ""; } - if (!$count_all_possible_rows) { - // `sql_calc_found_rows` forces the query to ignore the `limit` clause - // in order to count all possible results, which means a slower full - // table scan. If the total number of rows is not needed, we can skip - // `sql_calc_found_rows` to speed up the query. - $sql_calc_found_rows = ""; - } - // build the SELECT statement $sql = "select $sql_calc_found_rows From 9ce96d235e9bba8de3b72690fdf7e086faee428b Mon Sep 17 00:00:00 2001 From: alice-blue Date: Wed, 22 Jan 2025 19:51:25 -0500 Subject: [PATCH 54/72] editprofile: update description of game filtering to say it applies to the home page, too --- www/editprofile | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/www/editprofile b/www/editprofile index 37834d5a..d4867c15 100644 --- a/www/editprofile +++ b/www/editprofile @@ -934,22 +934,22 @@ captchaSupportScripts($captchaKey);

5. Game Filtering

-

To limit what kinds of games appear on the - search page and on the - browse page, you can - create a filter using IFDB's - search prefixes. - For instance, to hide games in a certain language, games in a +

To see certain kinds of games less often, + you can create a filter using IFDB's + search prefixes. For + instance, to hide games in a certain language, games in a certain genre, and games with a certain tag, you can type
-language:example -genre:example -tag:example
- (replacing "example" with the name of the language, genre, or tag). - While you are logged in, your saved filter will automatically be - be added to the end of your search terms when you search for games. - The filter will also be applied when you browse games on the browse - page. At the bottom of the page of results, there will be an option - to search again without the filter. (Note: Game information on IFDB - is incomplete and can have mistakes. A filter is not a reliable way - to make sure that games are kid-friendly.) + (replacing "example" with the name of the language, genre, or + tag).

+

While you are logged in, your saved filter + will be applied on certain pages: the home page, the browse page, + and the search page (where the filter will automatically be added + to your search terms). The search and browse pages will have + an option to temporarily turn off the filter.

+

Game information on IFDB is incomplete + and can have mistakes, so a filter is not a reliable + way to make sure that games are kid-friendly.

From 1003e84c9ef85684d4aa240d2aceb188a7afaec0 Mon Sep 17 00:00:00 2001 From: alice-blue Date: Thu, 23 Jan 2025 00:05:29 -0500 Subject: [PATCH 55/72] newitems.php: leave out the last review date limit if we need 20+ reviews If we're finding new reviews and we have a custom game filter, limit games to those reviewed in the last year only if the number of reviews we need is home-page-sized. On the allnew page, we want to be able to show more and older reviews. --- www/newitems.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/www/newitems.php b/www/newitems.php index 581c8bec..0c7b76eb 100644 --- a/www/newitems.php +++ b/www/newitems.php @@ -180,14 +180,19 @@ function getNewItems($db, $limit, $itemTypes = NEWITEMS_ALLITEMS, $options = [], if (!$result) throw new Exception("Error: " . mysqli_error($db)); [$game_filter] = mysql_fetch_row($result); if ($game_filter != "") { - // Find games that have been reviewed in the past 365 days. + // If we'll need only a small number of reviews (to show + // on the home page, for example, vs. the allnew page), + // find games that have been reviewed in the past 365 days. // (This condition is to avoid a slow full table scan.) // Sort the most recently reviewed games to the top, // and fetch the correct number of games (at most, we'll // need the same number of games as the number of reviews // we're ultimately looking for). The custom game filter // gets applied in doSearch. - $term = "lastreview:365d-"; + $term = ""; + if ($reviews_limit < 20) { + $term = "lastreview:365d-"; + } $searchType = "game"; $sortby = "recently_reviewed"; $games_limit_clause = "limit $reviews_limit"; From 45106395429b66fe66dfd94725ff06980f8e37bd Mon Sep 17 00:00:00 2001 From: alice-blue Date: Thu, 23 Jan 2025 18:54:59 +0000 Subject: [PATCH 56/72] use clearer variable to accomplish the same effect --- www/newitems.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/newitems.php b/www/newitems.php index 0c7b76eb..34689a66 100644 --- a/www/newitems.php +++ b/www/newitems.php @@ -247,7 +247,7 @@ function getNewItems($db, $limit, $itemTypes = NEWITEMS_ALLITEMS, $options = [], order by d desc, id desc $reviews_limit_clause", $db); $revcnt = mysql_num_rows($result); - if ($game_filter != "") { + if ($game_filter_was_applied) { for ($i = 0 ; $i < $revcnt ; $i++) { $row = mysql_fetch_array($result, MYSQL_ASSOC); // Only add the review to $items if it matches a gameid From 7f4e701c551e972d53dfdbf2a5810c68b20cedf7 Mon Sep 17 00:00:00 2001 From: alice-blue Date: Thu, 23 Jan 2025 18:55:24 +0000 Subject: [PATCH 57/72] Mention that this applies to the "New Reviews on IFDB" page --- www/editprofile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/www/editprofile b/www/editprofile index d4867c15..a0abe12b 100644 --- a/www/editprofile +++ b/www/editprofile @@ -939,14 +939,14 @@ captchaSupportScripts($captchaKey); search prefixes. For instance, to hide games in a certain language, games in a certain genre, and games with a certain tag, you can type -
-language:example -genre:example -tag:example
+

-language:example -genre:example -tag:example

(replacing "example" with the name of the language, genre, or - tag).

-

While you are logged in, your saved filter - will be applied on certain pages: the home page, the browse page, - and the search page (where the filter will automatically be added - to your search terms). The search and browse pages will have - an option to temporarily turn off the filter.

+ tag). While you are logged in, your saved filter + will be used to hide games, but only on certain pages: the home page, + the "New Reviews on IFDB" page, and the search/browse page + (where the filter will automatically be added to the end of your + search terms). The "New Reviews on IFDB" page and the search/browse + page will show an option to temporarily turn off the filter.

Game information on IFDB is incomplete and can have mistakes, so a filter is not a reliable way to make sure that games are kid-friendly. From 37a1f481d17fe91a73a1e7336ae4bf78fda94f1b Mon Sep 17 00:00:00 2001 From: Dan Fabulich Date: Sun, 2 Feb 2025 22:57:59 -0800 Subject: [PATCH 58/72] Always search games to find new reviews Fixes #1275 --- www/newitems.php | 77 ++++++++++-------------------------------------- 1 file changed, 16 insertions(+), 61 deletions(-) diff --git a/www/newitems.php b/www/newitems.php index 34689a66..b80d3d80 100644 --- a/www/newitems.php +++ b/www/newitems.php @@ -171,47 +171,17 @@ function getNewItems($db, $limit, $itemTypes = NEWITEMS_ALLITEMS, $options = [], if ($itemTypes & NEWITEMS_REVIEWS) { $reviews_limit = $options['reviews_limit'] ?? $limit; - $reviews_limit_clause = ""; - // deal with custom game filters - $game_filter = ""; - $gameids_after_filtering = []; - if ($curuser && $override_game_filter != 1) { - $result = mysqli_execute_query($db, "select game_filter from users where id = ?", [$curuser]); - if (!$result) throw new Exception("Error: " . mysqli_error($db)); - [$game_filter] = mysql_fetch_row($result); - if ($game_filter != "") { - // If we'll need only a small number of reviews (to show - // on the home page, for example, vs. the allnew page), - // find games that have been reviewed in the past 365 days. - // (This condition is to avoid a slow full table scan.) - // Sort the most recently reviewed games to the top, - // and fetch the correct number of games (at most, we'll - // need the same number of games as the number of reviews - // we're ultimately looking for). The custom game filter - // gets applied in doSearch. - $term = ""; - if ($reviews_limit < 20) { - $term = "lastreview:365d-"; - } - $searchType = "game"; - $sortby = "recently_reviewed"; - $games_limit_clause = "limit $reviews_limit"; - $browse = 0; - list($game_rows_after_filtering, $rowcnt, $sortList, $errMsg, $summaryDesc, $badges, $specials, $specialsUsed, $orderBy) = - doSearch($db, $term, $searchType, $sortby, $games_limit_clause, $browse); - // Note the gameids of games that we might want to display reviews for - foreach ($game_rows_after_filtering as $game_row) { - $gameids_after_filtering[] = $game_row['id']; - } - $game_filter_was_applied = 1; - } - } - if (!$game_filter_was_applied) { - // We're not applying a game filter, so we don't need extra reviews. - // (We only need extras if some of them might get filtered out.) - // We can limit results to the exact number we want to display. - $reviews_limit_clause = "limit $reviews_limit"; + $term = ""; + $searchType = "game"; + $sortby = "recently_reviewed"; + $games_limit_clause = "limit $reviews_limit"; + $browse = 0; + [$game_rows_after_filtering] = doSearch($db, $term, $searchType, $sortby, $games_limit_clause, $browse); + // Note the gameids of games that we might want to display reviews for + foreach ($game_rows_after_filtering as $game_row) { + $gameids_after_filtering[] = "'" . $game_row['id'] . "'"; } + $reviews_limit_clause = "limit $reviews_limit"; // prepare to query reviews if ($days) $dayWhere = "greatest(reviews.createdate, ifnull(reviews.embargodate, '0000-00-00')) > date_sub(now(), interval $days day)"; // query the recent reviews (minus mutes) @@ -232,12 +202,11 @@ function getNewItems($db, $limit, $itemTypes = NEWITEMS_ALLITEMS, $options = [], games.flags from reviews - join games - join users + join games on games.id = reviews.gameid + join users on users.id = reviews.userid left outer join specialreviewers on specialreviewers.id = special where - games.id = reviews.gameid - and users.id = reviews.userid + gameid in (".join(",", $gameids_after_filtering).") and reviews.review is not null and ifnull(now() >= reviews.embargodate, 1) and ifnull(specialreviewers.code, '') <> 'external' @@ -247,23 +216,9 @@ function getNewItems($db, $limit, $itemTypes = NEWITEMS_ALLITEMS, $options = [], order by d desc, id desc $reviews_limit_clause", $db); $revcnt = mysql_num_rows($result); - if ($game_filter_was_applied) { - for ($i = 0 ; $i < $revcnt ; $i++) { - $row = mysql_fetch_array($result, MYSQL_ASSOC); - // Only add the review to $items if it matches a gameid - // in $gameids_after_filtering - if (in_array($row['gameid'], $gameids_after_filtering)) { - $items[] = array('R', $row['d'], $row); - if ( count($items) == $reviews_limit ) { - break; - } - } - } - } else { - for ($i = 0 ; $i < $revcnt ; $i++) { - $row = mysql_fetch_array($result, MYSQL_ASSOC); - $items[] = array('R', $row['d'], $row); - } + for ($i = 0 ; $i < $revcnt ; $i++) { + $row = mysql_fetch_array($result, MYSQL_ASSOC); + $items[] = array('R', $row['d'], $row); } } From 41094c4791a28aade41b8d851436442e94b53f63 Mon Sep 17 00:00:00 2001 From: alice-blue Date: Mon, 3 Feb 2025 19:33:01 -0500 Subject: [PATCH 59/72] newitems.php: get $game_filter_was_applied from doSearch $game_filter_was_applied (or the equivalent) is actually returned by doSearch anyway--we're just not tracking it. This change will bring back the "games have been filtered" announcement on the allnew page. --- www/newitems.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/www/newitems.php b/www/newitems.php index b80d3d80..b7f55f02 100644 --- a/www/newitems.php +++ b/www/newitems.php @@ -176,7 +176,9 @@ function getNewItems($db, $limit, $itemTypes = NEWITEMS_ALLITEMS, $options = [], $sortby = "recently_reviewed"; $games_limit_clause = "limit $reviews_limit"; $browse = 0; - [$game_rows_after_filtering] = doSearch($db, $term, $searchType, $sortby, $games_limit_clause, $browse); + list($game_rows_after_filtering, $rowcnt, $sortList, $errMsg, $summaryDesc, + $badges, $specials, $specialsUsed, $orderBy, $game_filter_was_applied) + = doSearch($db, $term, $searchType, $sortby, $games_limit_clause, $browse); // Note the gameids of games that we might want to display reviews for foreach ($game_rows_after_filtering as $game_row) { $gameids_after_filtering[] = "'" . $game_row['id'] . "'"; From e9974e771c217f32b464a2108291a76594af244e Mon Sep 17 00:00:00 2001 From: alice-blue Date: Mon, 3 Feb 2025 19:52:36 -0500 Subject: [PATCH 60/72] Update newitems.php Add comment explaining "game_rows_after_filtering" --- www/newitems.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/www/newitems.php b/www/newitems.php index b7f55f02..9403533b 100644 --- a/www/newitems.php +++ b/www/newitems.php @@ -176,6 +176,8 @@ function getNewItems($db, $limit, $itemTypes = NEWITEMS_ALLITEMS, $options = [], $sortby = "recently_reviewed"; $games_limit_clause = "limit $reviews_limit"; $browse = 0; + // If the user has a custom game filter and has not overridden it, that + // filter will automatically be applied within the doSearch function. list($game_rows_after_filtering, $rowcnt, $sortList, $errMsg, $summaryDesc, $badges, $specials, $specialsUsed, $orderBy, $game_filter_was_applied) = doSearch($db, $term, $searchType, $sortby, $games_limit_clause, $browse); From daef8452bb6b578dcb221a98144a49cbe0f9583a Mon Sep 17 00:00:00 2001 From: Dan Fabulich Date: Mon, 18 Aug 2025 10:12:48 -0700 Subject: [PATCH 61/72] Add `lastReviewDate` to `gameRatingsSandbox01` --- sql/unscrub-ifarchive.sql | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/sql/unscrub-ifarchive.sql b/sql/unscrub-ifarchive.sql index 7aaf9abb..14f01831 100644 --- a/sql/unscrub-ifarchive.sql +++ b/sql/unscrub-ifarchive.sql @@ -488,6 +488,7 @@ select `averaged`.`gameid` AS `gameid`, `averaged`.`numRatingsInAvg` AS `numRatingsInAvg`, `averaged`.`numRatingsTotal` AS `numRatingsTotal`, `averaged`.`numMemberReviews` AS `numMemberReviews`, + `averaged`.`lastReviewDate` AS `lastReviewDate`, `averaged`.`avgRating` AS `avgRating`, pow( ( @@ -535,6 +536,7 @@ from ( `rating_counts`.`numRatingsInAvg` AS `numRatingsInAvg`, `rating_counts`.`numRatingsTotal` AS `numRatingsTotal`, `rating_counts`.`numMemberReviews` AS `numMemberReviews`, + `rating_counts`.`lastReviewDate` AS `lastReviewDate`, ( `rating_counts`.`rated1` + `rating_counts`.`rated2` * 2 @@ -597,13 +599,20 @@ from ( when `grouped`.`hasReview` then `grouped`.`count` else 0 end - ) AS `numMemberReviews` + ) AS `numMemberReviews`, + max( + case + when `grouped`.`hasReview` then `grouped`.`lastRatingOrReviewDate` + else null + end + ) AS `lastReviewDate` from ( select count(`ifdb`.`reviews`.`id`) AS `count`, `ifdb`.`reviews`.`rating` AS `rating`, `ifdb`.`games`.`id` AS `gameid`, ifnull(`ifdb`.`reviews`.`RFlags`, 0) & 2 AS `omitted`, - `ifdb`.`reviews`.`review` is not null AS `hasReview` + `ifdb`.`reviews`.`review` is not null AS `hasReview`, + max(ifnull(embargodate, createdate)) AS `lastRatingOrReviewDate` from ( `ifdb`.`games` left outer join `ifdb`.`reviews` on ( From 8d207a258b7ade82e14493244644222a177573c4 Mon Sep 17 00:00:00 2001 From: Dan Fabulich Date: Mon, 18 Aug 2025 10:24:29 -0700 Subject: [PATCH 62/72] Patch full schema --- sql/patch-full-schema.sql | 447 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 447 insertions(+) diff --git a/sql/patch-full-schema.sql b/sql/patch-full-schema.sql index 40fae266..0bd03df1 100644 --- a/sql/patch-full-schema.sql +++ b/sql/patch-full-schema.sql @@ -1,2 +1,449 @@ USE ifdb; +ALTER TABLE `users` ADD COLUMN `game_filter` VARCHAR(150) DEFAULT ''; + +-- +-- Final view structure for view `gameRatingsSandbox0` +-- + +/*!50001 DROP TABLE IF EXISTS `gameRatingsSandbox0`*/; +/*!50001 DROP VIEW IF EXISTS `gameRatingsSandbox0`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50001 VIEW `gameRatingsSandbox0` AS +select `averaged`.`gameid` AS `gameid`, + `averaged`.`rated1` AS `rated1`, + `averaged`.`rated2` AS `rated2`, + `averaged`.`rated3` AS `rated3`, + `averaged`.`rated4` AS `rated4`, + `averaged`.`rated5` AS `rated5`, + `averaged`.`numRatingsInAvg` AS `numRatingsInAvg`, + `averaged`.`numRatingsTotal` AS `numRatingsTotal`, + `averaged`.`numMemberReviews` AS `numMemberReviews`, + `averaged`.`lastReviewDate` AS `lastReviewDate`, + `averaged`.`avgRating` AS `avgRating`, + pow( + ( + pow(1 - `averaged`.`avgRating`, 2) * `averaged`.`rated1` + + pow(2 - `averaged`.`avgRating`, 2) * `averaged`.`rated2` + + pow(3 - `averaged`.`avgRating`, 2) * `averaged`.`rated3` + + pow(4 - `averaged`.`avgRating`, 2) * `averaged`.`rated4` + + pow(5 - `averaged`.`avgRating`, 2) * `averaged`.`rated5` + ) / `averaged`.`numRatingsInAvg`, + 0.5 + ) AS `stdDevRating`, +( + 5 * (`averaged`.`rated5` + 1) + + 4 * (`averaged`.`rated4` + 1) + + 3 * (`averaged`.`rated3` + 1) + + 2 * (`averaged`.`rated2` + 1) + + 1 * (`averaged`.`rated1` + 1) + ) / (5 + `averaged`.`numRatingsInAvg`) - 1.65 * sqrt( + ( + ( + 25 * (`averaged`.`rated5` + 1) + + 16 * (`averaged`.`rated4` + 1) + + 9 * (`averaged`.`rated3` + 1) + + 4 * (`averaged`.`rated2` + 1) + + 1 * (`averaged`.`rated1` + 1) + ) / (5 + `averaged`.`numRatingsInAvg`) - pow( + ( + 5 * (`averaged`.`rated5` + 1) + + 4 * (`averaged`.`rated4` + 1) + + 3 * (`averaged`.`rated3` + 1) + + 2 * (`averaged`.`rated2` + 1) + + 1 * (`averaged`.`rated1` + 1) + ) / (5 + `averaged`.`numRatingsInAvg`), + 2 + ) + ) / (6 + `averaged`.`numRatingsInAvg`) + ) AS `starsort` +from ( + select `rating_counts`.`gameid` AS `gameid`, + `rating_counts`.`rated1` AS `rated1`, + `rating_counts`.`rated2` AS `rated2`, + `rating_counts`.`rated3` AS `rated3`, + `rating_counts`.`rated4` AS `rated4`, + `rating_counts`.`rated5` AS `rated5`, + `rating_counts`.`numRatingsInAvg` AS `numRatingsInAvg`, + `rating_counts`.`numRatingsTotal` AS `numRatingsTotal`, + `rating_counts`.`numMemberReviews` AS `numMemberReviews`, + `rating_counts`.`lastReviewDate` AS `lastReviewDate`, +( + `rating_counts`.`rated1` + + `rating_counts`.`rated2` * 2 + + `rating_counts`.`rated3` * 3 + + `rating_counts`.`rated4` * 4 + + `rating_counts`.`rated5` * 5 + ) / `rating_counts`.`numRatingsInAvg` AS `avgRating` + from ( + select `grouped`.`gameid` AS `gameid`, + sum( + case + when `grouped`.`rating` = 1 + and `grouped`.`omitted` = 0 then `grouped`.`count` + else 0 + end + ) AS `rated1`, + sum( + case + when `grouped`.`rating` = 2 + and `grouped`.`omitted` = 0 then `grouped`.`count` + else 0 + end + ) AS `rated2`, + sum( + case + when `grouped`.`rating` = 3 + and `grouped`.`omitted` = 0 then `grouped`.`count` + else 0 + end + ) AS `rated3`, + sum( + case + when `grouped`.`rating` = 4 + and `grouped`.`omitted` = 0 then `grouped`.`count` + else 0 + end + ) AS `rated4`, + sum( + case + when `grouped`.`rating` = 5 + and `grouped`.`omitted` = 0 then `grouped`.`count` + else 0 + end + ) AS `rated5`, + sum( + case + when `grouped`.`rating` in (1, 2, 3, 4, 5) + and `grouped`.`omitted` = 0 then `grouped`.`count` + else 0 + end + ) AS `numRatingsInAvg`, + sum( + case + when `grouped`.`rating` in (1, 2, 3, 4, 5) then `grouped`.`count` + else 0 + end + ) AS `numRatingsTotal`, + sum( + case + when `grouped`.`hasReview` then `grouped`.`count` + else 0 + end + ) AS `numMemberReviews`, + max( + case + when `grouped`.`hasReview` then `grouped`.`lastRatingOrReviewDate` + else null + end + ) AS `lastReviewDate` + from ( + select count(`ifdb`.`reviews`.`id`) AS `count`, + `ifdb`.`reviews`.`rating` AS `rating`, + `ifdb`.`games`.`id` AS `gameid`, + ifnull(`ifdb`.`reviews`.`RFlags`, 0) & 2 AS `omitted`, + `ifdb`.`reviews`.`review` is not null AS `hasReview`, + max(ifnull(embargodate, createdate)) AS `lastRatingOrReviewDate` + from ( + `ifdb`.`games` + left outer join `ifdb`.`reviews` on ( + `ifdb`.`games`.`id` = `ifdb`.`reviews`.`gameid` + and ifnull( + current_timestamp() > `ifdb`.`reviews`.`embargodate`, + 1 + ) + and `ifdb`.`reviews`.`special` is null + and `ifdb`.`reviews`.`userid` not in (select `ifdb`.`users`.`id` from `ifdb`.`users` where `ifdb`.`users`.`Sandbox` = 1) + ) + ) + group by `ifdb`.`reviews`.`rating`, + `ifdb`.`games`.`id`, + ifnull(`ifdb`.`reviews`.`RFlags`, 0) & 2, + ifnull( + `ifdb`.`reviews`.`special`, + `ifdb`.`reviews`.`review` + ) is not null + ) `grouped` + group by `grouped`.`gameid` + ) `rating_counts` + ) `averaged` +*/; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + +-- +-- Final view structure for view `gameRatingsSandbox01` +-- + +/*!50001 DROP TABLE IF EXISTS `gameRatingsSandbox01`*/; +/*!50001 DROP VIEW IF EXISTS `gameRatingsSandbox01`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50001 VIEW `gameRatingsSandbox01` AS +select `averaged`.`gameid` AS `gameid`, + `averaged`.`rated1` AS `rated1`, + `averaged`.`rated2` AS `rated2`, + `averaged`.`rated3` AS `rated3`, + `averaged`.`rated4` AS `rated4`, + `averaged`.`rated5` AS `rated5`, + `averaged`.`numRatingsInAvg` AS `numRatingsInAvg`, + `averaged`.`numRatingsTotal` AS `numRatingsTotal`, + `averaged`.`numMemberReviews` AS `numMemberReviews`, + `averaged`.`lastReviewDate` AS `lastReviewDate`, + `averaged`.`avgRating` AS `avgRating`, + pow( + ( + pow(1 - `averaged`.`avgRating`, 2) * `averaged`.`rated1` + + pow(2 - `averaged`.`avgRating`, 2) * `averaged`.`rated2` + + pow(3 - `averaged`.`avgRating`, 2) * `averaged`.`rated3` + + pow(4 - `averaged`.`avgRating`, 2) * `averaged`.`rated4` + + pow(5 - `averaged`.`avgRating`, 2) * `averaged`.`rated5` + ) / `averaged`.`numRatingsInAvg`, + 0.5 + ) AS `stdDevRating`, +( + 5 * (`averaged`.`rated5` + 1) + + 4 * (`averaged`.`rated4` + 1) + + 3 * (`averaged`.`rated3` + 1) + + 2 * (`averaged`.`rated2` + 1) + + 1 * (`averaged`.`rated1` + 1) + ) / (5 + `averaged`.`numRatingsInAvg`) - 1.65 * sqrt( + ( + ( + 25 * (`averaged`.`rated5` + 1) + + 16 * (`averaged`.`rated4` + 1) + + 9 * (`averaged`.`rated3` + 1) + + 4 * (`averaged`.`rated2` + 1) + + 1 * (`averaged`.`rated1` + 1) + ) / (5 + `averaged`.`numRatingsInAvg`) - pow( + ( + 5 * (`averaged`.`rated5` + 1) + + 4 * (`averaged`.`rated4` + 1) + + 3 * (`averaged`.`rated3` + 1) + + 2 * (`averaged`.`rated2` + 1) + + 1 * (`averaged`.`rated1` + 1) + ) / (5 + `averaged`.`numRatingsInAvg`), + 2 + ) + ) / (6 + `averaged`.`numRatingsInAvg`) + ) AS `starsort` +from ( + select `rating_counts`.`gameid` AS `gameid`, + `rating_counts`.`rated1` AS `rated1`, + `rating_counts`.`rated2` AS `rated2`, + `rating_counts`.`rated3` AS `rated3`, + `rating_counts`.`rated4` AS `rated4`, + `rating_counts`.`rated5` AS `rated5`, + `rating_counts`.`numRatingsInAvg` AS `numRatingsInAvg`, + `rating_counts`.`numRatingsTotal` AS `numRatingsTotal`, + `rating_counts`.`numMemberReviews` AS `numMemberReviews`, + `rating_counts`.`lastReviewDate` AS `lastReviewDate`, +( + `rating_counts`.`rated1` + + `rating_counts`.`rated2` * 2 + + `rating_counts`.`rated3` * 3 + + `rating_counts`.`rated4` * 4 + + `rating_counts`.`rated5` * 5 + ) / `rating_counts`.`numRatingsInAvg` AS `avgRating` + from ( + select `grouped`.`gameid` AS `gameid`, + sum( + case + when `grouped`.`rating` = 1 + and `grouped`.`omitted` = 0 then `grouped`.`count` + else 0 + end + ) AS `rated1`, + sum( + case + when `grouped`.`rating` = 2 + and `grouped`.`omitted` = 0 then `grouped`.`count` + else 0 + end + ) AS `rated2`, + sum( + case + when `grouped`.`rating` = 3 + and `grouped`.`omitted` = 0 then `grouped`.`count` + else 0 + end + ) AS `rated3`, + sum( + case + when `grouped`.`rating` = 4 + and `grouped`.`omitted` = 0 then `grouped`.`count` + else 0 + end + ) AS `rated4`, + sum( + case + when `grouped`.`rating` = 5 + and `grouped`.`omitted` = 0 then `grouped`.`count` + else 0 + end + ) AS `rated5`, + sum( + case + when `grouped`.`rating` in (1, 2, 3, 4, 5) + and `grouped`.`omitted` = 0 then `grouped`.`count` + else 0 + end + ) AS `numRatingsInAvg`, + sum( + case + when `grouped`.`rating` in (1, 2, 3, 4, 5) then `grouped`.`count` + else 0 + end + ) AS `numRatingsTotal`, + sum( + case + when `grouped`.`hasReview` then `grouped`.`count` + else 0 + end + ) AS `numMemberReviews`, + max( + case + when `grouped`.`hasReview` then `grouped`.`lastRatingOrReviewDate` + else null + end + ) AS `lastReviewDate` + from ( + select count(`ifdb`.`reviews`.`id`) AS `count`, + `ifdb`.`reviews`.`rating` AS `rating`, + `ifdb`.`games`.`id` AS `gameid`, + ifnull(`ifdb`.`reviews`.`RFlags`, 0) & 2 AS `omitted`, + `ifdb`.`reviews`.`review` is not null AS `hasReview`, + max(ifnull(embargodate, createdate)) AS `lastRatingOrReviewDate` + from ( + `ifdb`.`games` + left outer join `ifdb`.`reviews` on ( + `ifdb`.`games`.`id` = `ifdb`.`reviews`.`gameid` + and ifnull( + current_timestamp() > `ifdb`.`reviews`.`embargodate`, + 1 + ) + and `ifdb`.`reviews`.`special` is null + ) + ) + group by `ifdb`.`reviews`.`rating`, + `ifdb`.`games`.`id`, + ifnull(`ifdb`.`reviews`.`RFlags`, 0) & 2, + ifnull( + `ifdb`.`reviews`.`special`, + `ifdb`.`reviews`.`review` + ) is not null + ) `grouped` + group by `grouped`.`gameid` + ) `rating_counts` + ) `averaged` +*/; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + +drop table if exists gameRatingsSandbox0_mv; +create table gameRatingsSandbox0_mv ( + `gameid` varchar(32) NOT NULL DEFAULT '', + `rated1` int unsigned, + `rated2` int unsigned, + `rated3` int unsigned, + `rated4` int unsigned, + `rated5` int unsigned, + `numRatingsInAvg` int unsigned, + `numRatingsTotal` int unsigned, + `numMemberReviews` int unsigned, + `lastReviewDate` datetime NOT NULL, + `avgRating` double, + `stdDevRating` double, + `starsort` double, + `updated` date, + PRIMARY KEY (`gameid`), + KEY `numRatingsInAvg` (`numRatingsInAvg`), + KEY `numRatingsTotal` (`numRatingsTotal`), + KEY `numMemberReviews` (`numMemberReviews`), + KEY `avgRating` (`avgRating`), + KEY `stdDevRating` (`stdDevRating`), + KEY `starsort` (`starsort`), + KEY `lastReviewDate` (`lastReviewDate`) +) ENGINE = MyISAM DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci; + +lock tables gameRatingsSandbox0_mv write, gameRatingsSandbox0 read; +truncate table gameRatingsSandbox0_mv; +insert into gameRatingsSandbox0_mv select *, now() from gameRatingsSandbox0; +unlock tables; + +DROP PROCEDURE IF EXISTS refresh_gameRatingsSandbox0_mv; +DELIMITER $$ + +CREATE PROCEDURE refresh_gameRatingsSandbox0_mv ( + IN new_gameid varchar(32) +) +BEGIN +select * +from gameRatingsSandbox0 +where gameid = new_gameid into @gameid, + @rated1, + @rated2, + @rated3, + @rated4, + @rated5, + @numRatingsInAvg, + @numRatingsTotal, + @numMemberReviews, + @avgRating, + @stdDevRating, + @starsort, + @lastReviewDate; +if @gameid is null then + delete from gameRatingsSandbox0_mv where gameid = new_gameid; +else +insert into gameRatingsSandbox0_mv +values ( + @gameid, + @rated1, + @rated2, + @rated3, + @rated4, + @rated5, + @numRatingsInAvg, + @numRatingsTotal, + @numMemberReviews, + @avgRating, + @stdDevRating, + @starsort, + @lastReviewDate, + now() + ) on duplicate key +update gameid = @gameid, + rated1 = @rated1, + rated2 = @rated2, + rated3 = @rated3, + rated4 = @rated4, + rated5 = @rated5, + numRatingsInAvg = @numRatingsInAvg, + numRatingsTotal = @numRatingsTotal, + numMemberReviews = @numMemberReviews, + avgRating = @avgRating, + stdDevRating = @stdDevRating, + starsort = @starsort, + lastReviewDate = @lastReviewDate, + updated = now(); +END IF; +END; +$$ + +DELIMITER ; From bf9632234ed7c0238240ed90a936e5a8a162441e Mon Sep 17 00:00:00 2001 From: Dan Fabulich Date: Thu, 28 Aug 2025 11:21:36 -0700 Subject: [PATCH 63/72] Fix `refresh_gameRatingsSandbox0_mv` stored procedure I got the column orders mixed up, so when creating/updating/deleting new reviews, `gameRatingsSandbox0_mv` wasn't getting updated properly. --- sql/patch-full-schema.sql | 8 ++++---- sql/unscrub-ifarchive.sql | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/sql/patch-full-schema.sql b/sql/patch-full-schema.sql index 0bd03df1..ebf2e98a 100644 --- a/sql/patch-full-schema.sql +++ b/sql/patch-full-schema.sql @@ -404,10 +404,10 @@ where gameid = new_gameid into @gameid, @numRatingsInAvg, @numRatingsTotal, @numMemberReviews, + @lastReviewDate, @avgRating, @stdDevRating, - @starsort, - @lastReviewDate; + @starsort; if @gameid is null then delete from gameRatingsSandbox0_mv where gameid = new_gameid; else @@ -422,10 +422,10 @@ values ( @numRatingsInAvg, @numRatingsTotal, @numMemberReviews, + @lastReviewDate, @avgRating, @stdDevRating, @starsort, - @lastReviewDate, now() ) on duplicate key update gameid = @gameid, @@ -437,10 +437,10 @@ update gameid = @gameid, numRatingsInAvg = @numRatingsInAvg, numRatingsTotal = @numRatingsTotal, numMemberReviews = @numMemberReviews, + lastReviewDate = @lastReviewDate, avgRating = @avgRating, stdDevRating = @stdDevRating, starsort = @starsort, - lastReviewDate = @lastReviewDate, updated = now(); END IF; END; diff --git a/sql/unscrub-ifarchive.sql b/sql/unscrub-ifarchive.sql index 14f01831..81b9244b 100644 --- a/sql/unscrub-ifarchive.sql +++ b/sql/unscrub-ifarchive.sql @@ -930,10 +930,10 @@ where gameid = new_gameid into @gameid, @numRatingsInAvg, @numRatingsTotal, @numMemberReviews, + @lastReviewDate, @avgRating, @stdDevRating, - @starsort, - @lastReviewDate; + @starsort; if @gameid is null then delete from gameRatingsSandbox0_mv where gameid = new_gameid; else @@ -948,10 +948,10 @@ values ( @numRatingsInAvg, @numRatingsTotal, @numMemberReviews, + @lastReviewDate, @avgRating, @stdDevRating, @starsort, - @lastReviewDate, now() ) on duplicate key update gameid = @gameid, @@ -963,10 +963,10 @@ update gameid = @gameid, numRatingsInAvg = @numRatingsInAvg, numRatingsTotal = @numRatingsTotal, numMemberReviews = @numMemberReviews, + lastReviewDate = @lastReviewDate, avgRating = @avgRating, stdDevRating = @stdDevRating, starsort = @starsort, - lastReviewDate = @lastReviewDate, updated = now(); END IF; END; From f5250d3e12fc0f389a73ec098dfa1ac932bde7b9 Mon Sep 17 00:00:00 2001 From: alice-blue Date: Sat, 30 Aug 2025 19:22:36 -0400 Subject: [PATCH 64/72] Remove "lastreview" search prefix from searchutil.php The "lastreview" search prefix isn't being used. We are instead using the "recently_reviewed" sort order to get recent reviews for the home page. --- www/searchutil.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/www/searchutil.php b/www/searchutil.php index 6fef2971..1cd663f1 100644 --- a/www/searchutil.php +++ b/www/searchutil.php @@ -267,11 +267,7 @@ function doSearch($db, $term, $searchType, $sortby, $limit, $browse, $count_all_ "rated:" => array("rated", 99), "license:" => array("license", 0), "competitionid:" => array("competitionid", 99), - "format:" => array("/gameformat/", 99), - // "lastreview:" is not documented for users. It's used in newitems.php - // as part of finding new reviews to display when a custom game filter - // is applied. - "lastreview:" => array("lastReviewDate", 4)); + "format:" => array("/gameformat/", 99)); // SELECT parameters for game queries From 9e4b42bfa8b7ca077eba1493fd915fd48392ab99 Mon Sep 17 00:00:00 2001 From: alice-blue Date: Sun, 31 Aug 2025 17:06:10 -0400 Subject: [PATCH 65/72] Add view and materialized view to track recent game news This mostly follows the pattern of the gametimes view, materialized view, triggers, and update procedures, but it's possible some stuff doesn't apply --- sql/incoming-schema-changes.sql | 98 +++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/sql/incoming-schema-changes.sql b/sql/incoming-schema-changes.sql index 65255f90..ed798d3d 100644 --- a/sql/incoming-schema-changes.sql +++ b/sql/incoming-schema-changes.sql @@ -7,3 +7,101 @@ USE ifdb; -- Add column for game search filter to the users table ALTER TABLE `users` ADD COLUMN `game_filter` VARCHAR(150) DEFAULT ''; + + + + + +-- Add a view to track the news items for each game. +-- "G" in the news table means the news is about a game. +-- Do not include versions of news items that have been +-- superseded by later edits. + +CREATE VIEW `recentgamenews` AS + SELECT + newsid AS news_id, + sourceid AS game_id, + created AS news_create_date + FROM news + WHERE source = "G" + AND newsid NOT IN ( + SELECT supersedes + FROM news + WHERE supersedes IS NOT NULL + ) + ORDER BY news_id DESC; + + + +-- Create a materialized view to store the data from the recentgamenews view + +CREATE TABLE recentgamenews_mv ( + news_id BIGINT(20) unsigned NOT NULL, + game_id VARCHAR(32) NOT NULL, + news_create_date DATETIME NOT NULL, + PRIMARY KEY (news_id) +); + + + +-- Populate the recentgamenews_mv materialized view from the recentgamenews view + +lock tables recentgamenews_mv write, recentgamenews read; +truncate table recentgamenews_mv; +insert into recentgamenews_mv select * from recentgamenews; +unlock tables; + + + +-- Procedure to update one row of the recentgamenews_mv materialized view + +DROP PROCEDURE IF EXISTS refresh_recentgamenews_mv; +DELIMITER $$ + +CREATE PROCEDURE refresh_recentgamenews_mv ( + IN new_newsid BIGINT(20) +) +BEGIN +select * +from recentgamenews +where news_id = new_newsid +into @news_id, + @game_id, + @news_create_date; +if @news_id is null then + delete from recentgamenews_mv where news_id = new_news_id; +else +insert into recentgamenews_mv +values ( + @news_id, + @game_id, + @news_create_date + ) on duplicate key +update news_id = @news_id, + game_id = @game_id, + news_create_date = @news_create_date; +END IF; +END; +$$ + +DELIMITER ; + + + +-- Create triggers so that when a news item for a game is added to the news table, +-- the latest news date and the latest news id for that game will automatically +-- be updated in the recentgamenews_mv materialized view. [Question: How do I limit this to just game news?] + +CREATE TRIGGER recentgamenews_insert +AFTER INSERT ON news FOR EACH ROW +call refresh_recentgamenews_mv(NEW.newsid); + + +CREATE TRIGGER recentgamenews_update +AFTER UPDATE ON news FOR EACH ROW +call refresh_gametimes_mv(NEW.newsid); + + +CREATE TRIGGER recentgamenews_delete +AFTER DELETE ON news FOR EACH ROW +call refresh_recentgamenews_mv(OLD.newsid); From 4c3d00c4de93e2c1dedc60e3be3c37c017eb4ae8 Mon Sep 17 00:00:00 2001 From: alice-blue Date: Mon, 1 Sep 2025 11:13:24 +0000 Subject: [PATCH 66/72] Exclude deleted news items --- sql/incoming-schema-changes.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql/incoming-schema-changes.sql b/sql/incoming-schema-changes.sql index ed798d3d..81696535 100644 --- a/sql/incoming-schema-changes.sql +++ b/sql/incoming-schema-changes.sql @@ -23,7 +23,8 @@ CREATE VIEW `recentgamenews` AS sourceid AS game_id, created AS news_create_date FROM news - WHERE source = "G" + WHERE source = 'G' + AND status = 'A' AND newsid NOT IN ( SELECT supersedes FROM news From 8934fb581ad90ff33e2b44c5b83348adaf4dabee Mon Sep 17 00:00:00 2001 From: alice-blue Date: Mon, 1 Sep 2025 11:15:01 +0000 Subject: [PATCH 67/72] Add key (game_id) to recentgamenews materialized view --- sql/incoming-schema-changes.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql/incoming-schema-changes.sql b/sql/incoming-schema-changes.sql index 81696535..d9fd1636 100644 --- a/sql/incoming-schema-changes.sql +++ b/sql/incoming-schema-changes.sql @@ -40,7 +40,8 @@ CREATE TABLE recentgamenews_mv ( news_id BIGINT(20) unsigned NOT NULL, game_id VARCHAR(32) NOT NULL, news_create_date DATETIME NOT NULL, - PRIMARY KEY (news_id) + PRIMARY KEY (news_id), + KEY (game_id) ); From 069f447fab1fa807cb030326cf9ae0f03c3bd017 Mon Sep 17 00:00:00 2001 From: alice-blue Date: Mon, 1 Sep 2025 11:15:37 +0000 Subject: [PATCH 68/72] gametimes --> recentgamenews --- sql/incoming-schema-changes.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/incoming-schema-changes.sql b/sql/incoming-schema-changes.sql index d9fd1636..3a220232 100644 --- a/sql/incoming-schema-changes.sql +++ b/sql/incoming-schema-changes.sql @@ -101,7 +101,7 @@ call refresh_recentgamenews_mv(NEW.newsid); CREATE TRIGGER recentgamenews_update AFTER UPDATE ON news FOR EACH ROW -call refresh_gametimes_mv(NEW.newsid); +call refresh_recentgamenews_mv(NEW.newsid); CREATE TRIGGER recentgamenews_delete From 5690ec53c4f9ebeb076a0f22060c57c66ccbafd6 Mon Sep 17 00:00:00 2001 From: alice-blue Date: Mon, 1 Sep 2025 11:35:23 +0000 Subject: [PATCH 69/72] Add a recent_game_news sorting option to the $sortList in searchutil.php, with a join to recent_gamenews_mv. --- www/searchutil.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/www/searchutil.php b/www/searchutil.php index 1cd663f1..c10bef0a 100644 --- a/www/searchutil.php +++ b/www/searchutil.php @@ -914,6 +914,7 @@ function doSearch($db, $term, $searchType, $sortby, $limit, $browse, $count_all_ 'long' => array('rounded_median_time_in_minutes desc, starsort desc,', 'Longest First'), 'short' => array('-rounded_median_time_in_minutes desc, starsort desc,', 'Shortest First'), 'recently_reviewed' => array('lastReviewDate desc,', 'Recently Reviewed First'), + 'recent_game_news' => array('news_id desc,', 'Recent News First'), 'rand' => array('rand(),', 'Random Order')); if (count($words)) { $defSortBy = 'rel'; @@ -1035,6 +1036,15 @@ function doSearch($db, $term, $searchType, $sortby, $limit, $browse, $count_all_ } } + // If we're sorting by recent game news, select the news item's create date + // and join the recent game news + if ($searchType == "game" && $sortby == "recent_game_news") { + $selectList .= ", news_create_date"; + $tableList .= " left outer join recentgamenews_mv on games.id = recentgamenews_mv.game_id"; + } + + + // Build tags join $tagsJoin = ""; From c7c7b516d405e1a0b8495ec0affe56da19422371 Mon Sep 17 00:00:00 2001 From: alice-blue Date: Mon, 1 Sep 2025 11:37:22 +0000 Subject: [PATCH 70/72] Explain what A means --- sql/incoming-schema-changes.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql/incoming-schema-changes.sql b/sql/incoming-schema-changes.sql index 3a220232..14cb8332 100644 --- a/sql/incoming-schema-changes.sql +++ b/sql/incoming-schema-changes.sql @@ -13,7 +13,8 @@ ALTER TABLE `users` ADD COLUMN `game_filter` VARCHAR(150) DEFAULT ''; -- Add a view to track the news items for each game. --- "G" in the news table means the news is about a game. +-- "G" in the news table means the news is about a game, +-- and "A" means the news has not been deleted. -- Do not include versions of news items that have been -- superseded by later edits. From 8d7c16723e467695ff19bc693619866c3c5de9f8 Mon Sep 17 00:00:00 2001 From: alice-blue Date: Mon, 1 Sep 2025 10:35:47 -0400 Subject: [PATCH 71/72] newitems.php: In the game news query, limit results to games that match the game IDs from doSearch This is only partly working. I think it's successfully identifying the games with recent news, but that news is not showing up on the home page. --- www/newitems.php | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/www/newitems.php b/www/newitems.php index 9403533b..a2275801 100644 --- a/www/newitems.php +++ b/www/newitems.php @@ -249,15 +249,38 @@ function getNewItems($db, $limit, $itemTypes = NEWITEMS_ALLITEMS, $options = [], } if ($itemTypes & NEWITEMS_GAMENEWS) { + // Query the games and sort them so that games with recent news + // come first. If the user has a custom game filter and has not + // overridden it, that filter will automatically be applied within + // the doSearch function. + $term = ""; + $searchType = "game"; + $sortby = "recent_game_news"; $games_limit = $options['games_limit'] ?? $limit; + $limit_clause = "limit $games_limit"; + $browse = 0; + list($rows, $rowcnt, $sortList, $errMsg, $summaryDesc, $badges, + $specials, $specialsUsed, $orderBy) = + doSearch($db, $term, $searchType, $sortby, $limit_clause, $browse); + + // Put the resulting game IDs in an array so that we can + // limit news results to these (possibly filtered) games. + $games_with_recent_news = []; + foreach ($rows as $row) { + $games_with_recent_news[] = $row['id']; + } + // query game news updates queryNewNews( $items, $db, $games_limit, "G", - "join games as g on g.id = n.sourceid", + "join games as g on g.id = n.sourceid " + . "join recentgamenews_mv r on r.news_id = n.newsid", "g.id as sourceID, g.title as sourceTitle, " - . "(g.coverart is not null) as hasart, g.pagevsn", $days); + . "(g.coverart is not null) as hasart, g.pagevsn", + $days, $games_with_recent_news); } + if ($itemTypes & NEWITEMS_COMPNEWS) { $comps_limit = $options['comps_limit'] ?? $limit; // add the competition news updates @@ -295,7 +318,8 @@ function sortNewItemsByDate($a, $b) } function queryNewNews(&$items, $db, $limit, $sourceType, - $sourceJoin, $sourceCols, $days = null) + $sourceJoin, $sourceCols, $days = null, + $games_with_recent_news = []) { // get the logged-in user checkPersistentLogin(); @@ -325,6 +349,15 @@ function queryNewNews(&$items, $db, $limit, $sourceType, if ($mysandbox != 0) $sandbox = "(0,$mysandbox)"; } + + // Include game news only from games that remain after applying a custom filter + $andGameIDsMatch = ""; + if ($games_with_recent_news) { + // Change the array to a string + $games_with_recent_news = "'" . implode("', '",$games_with_recent_news) . "'"; + echo "GAMES WITH RECENT NEWS = $games_with_recent_news"; // Delete this line after we get this working + $andGameIDsMatch = "and recentgamenews_mv.game_id in ($games_with_recent_news)"; + } // query the data $result = mysql_query( @@ -353,6 +386,7 @@ function queryNewNews(&$items, $db, $limit, $sourceType, and uorig.sandbox in $sandbox and $dayWhere $andNotMuted + $andGameIDsMatch order by n.created desc limit $limit", $db); From d8d8dcb5188f9438ee5f867d12d1b398d32cb534 Mon Sep 17 00:00:00 2001 From: alice-blue Date: Mon, 1 Sep 2025 21:21:45 -0400 Subject: [PATCH 72/72] newitems.php: Change recentgamenews_mv.game_id to g.id This seems to have fixed the query that wasn't working. --- www/newitems.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/www/newitems.php b/www/newitems.php index a2275801..746ec450 100644 --- a/www/newitems.php +++ b/www/newitems.php @@ -353,10 +353,8 @@ function queryNewNews(&$items, $db, $limit, $sourceType, // Include game news only from games that remain after applying a custom filter $andGameIDsMatch = ""; if ($games_with_recent_news) { - // Change the array to a string $games_with_recent_news = "'" . implode("', '",$games_with_recent_news) . "'"; - echo "GAMES WITH RECENT NEWS = $games_with_recent_news"; // Delete this line after we get this working - $andGameIDsMatch = "and recentgamenews_mv.game_id in ($games_with_recent_news)"; + $andGameIDsMatch = "and g.id in ($games_with_recent_news) "; } // query the data