Completed
Push — master ( 3a6730...bad5d9 )
by Angus
03:21
created
application/models/Tracker_Model.php 1 patch
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -90,9 +90,9 @@  discard block
 block discarded – undo
90 90
 
91 91
 	public function getSiteDataFromURL(string $site_url) {
92 92
 		$query = $this->db->select('id, site_class')
93
-		                  ->from('tracker_sites')
94
-		                  ->where('site', $site_url)
95
-		                  ->get();
93
+						  ->from('tracker_sites')
94
+						  ->where('site', $site_url)
95
+						  ->get();
96 96
 
97 97
 		if($query->num_rows() > 0) {
98 98
 			$siteData = $query->row();
@@ -103,10 +103,10 @@  discard block
 block discarded – undo
103 103
 
104 104
 	public function getTitleID(string $titleURL, int $siteID) {
105 105
 		$query = $this->db->select('id')
106
-		                  ->from('tracker_titles')
107
-		                  ->where('title_url', $titleURL)
108
-		                  ->where('site_id', $siteID)
109
-		                  ->get();
106
+						  ->from('tracker_titles')
107
+						  ->where('title_url', $titleURL)
108
+						  ->where('site_id', $siteID)
109
+						  ->get();
110 110
 
111 111
 		if($query->num_rows() > 0) {
112 112
 			$titleID = $query->row('id');
@@ -140,9 +140,9 @@  discard block
 block discarded – undo
140 140
 			}
141 141
 			if($this->db->select('*')->where('user_id', $userID)->where('title_id', $titleID)->get('tracker_chapters')->num_rows() > 0) {
142 142
 				$success = $this->db->set(['current_chapter' => $chapter, 'last_updated' => NULL])
143
-				                    ->where('user_id', $userID)
144
-				                    ->where('title_id', $titleID)
145
-				                    ->update('tracker_chapters');
143
+									->where('user_id', $userID)
144
+									->where('title_id', $titleID)
145
+									->update('tracker_chapters');
146 146
 			} else {
147 147
 				$success = $this->db->insert('tracker_chapters', [
148 148
 					'user_id'         => $userID,
@@ -157,31 +157,31 @@  discard block
 block discarded – undo
157 157
 
158 158
 	public function updateTrackerByID(int $userID, int $chapterID, string $chapter) : bool {
159 159
 		$success = $this->db->set(['current_chapter' => $chapter, 'last_updated' => NULL])
160
-		                    ->where('user_id', $userID)
161
-		                    ->where('id', $chapterID)
162
-		                    ->update('tracker_chapters');
160
+							->where('user_id', $userID)
161
+							->where('id', $chapterID)
162
+							->update('tracker_chapters');
163 163
 
164 164
 		return (bool) $success;
165 165
 	}
166 166
 
167 167
 	public function deleteTrackerByID(int $userID, int $chapterID) {
168 168
 		$success = $this->db->where('user_id', $userID)
169
-		                    ->where('id', $chapterID)
170
-		                    ->delete('tracker_chapters');
169
+							->where('id', $chapterID)
170
+							->delete('tracker_chapters');
171 171
 
172 172
 		return (bool) $success;
173 173
 	}
174 174
 	private function updateTitleById(int $id, string $latestChapter) {
175 175
 		//FIXME: Really not too happy with how we're doing history stuff here, it just feels messy.
176 176
 		$query = $this->db->select('latest_chapter, last_updated')
177
-		                  ->from('tracker_titles')
178
-		                  ->where('id', $id)
179
-		                  ->get();
177
+						  ->from('tracker_titles')
178
+						  ->where('id', $id)
179
+						  ->get();
180 180
 		$row = $query->row();
181 181
 
182 182
 		$success = $this->db->set(['latest_chapter' => $latestChapter]) //last_updated gets updated via a trigger if something changes
183
-		                    ->where('id', $id)
184
-		                    ->update('tracker_titles');
183
+							->where('id', $id)
184
+							->update('tracker_titles');
185 185
 
186 186
 		//Update History
187 187
 		$this->History->updateTitleHistory($id, $row->latest_chapter, $row->last_updated);
@@ -190,16 +190,16 @@  discard block
 block discarded – undo
190 190
 	}
191 191
 	private function updateTitleDataById(int $id, array $titleData) {
192 192
 		$success = $this->db->set($titleData)
193
-		                    ->where('id', $id)
194
-		                    ->update('tracker_titles');
193
+							->where('id', $id)
194
+							->update('tracker_titles');
195 195
 
196 196
 		return (bool) $success;
197 197
 	}
198 198
 	private function addTitle(string $titleURL, int $siteID) {
199 199
 		$query = $this->db->select('site, site_class')
200
-		                  ->from('tracker_sites')
201
-		                  ->where('id', $siteID)
202
-		                  ->get();
200
+						  ->from('tracker_sites')
201
+						  ->where('id', $siteID)
202
+						  ->get();
203 203
 
204 204
 		$titleData = $this->sites->{$query->row()->site_class}->getTitleData($titleURL);
205 205
 		$this->db->insert('tracker_titles', array_merge($titleData, ['title_url' => $titleURL, 'site_id' => $siteID]));
@@ -224,18 +224,18 @@  discard block
 block discarded – undo
224 224
 		                      tracker_titles.last_updated,
225 225
 		                      from_unixtime(MAX(auth_users.last_login)) AS timestamp
226 226
 		                  ')
227
-		                  ->from('tracker_titles')
228
-		                  ->join('tracker_sites', 'tracker_sites.id = tracker_titles.site_id', 'left')
229
-		                  ->join('tracker_chapters', 'tracker_titles.id = tracker_chapters.title_id', 'left')
230
-		                  ->join('auth_users', 'tracker_chapters.user_id = auth_users.id', 'left')
231
-		                  ->where('tracker_sites.status = "enabled"')
232
-		                  ->where('(`complete` = "N" AND (`latest_chapter` = NULL OR `last_checked` < DATE_SUB(NOW(), INTERVAL 12 HOUR)))', NULL, FALSE) //TODO: Each title should have specific interval time?
233
-		                  ->or_where('(`complete` = "Y" AND `last_checked` < DATE_SUB(NOW(), INTERVAL 1 WEEK))', NULL, FALSE)
234
-		                  ->group_by('tracker_titles.id')
235
-		                  ->having('timestamp IS NOT NULL')
236
-		                  ->having('timestamp > DATE_SUB(NOW(), INTERVAL 120 HOUR)')
237
-		                  ->order_by('tracker_titles.title', 'ASC')
238
-		                  ->get();
227
+						  ->from('tracker_titles')
228
+						  ->join('tracker_sites', 'tracker_sites.id = tracker_titles.site_id', 'left')
229
+						  ->join('tracker_chapters', 'tracker_titles.id = tracker_chapters.title_id', 'left')
230
+						  ->join('auth_users', 'tracker_chapters.user_id = auth_users.id', 'left')
231
+						  ->where('tracker_sites.status = "enabled"')
232
+						  ->where('(`complete` = "N" AND (`latest_chapter` = NULL OR `last_checked` < DATE_SUB(NOW(), INTERVAL 12 HOUR)))', NULL, FALSE) //TODO: Each title should have specific interval time?
233
+						  ->or_where('(`complete` = "Y" AND `last_checked` < DATE_SUB(NOW(), INTERVAL 1 WEEK))', NULL, FALSE)
234
+						  ->group_by('tracker_titles.id')
235
+						  ->having('timestamp IS NOT NULL')
236
+						  ->having('timestamp > DATE_SUB(NOW(), INTERVAL 120 HOUR)')
237
+						  ->order_by('tracker_titles.title', 'ASC')
238
+						  ->get();
239 239
 
240 240
 		if($query->num_rows() > 0) {
241 241
 			foreach ($query->result() as $row) {
@@ -248,8 +248,8 @@  discard block
 block discarded – undo
248 248
 						//Make sure last_checked is always updated on successful run.
249 249
 						//CHECK: Is there a reason we aren't just doing this in updateTitleById?
250 250
 						$this->db->set('last_checked', 'CURRENT_TIMESTAMP', FALSE)
251
-						         ->where('id', $row->id)
252
-						         ->update('tracker_titles');
251
+								 ->where('id', $row->id)
252
+								 ->update('tracker_titles');
253 253
 
254 254
 						//Update History
255 255
 						$this->History->updateTitleHistory((int) $row->id, $titleData['latest_chapter'], $titleData['last_updated']);
@@ -362,9 +362,9 @@  discard block
 block discarded – undo
362 362
 	}
363 363
 	public function setCategoryTrackerByID(int $userID, int $chapterID, string $category) : bool {
364 364
 		$success = $this->db->set(['category' => $category, 'last_updated' => NULL])
365
-		                    ->where('user_id', $userID)
366
-		                    ->where('id', $chapterID)
367
-		                    ->update('tracker_chapters');
365
+							->where('user_id', $userID)
366
+							->where('id', $chapterID)
367
+							->update('tracker_chapters');
368 368
 
369 369
 		return (bool) $success;
370 370
 	}
@@ -374,9 +374,9 @@  discard block
 block discarded – undo
374 374
 		$success = FALSE;
375 375
 		if(preg_match("/^[a-z0-9-_,]{0,255}$/", $tag_string)) {
376 376
 			$success = $this->db->set(['tags' => $tag_string, 'last_updated' => NULL])
377
-			                    ->where('user_id', $userID)
378
-			                    ->where('id', $chapterID)
379
-			                    ->update('tracker_chapters');
377
+								->where('user_id', $userID)
378
+								->where('id', $chapterID)
379
+								->update('tracker_chapters');
380 380
 		}
381 381
 
382 382
 		return (bool) $success;
@@ -386,9 +386,9 @@  discard block
 block discarded – undo
386 386
 		$usedCategories = [];
387 387
 
388 388
 		$query = $this->db->distinct()
389
-		                  ->select('category')
390
-		                  ->from('tracker_chapters')
391
-		                  ->get();
389
+						  ->select('category')
390
+						  ->from('tracker_chapters')
391
+						  ->get();
392 392
 
393 393
 		return array_column($query->result_array(), 'category');
394 394
 	}
Please login to merge, or discard this patch.
application/models/History_Model.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -24,9 +24,9 @@
 block discarded – undo
24 24
 
25 25
 	public function getCurrentChapter(int $titleID) : string {
26 26
 		$query = $this->db->select('latest_chapter')
27
-		                  ->from('tracker_titles')
28
-		                  ->where('id', $titleID)
29
-		                  ->get();
27
+						  ->from('tracker_titles')
28
+						  ->where('id', $titleID)
29
+						  ->get();
30 30
 
31 31
 		return $query->row()->latest_chapter;
32 32
 	}
Please login to merge, or discard this patch.