@@ -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 | } |
@@ -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 | } |
@@ -74,8 +74,8 @@ discard block |
||
74 | 74 | //Make sure last_checked is always updated on successful run. |
75 | 75 | //CHECK: Is there a reason we aren't just doing this in updateByID? |
76 | 76 | $this->db->set('last_checked', 'CURRENT_TIMESTAMP', FALSE) |
77 | - ->where('id', $row->title_id) |
|
78 | - ->update('tracker_titles'); |
|
77 | + ->where('id', $row->title_id) |
|
78 | + ->update('tracker_titles'); |
|
79 | 79 | |
80 | 80 | print " - ({$titleData['latest_chapter']})\n"; |
81 | 81 | } else { |
@@ -99,10 +99,10 @@ discard block |
||
99 | 99 | */ |
100 | 100 | public function updateCustom() { |
101 | 101 | $query = $this->db->select('*') |
102 | - ->from('tracker_sites') |
|
103 | - ->where('status', 'enabled') |
|
104 | - ->where('tracker_sites.use_custom', 'Y') |
|
105 | - ->get(); |
|
102 | + ->from('tracker_sites') |
|
103 | + ->where('status', 'enabled') |
|
104 | + ->where('tracker_sites.use_custom', 'Y') |
|
105 | + ->get(); |
|
106 | 106 | |
107 | 107 | $sites = $query->result_array(); |
108 | 108 | foreach ($sites as $site) { |
@@ -117,8 +117,8 @@ discard block |
||
117 | 117 | //Make sure last_checked is always updated on successful run. |
118 | 118 | //CHECK: Is there a reason we aren't just doing this in updateByID? |
119 | 119 | $this->db->set('last_checked', 'CURRENT_TIMESTAMP', FALSE) |
120 | - ->where('id', $titleID) |
|
121 | - ->update('tracker_titles'); |
|
120 | + ->where('id', $titleID) |
|
121 | + ->update('tracker_titles'); |
|
122 | 122 | |
123 | 123 | print " - ({$titleData['latest_chapter']})\n"; |
124 | 124 | } else { |
@@ -142,13 +142,13 @@ discard block |
||
142 | 142 | |
143 | 143 | public function refollowCustom() { |
144 | 144 | $query = $this->db->select('tracker_titles.id, tracker_titles.title_url, tracker_sites.site_class') |
145 | - ->from('tracker_titles') |
|
146 | - ->join('tracker_sites', 'tracker_sites.id = tracker_titles.site_id', 'left') |
|
147 | - ->where('tracker_titles.followed','N') |
|
148 | - ->where('tracker_titles !=', '255') |
|
149 | - ->where('tracker_sites.status', 'enabled') |
|
150 | - ->where('tracker_sites.use_custom', 'Y') |
|
151 | - ->get(); |
|
145 | + ->from('tracker_titles') |
|
146 | + ->join('tracker_sites', 'tracker_sites.id = tracker_titles.site_id', 'left') |
|
147 | + ->where('tracker_titles.followed','N') |
|
148 | + ->where('tracker_titles !=', '255') |
|
149 | + ->where('tracker_sites.status', 'enabled') |
|
150 | + ->where('tracker_sites.use_custom', 'Y') |
|
151 | + ->get(); |
|
152 | 152 | |
153 | 153 | if($query->num_rows() > 0) { |
154 | 154 | foreach($query->result() as $row) { |
@@ -159,8 +159,8 @@ discard block |
||
159 | 159 | |
160 | 160 | if(!empty($titleData)) { |
161 | 161 | $this->db->set($titleData) |
162 | - ->where('id', $row->id) |
|
163 | - ->update('tracker_titles'); |
|
162 | + ->where('id', $row->id) |
|
163 | + ->update('tracker_titles'); |
|
164 | 164 | |
165 | 165 | print "> {$row->site_class}:{$row->id}:{$row->title_url} FOLLOWED\n"; |
166 | 166 | } else { |
@@ -208,8 +208,8 @@ discard block |
||
208 | 208 | if($titleData['title'] && is_array($titleData) && !is_null($titleData['latest_chapter'])) { |
209 | 209 | if($titleData['title'] !== $row->title) { |
210 | 210 | $this->db->set('title', $titleData['title']) |
211 | - ->where('id', $row->id) |
|
212 | - ->update('tracker_titles'); |
|
211 | + ->where('id', $row->id) |
|
212 | + ->update('tracker_titles'); |
|
213 | 213 | //TODO: Add to history somehow? |
214 | 214 | print " - NEW TITLE ({$titleData['title']})\n"; |
215 | 215 | } else { |
@@ -219,8 +219,8 @@ discard block |
||
219 | 219 | //We might as well try to update as well. |
220 | 220 | if($this->Tracker->title->updateByID((int) $row->id, $titleData['latest_chapter'])) { |
221 | 221 | $this->db->set('last_checked', 'CURRENT_TIMESTAMP', FALSE) |
222 | - ->where('id', $row->id) |
|
223 | - ->update('tracker_titles'); |
|
222 | + ->where('id', $row->id) |
|
223 | + ->update('tracker_titles'); |
|
224 | 224 | } |
225 | 225 | } else { |
226 | 226 | log_message('error', "{$row->title} failed to update title successfully"); |
@@ -71,32 +71,32 @@ |
||
71 | 71 | |
72 | 72 | ////We need the series to be tracked |
73 | 73 | $idCQuery = $this->db->select('id') |
74 | - ->where('user_id', $userID) |
|
75 | - ->where('title_id', $titleID) |
|
76 | - ->get('tracker_chapters'); |
|
74 | + ->where('user_id', $userID) |
|
75 | + ->where('title_id', $titleID) |
|
76 | + ->get('tracker_chapters'); |
|
77 | 77 | if(!($idCQuery->num_rows() > 0)) { |
78 | 78 | //NOTE: This pretty much repeats a lot of what we already did above. Is there a better way to do this? |
79 | 79 | $this->Tracker->list->update($userID, $site, $title, $chapter, FALSE); |
80 | 80 | |
81 | 81 | $idCQuery = $this->db->select('id') |
82 | - ->where('user_id', $userID) |
|
83 | - ->where('title_id', $titleID) |
|
84 | - ->get('tracker_chapters'); |
|
82 | + ->where('user_id', $userID) |
|
83 | + ->where('title_id', $titleID) |
|
84 | + ->get('tracker_chapters'); |
|
85 | 85 | } |
86 | 86 | if($idCQuery->num_rows() > 0) { |
87 | 87 | $idCQueryRow = $idCQuery->row(); |
88 | 88 | |
89 | 89 | //Check if it is already favourited |
90 | 90 | $idFQuery = $this->db->select('id') |
91 | - ->where('chapter_id', $idCQueryRow->id) |
|
92 | - ->where('chapter', $chapter) |
|
93 | - ->get('tracker_favourites'); |
|
91 | + ->where('chapter_id', $idCQueryRow->id) |
|
92 | + ->where('chapter', $chapter) |
|
93 | + ->get('tracker_favourites'); |
|
94 | 94 | if($idFQuery->num_rows() > 0) { |
95 | 95 | //Chapter is already favourited, so remove it from DB |
96 | 96 | $idFQueryRow = $idFQuery->row(); |
97 | 97 | |
98 | 98 | $isSuccess = (bool) $this->db->where('id', $idFQueryRow->id) |
99 | - ->delete('tracker_favourites'); |
|
99 | + ->delete('tracker_favourites'); |
|
100 | 100 | |
101 | 101 | if($isSuccess) { |
102 | 102 | $success = array( |