Version 5.1 - All the GraphQL #32

Closed
timw4mail wants to merge 1160 commits from develop into master
6 changed files with 41 additions and 13 deletions
Showing only changes of commit d3541da789 - Show all commits

4
.scrutinizer.yml Normal file
View File

@ -0,0 +1,4 @@
# .scrutinizer.yml
tools:
external_code_coverage:
timeout: 600 # Timeout in seconds.

View File

@ -8,6 +8,7 @@
<property name="phploc" value="phploc"/> <property name="phploc" value="phploc"/>
<property name="phpmd" value="phpmd"/> <property name="phpmd" value="phpmd"/>
<property name="phpunit" value="phpunit"/> <property name="phpunit" value="phpunit"/>
<property name="sonar" value="sonar-runner"/>
<!-- Use this when the tools are located as PHARs in ${basedir}/build/tools <!-- Use this when the tools are located as PHARs in ${basedir}/build/tools
<property name="pdepend" value="${basedir}/build/tools/pdepend.phar"/> <property name="pdepend" value="${basedir}/build/tools/pdepend.phar"/>
@ -28,7 +29,7 @@
<property name="phpunit" value="${basedir}/vendor/bin/phpunit"/> --> <property name="phpunit" value="${basedir}/vendor/bin/phpunit"/> -->
<target name="full-build" <target name="full-build"
depends="prepare,static-analysis,phpunit,phpdox,-check-failure" depends="prepare,static-analysis,phpunit,phpdox,sonar,-check-failure"
description="Performs static analysis, runs the tests, and generates project documentation"/> description="Performs static analysis, runs the tests, and generates project documentation"/>
<target name="full-build-parallel" <target name="full-build-parallel"
@ -231,6 +232,12 @@
<property name="phpdox.done" value="true"/> <property name="phpdox.done" value="true"/>
</target> </target>
<target name="sonar"
depends="phpunit">
<exec executable="${sonar}" taskname="sonar"/>
<property name="sonar.done" value="true"/>
</target>
<target name="-check-failure"> <target name="-check-failure">
<fail message="PHPUnit did not finish successfully"> <fail message="PHPUnit did not finish successfully">
<condition> <condition>

View File

@ -2,3 +2,5 @@ sonar.projectKey=animeclient
sonar.projectName=Anime Client sonar.projectName=Anime Client
sonar.projectVersion=1.0 sonar.projectVersion=1.0
sonar.sources=src sonar.sources=src
sonar.php.coverage.overallReportPath=build/logs/clover.xml
sonar.php.tests.reportPath=build/logs/junit.xml

View File

@ -94,8 +94,7 @@ class API extends BaseModel {
} }
array_unshift($args, strtoupper($method)); array_unshift($args, strtoupper($method));
$response = call_user_func_array([$this->client, 'request'], $args); return call_user_func_array([$this->client, 'request'], $args);
return $response;
} }
/** /**

View File

@ -75,7 +75,10 @@ class AnimeCollection extends DB {
->join('genres g', 'g.id=gl.genre_id', 'left'); ->join('genres g', 'g.id=gl.genre_id', 'left');
if ( ! empty($filter)) $this->db->where_in('hummingbird_id', $filter); if ( ! empty($filter))
{
$this->db->where_in('hummingbird_id', $filter);
}
$query = $this->db->order_by('hummingbird_id') $query = $this->db->order_by('hummingbird_id')
->order_by('genre') ->order_by('genre')
@ -89,8 +92,10 @@ class AnimeCollection extends DB {
$genre = $row['genre']; $genre = $row['genre'];
// Empty genre names aren't useful // Empty genre names aren't useful
if (empty($genre)) continue; if (empty($genre))
{
continue;
}
if (array_key_exists($id, $output)) if (array_key_exists($id, $output))
{ {
@ -174,7 +179,10 @@ class AnimeCollection extends DB {
*/ */
private function _get_collection() private function _get_collection()
{ {
if ( ! $this->valid_database) return []; if ( ! $this->valid_database)
{
return [];
}
$query = $this->db->select('hummingbird_id, slug, title, alternate_title, show_type, $query = $this->db->select('hummingbird_id, slug, title, alternate_title, show_type,
age_rating, episode_count, episode_length, cover_image, notes, media.type as media') age_rating, episode_count, episode_length, cover_image, notes, media.type as media')
@ -225,7 +233,10 @@ class AnimeCollection extends DB {
public function update($data) public function update($data)
{ {
// If there's no id to update, don't update // If there's no id to update, don't update
if ( ! array_key_exists('hummingbird_id', $data)) return; if ( ! array_key_exists('hummingbird_id', $data))
{
return;
}
$id = $data['hummingbird_id']; $id = $data['hummingbird_id'];
unset($data['hummingbird_id']); unset($data['hummingbird_id']);
@ -257,8 +268,10 @@ class AnimeCollection extends DB {
*/ */
private function json_import() private function json_import()
{ {
if ( ! file_exists('import.json')) return; if ( ! file_exists('import.json') || ! $this->valid_database)
if ( ! $this->valid_database) return; {
return;
}
$anime = json_decode(file_get_contents("import.json")); $anime = json_decode(file_get_contents("import.json"));

View File

@ -66,7 +66,7 @@ class Manga extends API {
{ {
$data = $this->_get_list_from_api(); $data = $this->_get_list_from_api();
foreach ($data as $key => &$val) foreach ($data as &$val)
{ {
$this->sort_by_name($val); $this->sort_by_name($val);
} }
@ -121,7 +121,10 @@ class Manga extends API {
{ {
// Bail out early if there isn't any manga data // Bail out early if there isn't any manga data
$api_data = json_decode($response->getBody(), TRUE); $api_data = json_decode($response->getBody(), TRUE);
if ( ! array_key_exists('manga', $api_data)) return []; if ( ! array_key_exists('manga', $api_data))
{
return [];
}
$cache_file = _dir($this->config->get('data_cache_path'), 'manga.json'); $cache_file = _dir($this->config->get('data_cache_path'), 'manga.json');
$transformed_cache_file = _dir($this->config->get('data_cache_path'), 'manga-transformed.json'); $transformed_cache_file = _dir($this->config->get('data_cache_path'), 'manga-transformed.json');