Completed
Push — master ( cc7fc1...a5df07 )
by Angus
02:51
created

AdminCLI::testSite()   B

Complexity

Conditions 5
Paths 5

Size

Total Lines 23
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 30

Importance

Changes 0
Metric Value
cc 5
eloc 17
nc 5
nop 3
dl 0
loc 23
ccs 0
cts 17
cp 0
crap 30
rs 8.5906
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
		print "Environment: ".ENVIRONMENT."\n";
34
		$this->Tracker->admin->updateLatestChapters();
35
	}
36
37
	/**
38
	 * Used to check for, and update titles with new chapters from a site following list.
39
	 * Called via: public/index.php admin/update_series_custom
40
	 *
41
	 * This is called via a cron job every hour.
42
	 * Series will always be updated if they can be. For more info see: https://github.com/DakuTree/manga-tracker/issues/78
43
	 * FIXME: The entire implementation of this is an utter mess.
44
	 **/
45
	public function updateSeriesCustom() {
46
		$this->Tracker->admin->updateCustom();
47
	}
48
49
	public function refollowCustom() {
50
		$this->Tracker->admin->refollowCustom();
51
	}
52
53
	public function testSite($type, $site, $extra = NULL) {
54
		print "Testing site\n";
55
		switch($type) {
56
			case 'update':
57
				if(!is_null($extra )) {
58
					print_r($this->Tracker->sites->{$site}->getTitleData($extra));
59
				}
60
				break;
61
62
			case 'custom_update':
63
				print_r($this->Tracker->sites->{$site}->doCustomUpdate());
64
				break;
65
66
			case 'force_update':
67
				print_r($this->Tracker->admin->updateAllTitlesBySite($site, $extra));
68
				break;
69
70
			default:
71
				print "Missing parameters.";
72
				break;
73
		}
74
		print "\n";
75
	}
76
}
77