Completed
Pull Request — master (#182)
by
unknown
02:44
created

AdminCLI::testSite()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 18
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
cc 4
eloc 13
nc 4
nop 3
dl 0
loc 18
ccs 0
cts 12
cp 0
crap 20
rs 9.2
c 0
b 0
f 0
1
<?php defined('BASEPATH') OR exit('No direct script access allowed');
2
3
class AdminCLI extends CLI_Controller {
4 1
	public function __construct() {
5 1
		parent::__construct();
6 1
	}
7
8
	public function index() {
9
		print "ERROR: This is an invalid route";
10
	}
11
12
	/**
13
	 * Used to update the site migration version.
14
	 * Called via public/index.php admin/migrate
15
	 */
16 1
	public function migrate() {
17 1
		$this->load->library('migration');
18
19 1
		if(!$this->migration->current()) {
0 ignored issues
show
Bug introduced by
The method current() does not seem to exist on object<CI_Migration>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
20
			show_error($this->migration->error_string());
0 ignored issues
show
Bug introduced by
The method error_string() does not seem to exist on object<CI_Migration>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
21
		}
22
		//TODO: Expand on this - http://avenir.ro/the-migrations-in-codeigniter-or-how-to-have-a-git-for-your-database/
23 1
	}
24
25
	/**
26
	 * Used to check for, and update series with new chapters.
27
	 * Called via: public/index.php admin/update_series
28
	 *
29
	 * This is called via a cron job every 6 hours.
30
	 * Series are only checked if they haven't been updated in 16+ hours (unless they are marked as complete, to which they are only checked once a week).
31
	 */
32
	public function updateSeries() {
33
		$this->Tracker->admin->updateLatestChapters();
34
	}
35
36
	/**
37
	 * Used to check for, and update titles with new chapters from a site following list.
38
	 * Called via: public/index.php admin/update_series_custom
39
	 *
40
	 * This is called via a cron job every hour.
41
	 * Series will always be updated if they can be. For more info see: https://github.com/DakuTree/manga-tracker/issues/78
42
	 * FIXME: The entire implementation of this is an utter mess.
43
	 **/
44
	public function updateSeriesCustom() {
45
		$this->Tracker->admin->updateCustom();
46
	}
47
48
	/**
49
	 * Checks every series to see if title has changed, and update if so.
50
	 * Called via: public/index.php admin/update_titles
51
	 *
52
	 * This is called via a cron job once a month.
53
	 **/
54
	public function updateTitles() {
55
		$this->Tracker->admin->updateTitles();
56
	}
57
58
	public function refollowCustom() {
59
		$this->Tracker->admin->refollowCustom();
60
	}
61
62
	public function testSite($type, $site, $title = NULL) {
63
		switch($type) {
64
			case 'update':
65
				if(!is_null($title)) {
66
					print_r($this->Tracker->sites->{$site}->getTitleData($title));
67
				}
68
				break;
69
70
			case 'custom_update':
71
				print_r($this->Tracker->sites->{$site}->doCustomUpdate());
72
				break;
73
74
			default:
75
				print "Missing parameters.";
76
				break;
77
		}
78
		print "\n";
79
	}
80
}
81