@@ -188,18 +188,18 @@ |
||
| 188 | 188 | //FIXME: Query duplication. |
| 189 | 189 | if($this->User->id !== $userID) { |
| 190 | 190 | $query = $this->db->select('value_str, value_int') |
| 191 | - ->from('user_options') |
|
| 192 | - ->where('user_id', $userID) |
|
| 193 | - ->where('name', $option) |
|
| 194 | - ->limit(1); |
|
| 191 | + ->from('user_options') |
|
| 192 | + ->where('user_id', $userID) |
|
| 193 | + ->where('name', $option) |
|
| 194 | + ->limit(1); |
|
| 195 | 195 | $data = $query->get()->row_array(); |
| 196 | 196 | } else { |
| 197 | 197 | if(!($data = $this->session->tempdata("option_{$option}"))) { |
| 198 | 198 | $query = $this->db->select('value_str, value_int') |
| 199 | - ->from('user_options') |
|
| 200 | - ->where('user_id', $userID) |
|
| 201 | - ->where('name', $option) |
|
| 202 | - ->limit(1); |
|
| 199 | + ->from('user_options') |
|
| 200 | + ->where('user_id', $userID) |
|
| 201 | + ->where('name', $option) |
|
| 202 | + ->limit(1); |
|
| 203 | 203 | $data = $query->get()->row_array(); |
| 204 | 204 | $this->session->set_tempdata("option_{$option}", $data, 3600); |
| 205 | 205 | } |
@@ -171,14 +171,14 @@ discard block |
||
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | $idQuery = $this->db->select('id') |
| 174 | - ->where('user_id', $userID) |
|
| 175 | - ->where('title_id', $titleID) |
|
| 176 | - ->get('tracker_chapters'); |
|
| 174 | + ->where('user_id', $userID) |
|
| 175 | + ->where('title_id', $titleID) |
|
| 176 | + ->get('tracker_chapters'); |
|
| 177 | 177 | if($idQuery->num_rows() > 0) { |
| 178 | 178 | $success = (bool) $this->db->set(['current_chapter' => $chapter, 'active' => 'Y', 'last_updated' => NULL, 'ignore_chapter' => NULL]) |
| 179 | - ->where('user_id', $userID) |
|
| 180 | - ->where('title_id', $titleID) |
|
| 181 | - ->update('tracker_chapters'); |
|
| 179 | + ->where('user_id', $userID) |
|
| 180 | + ->where('title_id', $titleID) |
|
| 181 | + ->update('tracker_chapters'); |
|
| 182 | 182 | |
| 183 | 183 | if($success) { |
| 184 | 184 | $idQueryRow = $idQuery->row(); |
@@ -204,9 +204,9 @@ discard block |
||
| 204 | 204 | } |
| 205 | 205 | public function updateByID(int $userID, int $chapterID, string $chapter) : bool { |
| 206 | 206 | $success = (bool) $this->db->set(['current_chapter' => $chapter, 'active' => 'Y', 'last_updated' => NULL]) |
| 207 | - ->where('user_id', $userID) |
|
| 208 | - ->where('id', $chapterID) |
|
| 209 | - ->update('tracker_chapters'); |
|
| 207 | + ->where('user_id', $userID) |
|
| 208 | + ->where('id', $chapterID) |
|
| 209 | + ->update('tracker_chapters'); |
|
| 210 | 210 | |
| 211 | 211 | if($success) { |
| 212 | 212 | $this->History->userUpdateTitle($chapterID, $chapter); |
@@ -216,9 +216,9 @@ discard block |
||
| 216 | 216 | |
| 217 | 217 | public function ignoreByID(int $userID, int $chapterID, string $chapter) : bool { |
| 218 | 218 | $success = (bool) $this->db->set(['ignore_chapter' => $chapter, 'active' => 'Y', 'last_updated' => NULL]) |
| 219 | - ->where('user_id', $userID) |
|
| 220 | - ->where('id', $chapterID) |
|
| 221 | - ->update('tracker_chapters'); |
|
| 219 | + ->where('user_id', $userID) |
|
| 220 | + ->where('id', $chapterID) |
|
| 221 | + ->update('tracker_chapters'); |
|
| 222 | 222 | |
| 223 | 223 | if($success) { |
| 224 | 224 | $this->History->userIgnoreTitle($chapterID, $chapter); |
@@ -231,9 +231,9 @@ discard block |
||
| 231 | 231 | //This is to allow user history to function properly. |
| 232 | 232 | |
| 233 | 233 | $success = $this->db->set(['active' => 'N', 'last_updated' => NULL]) |
| 234 | - ->where('user_id', $userID) |
|
| 235 | - ->where('id', $chapterID) |
|
| 236 | - ->update('tracker_chapters'); |
|
| 234 | + ->where('user_id', $userID) |
|
| 235 | + ->where('id', $chapterID) |
|
| 236 | + ->update('tracker_chapters'); |
|
| 237 | 237 | |
| 238 | 238 | return (bool) $success; |
| 239 | 239 | } |
@@ -263,9 +263,9 @@ discard block |
||
| 263 | 263 | //TODO: OPTION, USE BACKEND MAL ID DB WHERE POSSIBLE (DEFAULT TRUE) |
| 264 | 264 | |
| 265 | 265 | $queryC = $this->db->select('mal_id') |
| 266 | - ->where('user_id', $userID) |
|
| 267 | - ->where('title_id', $titleID) |
|
| 268 | - ->get('tracker_chapters'); |
|
| 266 | + ->where('user_id', $userID) |
|
| 267 | + ->where('title_id', $titleID) |
|
| 268 | + ->get('tracker_chapters'); |
|
| 269 | 269 | |
| 270 | 270 | if($queryC->num_rows() > 0 && ($rowC = $queryC->row())) { |
| 271 | 271 | $malIDArr = [ |
@@ -274,8 +274,8 @@ discard block |
||
| 274 | 274 | ]; |
| 275 | 275 | } else { |
| 276 | 276 | $queryT = $this->db->select('mal_id') |
| 277 | - ->where('title_id', $titleID) |
|
| 278 | - ->get('tracker_titles'); |
|
| 277 | + ->where('title_id', $titleID) |
|
| 278 | + ->get('tracker_titles'); |
|
| 279 | 279 | |
| 280 | 280 | if($queryT->num_rows() > 0 && ($rowT = $queryT->row())) { |
| 281 | 281 | $malIDArr = [ |
@@ -289,9 +289,9 @@ discard block |
||
| 289 | 289 | //TODO: Remove after a few weeks! |
| 290 | 290 | if(is_null($malIDArr)) { |
| 291 | 291 | $queryC2 = $this->db->select('tags') |
| 292 | - ->where('user_id', $userID) |
|
| 293 | - ->where('title_id', $titleID) |
|
| 294 | - ->get('tracker_chapters'); |
|
| 292 | + ->where('user_id', $userID) |
|
| 293 | + ->where('title_id', $titleID) |
|
| 294 | + ->get('tracker_chapters'); |
|
| 295 | 295 | |
| 296 | 296 | if($queryC2->num_rows() > 0 && ($tag_string = $queryC2->row()->tags) && !is_null($tag_string)) { |
| 297 | 297 | $arr = preg_grep('/^mal:([0-9]+|none)$/', explode(',', $tag_string)); |
@@ -309,9 +309,9 @@ discard block |
||
| 309 | 309 | public function setMalID(int $userID, int $chapterID, ?int $malID) : bool { |
| 310 | 310 | //TODO: Handle NULL? |
| 311 | 311 | $success = (bool) $this->db->set(['mal_id' => $malID, 'active' => 'Y', 'last_updated' => NULL]) |
| 312 | - ->where('user_id', $userID) |
|
| 313 | - ->where('id', $chapterID) |
|
| 314 | - ->update('tracker_chapters'); |
|
| 312 | + ->where('user_id', $userID) |
|
| 313 | + ->where('id', $chapterID) |
|
| 314 | + ->update('tracker_chapters'); |
|
| 315 | 315 | |
| 316 | 316 | if($success) { |
| 317 | 317 | //MAL id update was successful, update history |
@@ -44,12 +44,12 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | private function _list_complete_titles() { |
| 46 | 46 | $query = $this->db->select('tracker_titles.id, tracker_sites.site_class, tracker_titles.title, tracker_titles.title_url') |
| 47 | - ->from('tracker_chapters') |
|
| 48 | - ->join('tracker_titles', 'tracker_chapters.title_id = tracker_titles.id', 'left') |
|
| 49 | - ->join('tracker_sites', 'tracker_sites.id = tracker_titles.site_id', 'left') |
|
| 50 | - ->like('tracker_chapters.tags', 'complete') |
|
| 51 | - ->where('tracker_titles.status', 0) |
|
| 52 | - ->get(); |
|
| 47 | + ->from('tracker_chapters') |
|
| 48 | + ->join('tracker_titles', 'tracker_chapters.title_id = tracker_titles.id', 'left') |
|
| 49 | + ->join('tracker_sites', 'tracker_sites.id = tracker_titles.site_id', 'left') |
|
| 50 | + ->like('tracker_chapters.tags', 'complete') |
|
| 51 | + ->where('tracker_titles.status', 0) |
|
| 52 | + ->get(); |
|
| 53 | 53 | |
| 54 | 54 | $completeList = []; |
| 55 | 55 | if($query->num_rows() > 0) { |
@@ -68,10 +68,10 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | private function _update_mal_id() : void { |
| 70 | 70 | $query = $this->db->select('id, tags') |
| 71 | - ->from('tracker_chapters') |
|
| 72 | - ->where('tags REGEXP "[[:<:]]mal:([0-9]+|none)[[:>:]]"', NULL, FALSE) |
|
| 73 | - ->where('mal_id', NULL) |
|
| 74 | - ->get(); |
|
| 71 | + ->from('tracker_chapters') |
|
| 72 | + ->where('tags REGEXP "[[:<:]]mal:([0-9]+|none)[[:>:]]"', NULL, FALSE) |
|
| 73 | + ->where('mal_id', NULL) |
|
| 74 | + ->get(); |
|
| 75 | 75 | |
| 76 | 76 | |
| 77 | 77 | if($query->num_rows() > 0) { |
@@ -83,8 +83,8 @@ discard block |
||
| 83 | 83 | $new_tags = implode(',', array_diff( explode(',', $row->tags), [$matches[0]])); |
| 84 | 84 | |
| 85 | 85 | $this->db->set(['mal_id' => $malID, 'tags' => $new_tags, 'last_updated' => NULL]) |
| 86 | - ->where('id', $row->id) |
|
| 87 | - ->update('tracker_chapters'); |
|
| 86 | + ->where('id', $row->id) |
|
| 87 | + ->update('tracker_chapters'); |
|
| 88 | 88 | } |
| 89 | 89 | } |
| 90 | 90 | } |
@@ -75,8 +75,8 @@ discard block |
||
| 75 | 75 | //Make sure last_checked is always updated on successful run. |
| 76 | 76 | //CHECK: Is there a reason we aren't just doing this in updateByID? |
| 77 | 77 | $this->db->set('last_checked', 'CURRENT_TIMESTAMP', FALSE) |
| 78 | - ->where('id', $row->id) |
|
| 79 | - ->update('tracker_titles'); |
|
| 78 | + ->where('id', $row->id) |
|
| 79 | + ->update('tracker_titles'); |
|
| 80 | 80 | |
| 81 | 81 | print " - ({$titleData['latest_chapter']})\n"; |
| 82 | 82 | } else { |
@@ -96,9 +96,9 @@ discard block |
||
| 96 | 96 | */ |
| 97 | 97 | public function updateCustom() { |
| 98 | 98 | $query = $this->db->select('*') |
| 99 | - ->from('tracker_sites') |
|
| 100 | - ->where('status', 'enabled') |
|
| 101 | - ->get(); |
|
| 99 | + ->from('tracker_sites') |
|
| 100 | + ->where('status', 'enabled') |
|
| 101 | + ->get(); |
|
| 102 | 102 | |
| 103 | 103 | $sites = $query->result_array(); |
| 104 | 104 | foreach ($sites as $site) { |
@@ -113,8 +113,8 @@ discard block |
||
| 113 | 113 | //Make sure last_checked is always updated on successful run. |
| 114 | 114 | //CHECK: Is there a reason we aren't just doing this in updateByID? |
| 115 | 115 | $this->db->set('last_checked', 'CURRENT_TIMESTAMP', FALSE) |
| 116 | - ->where('id', $titleID) |
|
| 117 | - ->update('tracker_titles'); |
|
| 116 | + ->where('id', $titleID) |
|
| 117 | + ->update('tracker_titles'); |
|
| 118 | 118 | |
| 119 | 119 | print " - ({$titleData['latest_chapter']})\n"; |
| 120 | 120 | } else { |
@@ -138,13 +138,13 @@ discard block |
||
| 138 | 138 | |
| 139 | 139 | public function refollowCustom() { |
| 140 | 140 | $query = $this->db->select('tracker_titles.id, tracker_titles.title_url, tracker_sites.site_class') |
| 141 | - ->from('tracker_titles') |
|
| 142 | - ->join('tracker_sites', 'tracker_sites.id = tracker_titles.site_id', 'left') |
|
| 143 | - ->where('tracker_titles.followed','N') |
|
| 144 | - ->where('tracker_titles !=', '255') |
|
| 145 | - ->where('tracker_sites.status', 'enabled') |
|
| 146 | - ->where('tracker_sites.use_custom', 'Y') |
|
| 147 | - ->get(); |
|
| 141 | + ->from('tracker_titles') |
|
| 142 | + ->join('tracker_sites', 'tracker_sites.id = tracker_titles.site_id', 'left') |
|
| 143 | + ->where('tracker_titles.followed','N') |
|
| 144 | + ->where('tracker_titles !=', '255') |
|
| 145 | + ->where('tracker_sites.status', 'enabled') |
|
| 146 | + ->where('tracker_sites.use_custom', 'Y') |
|
| 147 | + ->get(); |
|
| 148 | 148 | |
| 149 | 149 | if($query->num_rows() > 0) { |
| 150 | 150 | foreach($query->result() as $row) { |
@@ -155,8 +155,8 @@ discard block |
||
| 155 | 155 | |
| 156 | 156 | if(!empty($titleData)) { |
| 157 | 157 | $this->db->set($titleData) |
| 158 | - ->where('id', $row->id) |
|
| 159 | - ->update('tracker_titles'); |
|
| 158 | + ->where('id', $row->id) |
|
| 159 | + ->update('tracker_titles'); |
|
| 160 | 160 | |
| 161 | 161 | print "> {$row->site_class}:{$row->id}:{$row->title_url} FOLLOWED\n"; |
| 162 | 162 | } else { |
@@ -204,8 +204,8 @@ discard block |
||
| 204 | 204 | if($titleData['title'] && is_array($titleData) && !is_null($titleData['latest_chapter'])) { |
| 205 | 205 | if($titleData['title'] !== $row->title) { |
| 206 | 206 | $this->db->set('title', $titleData['title']) |
| 207 | - ->where('id', $row->id) |
|
| 208 | - ->update('tracker_titles'); |
|
| 207 | + ->where('id', $row->id) |
|
| 208 | + ->update('tracker_titles'); |
|
| 209 | 209 | //TODO: Add to history somehow? |
| 210 | 210 | print " - NEW TITLE ({$titleData['title']})\n"; |
| 211 | 211 | } else { |
@@ -215,8 +215,8 @@ discard block |
||
| 215 | 215 | //We might as well try to update as well. |
| 216 | 216 | if($this->Tracker->title->updateByID((int) $row->id, $titleData['latest_chapter'])) { |
| 217 | 217 | $this->db->set('last_checked', 'CURRENT_TIMESTAMP', FALSE) |
| 218 | - ->where('id', $row->id) |
|
| 219 | - ->update('tracker_titles'); |
|
| 218 | + ->where('id', $row->id) |
|
| 219 | + ->update('tracker_titles'); |
|
| 220 | 220 | } |
| 221 | 221 | } else { |
| 222 | 222 | log_message('error', "{$row->title} failed to update title successfully"); |
@@ -53,9 +53,9 @@ |
||
| 53 | 53 | ]; |
| 54 | 54 | |
| 55 | 55 | $this->output |
| 56 | - ->set_status_header('200') |
|
| 57 | - ->set_content_type('application/json', 'utf-8') |
|
| 58 | - ->set_output(json_encode($json)); |
|
| 56 | + ->set_status_header('200') |
|
| 57 | + ->set_content_type('application/json', 'utf-8') |
|
| 58 | + ->set_output(json_encode($json)); |
|
| 59 | 59 | } else { |
| 60 | 60 | //TODO: We should probably try and have more verbose errors here. Return via JSON or something. |
| 61 | 61 | $this->output->set_status_header('400', 'Unable to update?'); |
@@ -15,11 +15,11 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | public function getID(string $titleURL, int $siteID, bool $create = TRUE, bool $returnData = FALSE) { |
| 17 | 17 | $query = $this->db->select('tracker_titles.id, tracker_titles.title, tracker_titles.title_url, tracker_titles.latest_chapter, tracker_titles.status, tracker_sites.site_class, (tracker_titles.last_checked > DATE_SUB(NOW(), INTERVAL 3 DAY)) AS active', FALSE) |
| 18 | - ->from('tracker_titles') |
|
| 19 | - ->join('tracker_sites', 'tracker_sites.id = tracker_titles.site_id', 'left') |
|
| 20 | - ->where('tracker_titles.title_url', $titleURL) |
|
| 21 | - ->where('tracker_titles.site_id', $siteID) |
|
| 22 | - ->get(); |
|
| 18 | + ->from('tracker_titles') |
|
| 19 | + ->join('tracker_sites', 'tracker_sites.id = tracker_titles.site_id', 'left') |
|
| 20 | + ->where('tracker_titles.title_url', $titleURL) |
|
| 21 | + ->where('tracker_titles.site_id', $siteID) |
|
| 22 | + ->get(); |
|
| 23 | 23 | |
| 24 | 24 | if($query->num_rows() > 0) { |
| 25 | 25 | $id = (int) $query->row('id'); |
@@ -32,8 +32,8 @@ discard block |
||
| 32 | 32 | //Make sure last_checked is always updated on successful run. |
| 33 | 33 | //CHECK: Is there a reason we aren't just doing this in updateTitleById? |
| 34 | 34 | $this->db->set('last_checked', 'CURRENT_TIMESTAMP', FALSE) |
| 35 | - ->where('id', $id) |
|
| 36 | - ->update('tracker_titles'); |
|
| 35 | + ->where('id', $id) |
|
| 36 | + ->update('tracker_titles'); |
|
| 37 | 37 | } |
| 38 | 38 | } else { |
| 39 | 39 | log_message('error', "{$query->row('title')} failed to update successfully"); |
@@ -73,9 +73,9 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | private function addTitle(string $titleURL, int $siteID) : int { |
| 75 | 75 | $query = $this->db->select('site, site_class') |
| 76 | - ->from('tracker_sites') |
|
| 77 | - ->where('id', $siteID) |
|
| 78 | - ->get(); |
|
| 76 | + ->from('tracker_sites') |
|
| 77 | + ->where('id', $siteID) |
|
| 78 | + ->get(); |
|
| 79 | 79 | |
| 80 | 80 | $titleData = $this->sites->{$query->row()->site_class}->getTitleData($titleURL, TRUE); |
| 81 | 81 | |
@@ -101,20 +101,20 @@ discard block |
||
| 101 | 101 | public function updateByID(int $titleID, string $latestChapter) : bool { |
| 102 | 102 | //FIXME: Really not too happy with how we're doing history stuff here, it just feels messy. |
| 103 | 103 | $query = $this->db->select('latest_chapter AS current_chapter') |
| 104 | - ->from('tracker_titles') |
|
| 105 | - ->where('id', $titleID) |
|
| 106 | - ->get(); |
|
| 104 | + ->from('tracker_titles') |
|
| 105 | + ->where('id', $titleID) |
|
| 106 | + ->get(); |
|
| 107 | 107 | $row = $query->row(); |
| 108 | 108 | |
| 109 | 109 | $success = $this->db->set(['latest_chapter' => $latestChapter, 'failed_checks' => 0]) //last_updated gets updated via a trigger if something changes |
| 110 | - ->where('id', $titleID) |
|
| 111 | - ->update('tracker_titles'); |
|
| 110 | + ->where('id', $titleID) |
|
| 111 | + ->update('tracker_titles'); |
|
| 112 | 112 | |
| 113 | 113 | if($this->db->affected_rows() > 0) { |
| 114 | 114 | //Clear hidden latest chapter |
| 115 | 115 | $this->db->set(['ignore_chapter' => 'NULL', 'last_updated' => 'last_updated'], NULL, FALSE) |
| 116 | - ->where('title_id', $titleID) |
|
| 117 | - ->update('tracker_chapters'); |
|
| 116 | + ->where('title_id', $titleID) |
|
| 117 | + ->update('tracker_chapters'); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | //Update History |
@@ -127,8 +127,8 @@ discard block |
||
| 127 | 127 | |
| 128 | 128 | public function updateFailedChecksByID(int $titleID) : bool { |
| 129 | 129 | $success = $this->db->set('failed_checks', 'failed_checks + 1', FALSE) |
| 130 | - ->where('id', $titleID) |
|
| 131 | - ->update('tracker_titles'); |
|
| 130 | + ->where('id', $titleID) |
|
| 131 | + ->update('tracker_titles'); |
|
| 132 | 132 | |
| 133 | 133 | return $success; |
| 134 | 134 | } |
@@ -140,9 +140,9 @@ discard block |
||
| 140 | 140 | */ |
| 141 | 141 | public function getSiteDataFromURL(string $site_url) { |
| 142 | 142 | $query = $this->db->select('*') |
| 143 | - ->from('tracker_sites') |
|
| 144 | - ->where('site', $site_url) |
|
| 145 | - ->get(); |
|
| 143 | + ->from('tracker_sites') |
|
| 144 | + ->where('site', $site_url) |
|
| 145 | + ->get(); |
|
| 146 | 146 | |
| 147 | 147 | return $query->row(); |
| 148 | 148 | } |