]> 91.132.146.200 Git - insipid.git/commitdiff
reduce some load. updated todo
authorBanana <banana@optimus.de>
Thu, 3 Oct 2019 19:34:43 +0000 (21:34 +0200)
committerBanana <banana@optimus.de>
Thu, 3 Oct 2019 19:34:43 +0000 (21:34 +0200)
TODO
webroot/lib/link.class.php
webroot/lib/management.class.php
webroot/view/overview.php

diff --git a/TODO b/TODO
index 8dfa88062aba48293a0ff90c3808a9d6f7dcc103..e9f37a21be8990bc661ed7809bcb8f36f0cc6c20 100755 (executable)
--- a/TODO
+++ b/TODO
@@ -3,7 +3,7 @@ TODO / Feature list
 + theme support
 + bookmark js snippet
 + snapshots
-+ stats
++ stats, storage usage
 + private links
 + more "secure" user authentication
 ++ multiple user accounts and stuff
index f3d24191a85bcca9d5ade3df63539d51aabe7ed4..09130a607170a3aff8a5294c78287a5e6bd3a89c 100644 (file)
@@ -79,6 +79,42 @@ class Link {
                return $this->_data;
        }
 
+       /**
+        * loads only the info needed to display the link
+        * for edit use $this->load
+        * @param $hash
+        * @return array
+        */
+       public function loadShortInfo($hash) {
+               $this->_data = array();
+
+               if(!empty($hash)) {
+                       $queryStr = "SELECT
+                               any_value(`id`) as id,
+                               any_value(`link`) as link,
+                               any_value(`description`) as description,
+                               any_value(`title`) as title,
+                               any_value(`image`) as image,
+                               any_value(`hash`) as hash
+                               FROM `".DB_PREFIX."_link`
+                               WHERE `hash` = '".$this->DB->real_escape_string($hash)."'";
+                       $query = $this->DB->query($queryStr);
+                       if(!empty($query) && $query->num_rows == 1) {
+                               $this->_data = $query->fetch_assoc();
+
+                               # add stuff
+                               $this->_image();
+                       }
+               }
+
+               return $this->_data;
+       }
+
+       /**
+        * return all or data fpr given key on the current loaded link
+        * @param bool $key
+        * @return array|mixed
+        */
        public function getData($key=false) {
                $ret = $this->_data;
 
index a26cab7c9f0941ddefea691356838012791edfda..e7099744e5ef5a20e92f82f7c01f5ee1ce7a0c8f 100644 (file)
@@ -265,15 +265,15 @@ class Management {
        /**
         * return all links and Info we have from the combined view
         * @param bool | int $limit
+        * @param bool $offset
         * @return array
         */
        public function links($limit=false,$offset=false) {
                $ret = array();
 
-               $queryStr = "SELECT ".$this->COMBINED_SELECT_VALUES."
-                       FROM `".DB_PREFIX."_combined`
+               $queryStr = "SELECT `hash`
+                       FROM `".DB_PREFIX."_link`
                        WHERE `status` = 2
-                       GROUP BY `hash`
                        ORDER BY `created` DESC";
                if(!empty($limit)) {
                        $queryStr .= " LIMIT $limit";
@@ -283,7 +283,11 @@ class Management {
                }
                $query = $this->DB->query($queryStr);
                if(!empty($query) && $query->num_rows > 0) {
-                       $ret['results'] = $query->fetch_all(MYSQLI_ASSOC);
+                       while($result = $query->fetch_assoc()) {
+                               $linkObj = new Link($this->DB);
+                               $ret['results'][] = $linkObj->loadShortInfo($result['hash']);
+                               unset($linkObj);
+                       }
 
                        $query = $this->DB->query("SELECT COUNT(DISTINCT(hash)) AS `amount` 
                                FROM `".DB_PREFIX."_combined`
index fc5bc5c550ef57bbb584e273bd39e78f3df3b282..c9dbc383ecc04957d61658d7c7d3d1793e78a531 100644 (file)
                                <figure class="image is-4by3">
                                <a href="<?php echo $link['link']; ?>" target="_blank">
                        <?php if(!empty($link['image'])) { ?>
-                               <img class="linkthumbnail" src= "<?php echo $link['image']; ?>">
+                               <img class="linkthumbnail" src= "<?php echo $link['imageToShow']; ?>">
                        <?php } else { ?>
                                <img class="" src= "asset/img/no-link-picture.png">
                        <?php } ?>