Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
DariusIII committed Feb 1, 2019
2 parents 029ce0b + 3ebac32 commit abd0085
Show file tree
Hide file tree
Showing 213 changed files with 16,877 additions and 18,496 deletions.
32 changes: 32 additions & 0 deletions .php-cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
/**
* Config for PHP-CS-Fixer ver2
*/
$rules = [
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'no_multiline_whitespace_before_semicolons' => true,
'no_short_echo_tag' => true,
'no_unused_imports' => true,
'not_operator_with_successor_space' => true,
'ordered_imports' => ['sortAlgorithm' => 'alpha'],
];
$excludes = [
// add exclude project directory
'vendor',
'resources',
'tests',
'storage',
'docs',
'public',
'bootstrap',
];
return PhpCsFixer\Config::create()
->setRules($rules)
->setFinder(
PhpCsFixer\Finder::create()
->exclude($excludes)
->in(__DIR__)
->name('*.php')
->notName('*.blade.php')
);
17 changes: 7 additions & 10 deletions .php-cs.dist
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ $rules = [
'no_short_echo_tag' => true,
'no_unused_imports' => true,
'not_operator_with_successor_space' => true,
'ordered_imports' => ['sortAlgorithm' => 'alpha'],
];
$excludes = [
// add exclude project directory
Expand All @@ -18,19 +19,15 @@ $excludes = [
'tests',
'storage',
'docs',
'public/themes',
'libs',
'bootstrap/cache'
'public',
'bootstrap',
];
return PhpCsFixer\Config::create()
->setRules($rules)
->setFinder(
PhpCsFixer\Finder::create()
->exclude($excludes)
->notName('README.md')
->notName('*.xml')
->notName('*.yml')
->notName('*.tsv')
->notName('*.sql')
->in(__DIR__)
);
->in(__DIR__)
->name('*.php')
->notName('*.blade.php')
);
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
public/
vendor/
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"printWidth": 100,
"singleQuote": true,
"tabWidth": 4,
"trailingComma": "es5"
}
4 changes: 2 additions & 2 deletions .styleci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ finder:
- "storage"
- "vendor"
- "docs"
- "public/themes"
- "libs"
- "public"
- "resources"
- "bootstrap"
- "database/migrations"
- "database/seeds"
- "database/fixtures"
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ before_install:
- sudo apt-get -qq update
- sudo apt-get install -y libsodium-dev
- pecl install libsodium
- mysql_upgrade -u root
- composer validate

install:
Expand Down
7 changes: 4 additions & 3 deletions Blacklight/Backfill.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Models\Group;
use App\Models\Settings;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\DB;

/**
Expand Down Expand Up @@ -93,7 +94,7 @@ public function __construct(array $options = [])
$this->colorCli = new ColorCLI();

$this->_compressedHeaders = (int) Settings::settingValue('..compressedheaders') === 1;
$this->_safeBackFillDate = Settings::settingValue('..safebackfilldate') !== '' ? (string) Settings::settingValue('safebackfilldate') : '2008-08-14';
$this->_safeBackFillDate = Settings::settingValue('..safebackfilldate') !== '' ? (string) Settings::settingValue('safebackfilldate') : '2012-08-14';
$this->_safePartRepair = (int) Settings::settingValue('..safepartrepair') === 1 ? 'update' : 'backfill';
$this->_disableBackfillGroup = (int) Settings::settingValue('..disablebackfillgroup') === 1;
}
Expand Down Expand Up @@ -334,9 +335,9 @@ public function backfillGroup($groupArr, $left, $articles = ''): void
public function safeBackfill($articles = ''): void
{
$groupname = Group::query()
->whereBetween('first_record_postdate', [$this->_safeBackFillDate, now()])
->whereBetween('first_record_postdate', [Carbon::createFromDate($this->_safeBackFillDate), now()])
->where('backfill', '=', 1)
->select('name')
->select(['name'])
->orderBy('name')
->first();

Expand Down
29 changes: 21 additions & 8 deletions Blacklight/Binaries.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Models\Group;
use App\Models\Settings;
use App\Models\Collection;
use Illuminate\Support\Str;
use Illuminate\Support\Carbon;
use App\Models\BinaryBlacklist;
use Illuminate\Support\Facades\DB;
Expand Down Expand Up @@ -278,7 +279,7 @@ public function updateAllGroups($maxHeaders = 100000): void
}

$this->log(
'Updating completed in '.str_plural(' second', now()->diffInSeconds($allTime)),
'Updating completed in '.Str::plural(' second', now()->diffInSeconds($allTime)),
__FUNCTION__,
'primary'
);
Expand Down Expand Up @@ -513,7 +514,7 @@ public function updateGroup($groupMySQL, $maxHeaders = 0): void
if ($this->_echoCLI) {
$this->colorCli->primary(
PHP_EOL.'Group '.$groupMySQL['name'].' processed in '.
str_plural(' second', now()->diffInSeconds($startGroup))
Str::plural(' second', now()->diffInSeconds($startGroup))
);
}
} elseif ($this->_echoCLI) {
Expand Down Expand Up @@ -711,7 +712,9 @@ public function scan($groupMySQL, $first, $last, $type = 'update', $missingParts
'warning'
);

Log::warning($notInsertedCount.' articles failed to insert!');
if (config('app.debug') === true) {
Log::warning($notInsertedCount.' articles failed to insert!');
}
}
unset($this->headersNotInserted);

Expand Down Expand Up @@ -837,7 +840,9 @@ protected function storeHeaders(array $headers = []): void
$collectionID = $this->_pdo->lastInsertId();
DB::commit();
} catch (\Throwable $e) {
Log::error($e->getMessage());
if (config('app.debug') === true) {
Log::error($e->getMessage());
}
DB::rollBack();
}

Expand Down Expand Up @@ -867,7 +872,9 @@ protected function storeHeaders(array $headers = []): void
$binaryID = $this->_pdo->lastInsertId();
DB::commit();
} catch (\Throwable $e) {
Log::error($e->getMessage());
if (config('app.debug') === true) {
Log::error($e->getMessage());
}
DB::rollBack();
}

Expand Down Expand Up @@ -1605,13 +1612,19 @@ protected function runQuery($query)
try {
return DB::insert($query);
} catch (QueryException $e) {
Log::error($e->getMessage());
if (config('app.debug') === true) {
Log::error($e->getMessage());
}
$this->colorCli->debug('Query error occurred.');
} catch (\PDOException $e) {
Log::error($e->getMessage());
if (config('app.debug') === true) {
Log::error($e->getMessage());
}
$this->colorCli->debug('Query error occurred.');
} catch (\Throwable $e) {
Log::error($e->getMessage());
if (config('app.debug') === true) {
Log::error($e->getMessage());
}
$this->colorCli->debug('Query error occurred.');
}

Expand Down
26 changes: 7 additions & 19 deletions Blacklight/Console.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ public function getConsoleRange($page, $cat, $start, $num, $orderBy, array $excl
}
$return = DB::select($sql);
if (\count($return) > 0) {
$return[0]->_totalcount = $consoles[0]->total ?? 0;
$return[0]->_totalcount = $consoles['total'][0]->total ?? 0;
}
$expiresAt = now()->addMinutes(config('nntmux.cache_expiry_long'));
Cache::put(md5($sql.$page), $return, $expiresAt);
Expand Down Expand Up @@ -337,28 +337,16 @@ public function getBrowseBy(): string
* @param $releasedate
* @param $esrb
* @param $cover
* @param $genreID
* @param $genres_id
* @param string $review
*/
public function update($id, $title, $asin, $url, $salesrank, $platform, $publisher, $releasedate, $esrb, $cover, $genreID, $review = 'review'): void
public function update($id, $title, $asin, $url, $salesrank, $platform, $publisher, $releasedate, $esrb, $cover, $genres_id, $review = 'review'): void
{
$releasedate = $releasedate !== '' ? $releasedate : 'null';
$review = $review === 'review' ? $review : substr($review, 0, 3000);
ConsoleInfo::query()
->where('id', $id)
->update(
[
'title' => $title,
'asin' => $asin,
'url' => $url,
'salesrank' => $salesrank,
'platform' => $platform,
'publisher' => $publisher,
'releasedate' => $releasedate !== '' ? $releasedate : 'null',
'esrb' => $esrb,
'cover' => $cover,
'genres_id' => $genreID,
'review' => $review === 'review' ? $review : substr($review, 0, 3000),
]
);
->update(compact('title', 'asin', 'url', 'salesrank', 'platform', 'publisher', 'releasedate', 'esrb', 'cover', 'genres_id', 'review'));
}

/**
Expand All @@ -383,7 +371,7 @@ public function updateConsoleInfo($gameInfo)
$con['substr'] = $gameInfo['title'];
}

if ($this->_matchConToGameInfo($gameInfo, $con) === true) {
if ($this->_matchConToGameInfo($gameInfo, $con)) {
$con += $this->_setConAfterMatch($amaz);
$con += $this->_matchGenre($amaz);

Expand Down
3 changes: 2 additions & 1 deletion Blacklight/Contents.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Models\User;
use App\Models\Content;
use Illuminate\Support\Arr;

/**
* Class Contents.
Expand Down Expand Up @@ -143,7 +144,7 @@ public function getByID($id, $role)
return false;
}

return array_first($row);
return Arr::first($row);
}

/**
Expand Down
12 changes: 6 additions & 6 deletions Blacklight/CouchPotato.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ public function sendToCouchPotato($id)
$this->imdbid = $id;

return (new Client(['verify' => false]))->get(
$this->cpurl.
'/api/'.
$this->cpapi.
'/movie.add/?identifier=tt'.
$this->imdbid
$this->cpurl.
'/api/'.
$this->cpapi.
'/movie.add/?identifier=tt'.
$this->imdbid

)->getBody()->getContents();
)->getBody()->getContents();
}
}
3 changes: 2 additions & 1 deletion Blacklight/Genres.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Models\Genre;
use App\Models\Category;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Cache;

Expand Down Expand Up @@ -123,7 +124,7 @@ public function getRange($type = '', $activeOnly = false, $start, $num): array
$sql = $this->getListQuery($type, $activeOnly);
$sql .= ' LIMIT '.$num.' OFFSET '.$start;

return (array) array_first(DB::select($sql));
return (array) Arr::first(DB::select($sql));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Blacklight/IRCScraper.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ protected function _checkForDupe()
*/
protected function _insertNewPre()
{
$sphinxData = $this->sphinxsearch->searchIndexes($this->_curPre['title'], ['title'], 'predb_rt');
$sphinxData = $this->sphinxsearch->searchIndexes('predb_rt', $this->_curPre['title'], ['title']);
if (! empty($sphinxData) || empty($this->_curPre['title'])) {
return;
}
Expand Down
5 changes: 3 additions & 2 deletions Blacklight/Movie.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use App\Models\Category;
use App\Models\Settings;
use App\Models\MovieInfo;
use Illuminate\Support\Arr;
use Illuminate\Support\Carbon;
use Tmdb\Laravel\Facades\Tmdb;
use Blacklight\utility\Utility;
Expand Down Expand Up @@ -830,7 +831,7 @@ public function fetchTMDBProperties($imdbId, $text = false)
} else {
$ret['rating'] = '';
}
$actors = array_pluck($tmdbLookup['credits']['cast'], 'name');
$actors = Arr::pluck($tmdbLookup['credits']['cast'], 'name');
if (! empty($actors)) {
$ret['actors'] = $actors;
} else {
Expand Down Expand Up @@ -907,7 +908,7 @@ public function fetchIMDBProperties($imdbId)
$ret = [
'title' => $result->orig_title(),
'tagline' => $result->tagline(),
'plot' => array_get($result->plot_split(), '0.plot'),
'plot' => Arr::get($result->plot_split(), '0.plot'),
'rating' => ! empty($result->rating()) ? $result->rating() : '',
'year' => $result->year(),
'cover' => $result->photo(),
Expand Down
Loading

0 comments on commit abd0085

Please sign in to comment.