viewgit/inc/functions.php:22 Function utf8_encode() is deprecated [8192]

Add a new impression type for viewing a cached web page in search, a=chris

Chris Pollett [2022-11-02 20:Nov:nd]
Add a new impression type for viewing a cached web page in search, a=chris
Filename
src/configs/Config.php
src/models/ImpressionModel.php
src/models/ProfileModel.php
diff --git a/src/configs/Config.php b/src/configs/Config.php
index ab7cb262d..925b3176e 100755
--- a/src/configs/Config.php
+++ b/src/configs/Config.php
@@ -1206,6 +1206,10 @@ nsdefine('GROUP_IMPRESSION', 3);
  * Impression type used to record one search query view
  */
 nsdefine('QUERY_IMPRESSION', 4);
+/**
+ * Impression type used to record one search query view
+ */
+nsdefine('CACHE_IMPRESSION', 5);
 /**
  * Number of ITEM_RECOMMENDATIONs to suggest to a user
  */
diff --git a/src/models/ImpressionModel.php b/src/models/ImpressionModel.php
index 931855d21..abd819a2c 100644
--- a/src/models/ImpressionModel.php
+++ b/src/models/ImpressionModel.php
@@ -105,16 +105,18 @@ class ImpressionModel extends Model
         $sql = "SELECT ID FROM QUERY_ITEM WHERE QUERY_HASH = ?";
         $result = $db->execute($sql, [$query_hash]);
         $row = $db->fetchArray($result);
+        $impression_type = (strncmp($query, "cache:", 6) === 0) ?
+            C\CACHE_IMPRESSION : C\QUERY_IMPRESSION;
         if (empty($row['ID'])) {
             $sql = "INSERT INTO QUERY_ITEM (QUERY_HASH, QUERY, CREATION)
                 VALUES (?, ?, ?)";
             $sql = $db->insertIgnore($sql, $dbinfo);
             $result = $db->execute($sql, [$query_hash, $query, time()]);
             $this->initWithDb(C\PUBLIC_USER_ID, $db->insertID("QUERY_ITEM"),
-                C\QUERY_IMPRESSION, $db);
+                $impression_type, $db);
         } else {
             $this->addWithDb(C\PUBLIC_USER_ID, $row['ID'],
-                C\QUERY_IMPRESSION, $db);
+                $impression_type, $db);
         }
     }
     /**
diff --git a/src/models/ProfileModel.php b/src/models/ProfileModel.php
index b1b5a2d86..f239ee28d 100755
--- a/src/models/ProfileModel.php
+++ b/src/models/ProfileModel.php
@@ -198,6 +198,8 @@ class ProfileModel extends Model
                 TYPE $integer DEFAULT " . C\STANDARD_GROUP_ITEM . ")",
             "GI_GROUP_ID_INDEX" => "CREATE INDEX GI_GROUP_ID_INDEX ON
                 GROUP_ITEM (GROUP_ID)",
+            "GI_PUBDATE_INDEX" => "CREATE INDEX
+                GI_PUBDATE_INDEX ON GROUP_ITEM (PUBDATE)",
             "GI_GROUP_ID_PUBDATE_INDEX" => "CREATE INDEX
                 GI_GROUP_ID_PUBDATE_INDEX ON GROUP_ITEM (GROUP_ID, PUBDATE)",
             "GI_USER_ID_INDEX" => "CREATE INDEX GI_USER_ID_INDEX ON
ViewGit