Completed
Push — master ( 6612f8...4145fd )
by Angus
04:09
created
application/models/Tracker_Model.php 1 patch
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -91,9 +91,9 @@  discard block
 block discarded – undo
91 91
 
92 92
 	public function getSiteDataFromURL(string $site_url) {
93 93
 		$query = $this->db->select('id, site_class')
94
-		                  ->from('tracker_sites')
95
-		                  ->where('site', $site_url)
96
-		                  ->get();
94
+						  ->from('tracker_sites')
95
+						  ->where('site', $site_url)
96
+						  ->get();
97 97
 
98 98
 		if($query->num_rows() > 0) {
99 99
 			$siteData = $query->row();
@@ -104,10 +104,10 @@  discard block
 block discarded – undo
104 104
 
105 105
 	public function getTitleID(string $titleURL, int $siteID) {
106 106
 		$query = $this->db->select('id')
107
-		                  ->from('tracker_titles')
108
-		                  ->where('title_url', $titleURL)
109
-		                  ->where('site_id', $siteID)
110
-		                  ->get();
107
+						  ->from('tracker_titles')
108
+						  ->where('title_url', $titleURL)
109
+						  ->where('site_id', $siteID)
110
+						  ->get();
111 111
 
112 112
 		if($query->num_rows() > 0) {
113 113
 			$titleID = $query->row('id');
@@ -141,14 +141,14 @@  discard block
 block discarded – undo
141 141
 			}
142 142
 
143 143
 			$idQuery = $this->db->select('id')
144
-			                    ->where('user_id', $userID)
145
-			                    ->where('title_id', $titleID)
146
-			                    ->get('tracker_chapters');
144
+								->where('user_id', $userID)
145
+								->where('title_id', $titleID)
146
+								->get('tracker_chapters');
147 147
 			if($idQuery->num_rows() > 0) {
148 148
 				$success = (bool) $this->db->set(['current_chapter' => $chapter, 'active' => 'Y', 'last_updated' => NULL])
149
-				                    ->where('user_id', $userID)
150
-				                    ->where('title_id', $titleID)
151
-				                    ->update('tracker_chapters');
149
+									->where('user_id', $userID)
150
+									->where('title_id', $titleID)
151
+									->update('tracker_chapters');
152 152
 
153 153
 				if($success) {
154 154
 					$idQueryRow = $idQuery->row();
@@ -173,9 +173,9 @@  discard block
 block discarded – undo
173 173
 
174 174
 	public function updateTrackerByID(int $userID, int $chapterID, string $chapter) : bool {
175 175
 		$success = (bool) $this->db->set(['current_chapter' => $chapter, 'active' => 'Y', 'last_updated' => NULL])
176
-		                    ->where('user_id', $userID)
177
-		                    ->where('id', $chapterID)
178
-		                    ->update('tracker_chapters');
176
+							->where('user_id', $userID)
177
+							->where('id', $chapterID)
178
+							->update('tracker_chapters');
179 179
 
180 180
 		if($success) {
181 181
 			$this->History->userUpdateTitle($chapterID, $chapter);
@@ -188,23 +188,23 @@  discard block
 block discarded – undo
188 188
 		//This is to allow user history to function properly.
189 189
 
190 190
 		$success = $this->db->set(['active' => 'N', 'last_updated' => NULL])
191
-		                    ->where('user_id', $userID)
192
-		                    ->where('id', $chapterID)
193
-		                    ->update('tracker_chapters');
191
+							->where('user_id', $userID)
192
+							->where('id', $chapterID)
193
+							->update('tracker_chapters');
194 194
 
195 195
 		return (bool) $success;
196 196
 	}
197 197
 	private function updateTitleById(int $id, string $latestChapter) {
198 198
 		//FIXME: Really not too happy with how we're doing history stuff here, it just feels messy.
199 199
 		$query = $this->db->select('latest_chapter AS current_chapter')
200
-		                  ->from('tracker_titles')
201
-		                  ->where('id', $id)
202
-		                  ->get();
200
+						  ->from('tracker_titles')
201
+						  ->where('id', $id)
202
+						  ->get();
203 203
 		$row = $query->row();
204 204
 
205 205
 		$success = $this->db->set(['latest_chapter' => $latestChapter]) //last_updated gets updated via a trigger if something changes
206
-		                    ->where('id', $id)
207
-		                    ->update('tracker_titles');
206
+							->where('id', $id)
207
+							->update('tracker_titles');
208 208
 
209 209
 		//Update History
210 210
 		//NOTE: To avoid doing another query to grab the last_updated time, we just use time() which <should> get the same thing.
@@ -215,16 +215,16 @@  discard block
 block discarded – undo
215 215
 	}
216 216
 	private function updateTitleDataById(int $id, array $titleData) {
217 217
 		$success = $this->db->set($titleData)
218
-		                    ->where('id', $id)
219
-		                    ->update('tracker_titles');
218
+							->where('id', $id)
219
+							->update('tracker_titles');
220 220
 
221 221
 		return (bool) $success;
222 222
 	}
223 223
 	private function addTitle(string $titleURL, int $siteID) {
224 224
 		$query = $this->db->select('site, site_class')
225
-		                  ->from('tracker_sites')
226
-		                  ->where('id', $siteID)
227
-		                  ->get();
225
+						  ->from('tracker_sites')
226
+						  ->where('id', $siteID)
227
+						  ->get();
228 228
 
229 229
 		$titleData = $this->sites->{$query->row()->site_class}->getTitleData($titleURL);
230 230
 		$this->db->insert('tracker_titles', array_merge($titleData, ['title_url' => $titleURL, 'site_id' => $siteID]));
@@ -275,8 +275,8 @@  discard block
 block discarded – undo
275 275
 						//Make sure last_checked is always updated on successful run.
276 276
 						//CHECK: Is there a reason we aren't just doing this in updateTitleById?
277 277
 						$this->db->set('last_checked', 'CURRENT_TIMESTAMP', FALSE)
278
-						         ->where('id', $row->id)
279
-						         ->update('tracker_titles');
278
+								 ->where('id', $row->id)
279
+								 ->update('tracker_titles');
280 280
 
281 281
 						print " - ({$titleData['latest_chapter']})\n";
282 282
 					}
@@ -393,9 +393,9 @@  discard block
 block discarded – undo
393 393
 	}
394 394
 	public function setCategoryTrackerByID(int $userID, int $chapterID, string $category) : bool {
395 395
 		$success = $this->db->set(['category' => $category, 'active' => 'Y', 'last_updated' => NULL])
396
-		                    ->where('user_id', $userID)
397
-		                    ->where('id', $chapterID)
398
-		                    ->update('tracker_chapters');
396
+							->where('user_id', $userID)
397
+							->where('id', $chapterID)
398
+							->update('tracker_chapters');
399 399
 
400 400
 		return (bool) $success;
401 401
 	}
@@ -405,9 +405,9 @@  discard block
 block discarded – undo
405 405
 		$success = FALSE;
406 406
 		if(preg_match("/^[a-z0-9-_,]{0,255}$/", $tag_string)) {
407 407
 			$success = (bool) $this->db->set(['tags' => $tag_string, 'active' => 'Y', 'last_updated' => NULL])
408
-			                           ->where('user_id', $userID)
409
-			                           ->where('id', $chapterID)
410
-			                           ->update('tracker_chapters');
408
+									   ->where('user_id', $userID)
409
+									   ->where('id', $chapterID)
410
+									   ->update('tracker_chapters');
411 411
 		}
412 412
 
413 413
 		if($success) {
@@ -445,23 +445,23 @@  discard block
 block discarded – undo
445 445
 
446 446
 			//We need the series to be tracked
447 447
 			$idCQuery = $this->db->select('id')
448
-			                    ->where('user_id', $userID)
449
-			                    ->where('title_id', $titleID)
450
-			                    ->get('tracker_chapters');
448
+								->where('user_id', $userID)
449
+								->where('title_id', $titleID)
450
+								->get('tracker_chapters');
451 451
 			if($idCQuery->num_rows() > 0) {
452 452
 				$idCQueryRow = $idCQuery->row();
453 453
 
454 454
 				//Check if it is already favourited
455 455
 				$idFQuery = $this->db->select('id')
456
-				                    ->where('chapter_id', $idCQueryRow->id)
457
-				                    ->where('chapter', $chapter)
458
-				                    ->get('tracker_favourites');
456
+									->where('chapter_id', $idCQueryRow->id)
457
+									->where('chapter', $chapter)
458
+									->get('tracker_favourites');
459 459
 				if($idFQuery->num_rows() > 0) {
460 460
 					//Chapter is already favourited, so remove it from DB
461 461
 					$idFQueryRow = $idFQuery->row();
462 462
 
463 463
 					$isSuccess = (bool) $this->db->where('id', $idFQueryRow->id)
464
-					                           ->delete('tracker_favourites');
464
+											   ->delete('tracker_favourites');
465 465
 
466 466
 					if($isSuccess) {
467 467
 						$success = array(
@@ -534,10 +534,10 @@  discard block
 block discarded – undo
534 534
 		$usedCategories = [];
535 535
 
536 536
 		$query = $this->db->distinct()
537
-		                  ->select('category')
538
-		                  ->from('tracker_chapters')
539
-		                  ->where('tracker_chapters.active', 'Y')
540
-		                  ->get();
537
+						  ->select('category')
538
+						  ->from('tracker_chapters')
539
+						  ->where('tracker_chapters.active', 'Y')
540
+						  ->get();
541 541
 
542 542
 		return array_column($query->result_array(), 'category');
543 543
 	}
Please login to merge, or discard this patch.