@@ -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'); |
@@ -33,8 +33,8 @@ discard block |
||
| 33 | 33 | //Make sure last_checked is always updated on successful run. |
| 34 | 34 | //CHECK: Is there a reason we aren't just doing this in updateTitleById? |
| 35 | 35 | $this->db->set('last_checked', 'CURRENT_TIMESTAMP', FALSE) |
| 36 | - ->where('id', $id) |
|
| 37 | - ->update('tracker_titles'); |
|
| 36 | + ->where('id', $id) |
|
| 37 | + ->update('tracker_titles'); |
|
| 38 | 38 | } |
| 39 | 39 | } else { |
| 40 | 40 | log_message('error', "{$siteClass} | {$query->row('title')} ({$query->row('title_url')}) | Failed to update."); |
@@ -74,9 +74,9 @@ discard block |
||
| 74 | 74 | */ |
| 75 | 75 | private function addTitle(string $titleURL, int $siteID) : int { |
| 76 | 76 | $query = $this->db->select('site, site_class') |
| 77 | - ->from('tracker_sites') |
|
| 78 | - ->where('id', $siteID) |
|
| 79 | - ->get(); |
|
| 77 | + ->from('tracker_sites') |
|
| 78 | + ->where('id', $siteID) |
|
| 79 | + ->get(); |
|
| 80 | 80 | |
| 81 | 81 | $titleData = $this->sites->{$query->row()->site_class}->getTitleData($titleURL, TRUE); |
| 82 | 82 | |
@@ -102,21 +102,21 @@ discard block |
||
| 102 | 102 | public function updateByID(int $titleID, ?string $latestChapter) : bool { |
| 103 | 103 | //FIXME: Really not too happy with how we're doing history stuff here, it just feels messy. |
| 104 | 104 | $query = $this->db->select('latest_chapter AS current_chapter') |
| 105 | - ->from('tracker_titles') |
|
| 106 | - ->where('id', $titleID) |
|
| 107 | - ->get(); |
|
| 105 | + ->from('tracker_titles') |
|
| 106 | + ->where('id', $titleID) |
|
| 107 | + ->get(); |
|
| 108 | 108 | $row = $query->row(); |
| 109 | 109 | |
| 110 | 110 | //TODO (CHECK): If failed_checks changes won't that trigger affected_rows? |
| 111 | 111 | $success = $this->db->set(['latest_chapter' => $latestChapter, 'failed_checks' => 0]) //last_updated gets updated via a trigger if something changes |
| 112 | - ->where('id', $titleID) |
|
| 113 | - ->update('tracker_titles'); |
|
| 112 | + ->where('id', $titleID) |
|
| 113 | + ->update('tracker_titles'); |
|
| 114 | 114 | |
| 115 | 115 | if($this->db->affected_rows() > 0) { |
| 116 | 116 | //Clear hidden latest chapter |
| 117 | 117 | $this->db->set(['ignore_chapter' => 'NULL', 'last_updated' => 'last_updated'], NULL, FALSE) |
| 118 | - ->where('title_id', $titleID) |
|
| 119 | - ->update('tracker_chapters'); |
|
| 118 | + ->where('title_id', $titleID) |
|
| 119 | + ->update('tracker_chapters'); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | //Update History |
@@ -129,8 +129,8 @@ discard block |
||
| 129 | 129 | |
| 130 | 130 | public function updateFailedChecksByID(int $titleID) : bool { |
| 131 | 131 | $success = $this->db->set('failed_checks', 'failed_checks + 1', FALSE) |
| 132 | - ->where('id', $titleID) |
|
| 133 | - ->update('tracker_titles'); |
|
| 132 | + ->where('id', $titleID) |
|
| 133 | + ->update('tracker_titles'); |
|
| 134 | 134 | |
| 135 | 135 | return $success; |
| 136 | 136 | } |
@@ -142,9 +142,9 @@ discard block |
||
| 142 | 142 | */ |
| 143 | 143 | public function getSiteDataFromURL(string $site_url) { |
| 144 | 144 | $query = $this->db->select('*') |
| 145 | - ->from('tracker_sites') |
|
| 146 | - ->where('site', $site_url) |
|
| 147 | - ->get(); |
|
| 145 | + ->from('tracker_sites') |
|
| 146 | + ->where('site', $site_url) |
|
| 147 | + ->get(); |
|
| 148 | 148 | |
| 149 | 149 | return $query->row(); |
| 150 | 150 | } |
@@ -152,8 +152,8 @@ discard block |
||
| 152 | 152 | //Make sure last_checked is always updated on successful run. |
| 153 | 153 | //CHECK: Is there a reason we aren't just doing this in updateByID? |
| 154 | 154 | $this->db->set('last_checked', 'CURRENT_TIMESTAMP', FALSE) |
| 155 | - ->where('id', $row->title_id) |
|
| 156 | - ->update('tracker_titles'); |
|
| 155 | + ->where('id', $row->title_id) |
|
| 156 | + ->update('tracker_titles'); |
|
| 157 | 157 | |
| 158 | 158 | print " - ({$titleData['latest_chapter']})\n"; |
| 159 | 159 | } else { |
@@ -167,8 +167,8 @@ discard block |
||
| 167 | 167 | //Make sure last_checked is always updated on successful run. |
| 168 | 168 | //CHECK: Is there a reason we aren't just doing this in updateByID? |
| 169 | 169 | $this->db->set('last_checked', 'CURRENT_TIMESTAMP', FALSE) |
| 170 | - ->where('id', $row->title_id) |
|
| 171 | - ->update('tracker_titles'); |
|
| 170 | + ->where('id', $row->title_id) |
|
| 171 | + ->update('tracker_titles'); |
|
| 172 | 172 | |
| 173 | 173 | print " - (No chapters found?)\n"; |
| 174 | 174 | } else { |
@@ -191,10 +191,10 @@ discard block |
||
| 191 | 191 | */ |
| 192 | 192 | public function updateCustom() { |
| 193 | 193 | $query = $this->db->select('*') |
| 194 | - ->from('tracker_sites') |
|
| 195 | - ->where('tracker_sites.status', 'enabled') |
|
| 196 | - ->where('tracker_sites.use_custom', 'Y') |
|
| 197 | - ->get(); |
|
| 194 | + ->from('tracker_sites') |
|
| 195 | + ->where('tracker_sites.status', 'enabled') |
|
| 196 | + ->where('tracker_sites.use_custom', 'Y') |
|
| 197 | + ->get(); |
|
| 198 | 198 | |
| 199 | 199 | $sites = $query->result_array(); |
| 200 | 200 | foreach ($sites as $site) { |
@@ -211,8 +211,8 @@ discard block |
||
| 211 | 211 | //Make sure last_checked is always updated on successful run. |
| 212 | 212 | //CHECK: Is there a reason we aren't just doing this in updateByID? |
| 213 | 213 | $this->db->set('last_checked', 'CURRENT_TIMESTAMP', FALSE) |
| 214 | - ->where('id', $titleID) |
|
| 215 | - ->update('tracker_titles'); |
|
| 214 | + ->where('id', $titleID) |
|
| 215 | + ->update('tracker_titles'); |
|
| 216 | 216 | |
| 217 | 217 | print " - ({$titleData['latest_chapter']})\n"; |
| 218 | 218 | } else { |
@@ -241,13 +241,13 @@ discard block |
||
| 241 | 241 | |
| 242 | 242 | public function refollowCustom() { |
| 243 | 243 | $query = $this->db->select('tracker_titles.id, tracker_titles.title_url, tracker_sites.site_class') |
| 244 | - ->from('tracker_titles') |
|
| 245 | - ->join('tracker_sites', 'tracker_sites.id = tracker_titles.site_id', 'left') |
|
| 246 | - ->where('tracker_titles.followed','N') |
|
| 247 | - ->where('tracker_titles !=', '255') |
|
| 248 | - ->where('tracker_sites.status', 'enabled') |
|
| 249 | - ->where('tracker_sites.use_custom', 'Y') |
|
| 250 | - ->get(); |
|
| 244 | + ->from('tracker_titles') |
|
| 245 | + ->join('tracker_sites', 'tracker_sites.id = tracker_titles.site_id', 'left') |
|
| 246 | + ->where('tracker_titles.followed','N') |
|
| 247 | + ->where('tracker_titles !=', '255') |
|
| 248 | + ->where('tracker_sites.status', 'enabled') |
|
| 249 | + ->where('tracker_sites.use_custom', 'Y') |
|
| 250 | + ->get(); |
|
| 251 | 251 | |
| 252 | 252 | if($query->num_rows() > 0) { |
| 253 | 253 | foreach($query->result() as $row) { |
@@ -258,8 +258,8 @@ discard block |
||
| 258 | 258 | |
| 259 | 259 | if(!empty($titleData)) { |
| 260 | 260 | $this->db->set($titleData) |
| 261 | - ->where('id', $row->id) |
|
| 262 | - ->update('tracker_titles'); |
|
| 261 | + ->where('id', $row->id) |
|
| 262 | + ->update('tracker_titles'); |
|
| 263 | 263 | |
| 264 | 264 | print "> {$row->site_class}:{$row->id}:{$row->title_url} FOLLOWED\n"; |
| 265 | 265 | } else { |
@@ -307,8 +307,8 @@ discard block |
||
| 307 | 307 | if($titleData['title'] && is_array($titleData) && !is_null($titleData['latest_chapter'])) { |
| 308 | 308 | if($titleData['title'] !== $row->title) { |
| 309 | 309 | $this->db->set('title', $titleData['title']) |
| 310 | - ->where('id', $row->id) |
|
| 311 | - ->update('tracker_titles'); |
|
| 310 | + ->where('id', $row->id) |
|
| 311 | + ->update('tracker_titles'); |
|
| 312 | 312 | //TODO: Add to history somehow? |
| 313 | 313 | print " - NEW TITLE ({$titleData['title']})\n"; |
| 314 | 314 | } else { |
@@ -318,8 +318,8 @@ discard block |
||
| 318 | 318 | //We might as well try to update as well. |
| 319 | 319 | if($this->Tracker->title->updateByID((int) $row->id, $titleData['latest_chapter'])) { |
| 320 | 320 | $this->db->set('last_checked', 'CURRENT_TIMESTAMP', FALSE) |
| 321 | - ->where('id', $row->id) |
|
| 322 | - ->update('tracker_titles'); |
|
| 321 | + ->where('id', $row->id) |
|
| 322 | + ->update('tracker_titles'); |
|
| 323 | 323 | } |
| 324 | 324 | } else { |
| 325 | 325 | log_message('error', "{$row->title} failed to update title successfully"); |
@@ -335,14 +335,14 @@ discard block |
||
| 335 | 335 | $date = $temp_now->format('Y-m-d'); |
| 336 | 336 | |
| 337 | 337 | $query = $this->db->select('1') |
| 338 | - ->from('site_stats') |
|
| 339 | - ->where('date', $date) |
|
| 340 | - ->get(); |
|
| 338 | + ->from('site_stats') |
|
| 339 | + ->where('date', $date) |
|
| 340 | + ->get(); |
|
| 341 | 341 | |
| 342 | 342 | if($query->num_rows() > 0) { |
| 343 | 343 | $this->db->set('total_requests', 'total_requests+1', FALSE) |
| 344 | - ->where('date', $date) |
|
| 345 | - ->update('site_stats'); |
|
| 344 | + ->where('date', $date) |
|
| 345 | + ->update('site_stats'); |
|
| 346 | 346 | } else { |
| 347 | 347 | $this->db->insert('site_stats', [ |
| 348 | 348 | 'date' => $date, |