mirror of
https://github.com/ad-aures/castopod.git
synced 2026-04-12 19:17:45 +02:00
style(ecs): add easy-coding-standard to enforce coding style rules for php
- update .devcontainer settings: remove auto-formatting for php + set intelephense as default formatter - remove prettier php plugin as it lacks php 8 support - add captain hook action for checking style pre-commit - fix style with ecs on all files except views
This commit is contained in:
parent
fb3593f828
commit
aa1612342e
230 changed files with 3420 additions and 5884 deletions
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Class AnalyticsPodcastModel
|
||||
* Model for analytics_podcasts table in database
|
||||
* Class AnalyticsPodcastModel Model for analytics_podcasts table in database
|
||||
*
|
||||
* @copyright 2020 Podlibre
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
* @link https://castopod.org/
|
||||
|
|
@ -24,6 +24,7 @@ class AnalyticsPodcastModel extends Model
|
|||
* @var string
|
||||
*/
|
||||
protected $returnType = AnalyticsPodcasts::class;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
|
|
@ -41,7 +42,7 @@ class AnalyticsPodcastModel extends Model
|
|||
*/
|
||||
public function getDataByDay(int $podcastId): array
|
||||
{
|
||||
if (!($found = cache("{$podcastId}_analytics_podcast_by_day"))) {
|
||||
if (! ($found = cache("{$podcastId}_analytics_podcast_by_day"))) {
|
||||
$found = $this->select('date as labels, hits as values')
|
||||
->where([
|
||||
'podcast_id' => $podcastId,
|
||||
|
|
@ -50,7 +51,8 @@ class AnalyticsPodcastModel extends Model
|
|||
->orderBy('labels', 'ASC')
|
||||
->findAll();
|
||||
|
||||
cache()->save("{$podcastId}_analytics_podcast_by_day", $found, 600);
|
||||
cache()
|
||||
->save("{$podcastId}_analytics_podcast_by_day", $found, 600);
|
||||
}
|
||||
return $found;
|
||||
}
|
||||
|
|
@ -62,10 +64,8 @@ class AnalyticsPodcastModel extends Model
|
|||
*/
|
||||
public function getDataByWeekday(int $podcastId): array
|
||||
{
|
||||
if (!($found = cache("{$podcastId}_analytics_podcasts_by_weekday"))) {
|
||||
$found = $this->select(
|
||||
'LEFT(DAYNAME(date),3) as labels, WEEKDAY(date) as sort_labels',
|
||||
)
|
||||
if (! ($found = cache("{$podcastId}_analytics_podcasts_by_weekday"))) {
|
||||
$found = $this->select('LEFT(DAYNAME(date),3) as labels, WEEKDAY(date) as sort_labels',)
|
||||
->selectSum('hits', 'values')
|
||||
->where([
|
||||
'podcast_id' => $podcastId,
|
||||
|
|
@ -75,11 +75,8 @@ class AnalyticsPodcastModel extends Model
|
|||
->orderBy('sort_labels', 'ASC')
|
||||
->findAll();
|
||||
|
||||
cache()->save(
|
||||
"{$podcastId}_analytics_podcasts_by_weekday",
|
||||
$found,
|
||||
600,
|
||||
);
|
||||
cache()
|
||||
->save("{$podcastId}_analytics_podcasts_by_weekday", $found, 600,);
|
||||
}
|
||||
return $found;
|
||||
}
|
||||
|
|
@ -91,10 +88,8 @@ class AnalyticsPodcastModel extends Model
|
|||
*/
|
||||
public function getDataBandwidthByDay(int $podcastId): array
|
||||
{
|
||||
if (!($found = cache("{$podcastId}_analytics_podcast_by_bandwidth"))) {
|
||||
$found = $this->select(
|
||||
'date as labels, round(bandwidth / 1048576, 1) as `values`',
|
||||
)
|
||||
if (! ($found = cache("{$podcastId}_analytics_podcast_by_bandwidth"))) {
|
||||
$found = $this->select('date as labels, round(bandwidth / 1048576, 1) as `values`',)
|
||||
->where([
|
||||
'podcast_id' => $podcastId,
|
||||
'date >' => date('Y-m-d', strtotime('-60 days')),
|
||||
|
|
@ -102,11 +97,8 @@ class AnalyticsPodcastModel extends Model
|
|||
->orderBy('labels', 'ASC')
|
||||
->findAll();
|
||||
|
||||
cache()->save(
|
||||
"{$podcastId}_analytics_podcast_by_bandwidth",
|
||||
$found,
|
||||
600,
|
||||
);
|
||||
cache()
|
||||
->save("{$podcastId}_analytics_podcast_by_bandwidth", $found, 600,);
|
||||
}
|
||||
return $found;
|
||||
}
|
||||
|
|
@ -118,7 +110,7 @@ class AnalyticsPodcastModel extends Model
|
|||
*/
|
||||
public function getDataByMonth(int $podcastId): array
|
||||
{
|
||||
if (!($found = cache("{$podcastId}_analytics_podcast_by_month"))) {
|
||||
if (! ($found = cache("{$podcastId}_analytics_podcast_by_month"))) {
|
||||
$found = $this->select('DATE_FORMAT(date,"%Y-%m-01") as labels')
|
||||
->selectSum('hits', 'values')
|
||||
->where([
|
||||
|
|
@ -128,11 +120,8 @@ class AnalyticsPodcastModel extends Model
|
|||
->orderBy('labels', 'ASC')
|
||||
->findAll();
|
||||
|
||||
cache()->save(
|
||||
"{$podcastId}_analytics_podcast_by_month",
|
||||
$found,
|
||||
600,
|
||||
);
|
||||
cache()
|
||||
->save("{$podcastId}_analytics_podcast_by_month", $found, 600,);
|
||||
}
|
||||
return $found;
|
||||
}
|
||||
|
|
@ -145,9 +134,7 @@ class AnalyticsPodcastModel extends Model
|
|||
public function getDataUniqueListenersByDay(int $podcastId): array
|
||||
{
|
||||
if (
|
||||
!($found = cache(
|
||||
"{$podcastId}_analytics_podcast_unique_listeners_by_day",
|
||||
))
|
||||
! ($found = cache("{$podcastId}_analytics_podcast_unique_listeners_by_day",))
|
||||
) {
|
||||
$found = $this->select('date as labels, unique_listeners as values')
|
||||
->where([
|
||||
|
|
@ -157,11 +144,8 @@ class AnalyticsPodcastModel extends Model
|
|||
->orderBy('labels', 'ASC')
|
||||
->findAll();
|
||||
|
||||
cache()->save(
|
||||
"{$podcastId}_analytics_podcast_unique_listeners_by_day",
|
||||
$found,
|
||||
600,
|
||||
);
|
||||
cache()
|
||||
->save("{$podcastId}_analytics_podcast_unique_listeners_by_day", $found, 600,);
|
||||
}
|
||||
return $found;
|
||||
}
|
||||
|
|
@ -174,9 +158,7 @@ class AnalyticsPodcastModel extends Model
|
|||
public function getDataUniqueListenersByMonth(int $podcastId): array
|
||||
{
|
||||
if (
|
||||
!($found = cache(
|
||||
"{$podcastId}_analytics_podcast_unique_listeners_by_month",
|
||||
))
|
||||
! ($found = cache("{$podcastId}_analytics_podcast_unique_listeners_by_month",))
|
||||
) {
|
||||
$found = $this->select('DATE_FORMAT(date,"%Y-%m-01") as labels')
|
||||
->selectSum('unique_listeners', 'values')
|
||||
|
|
@ -187,11 +169,8 @@ class AnalyticsPodcastModel extends Model
|
|||
->orderBy('labels', 'ASC')
|
||||
->findAll();
|
||||
|
||||
cache()->save(
|
||||
"{$podcastId}_analytics_podcast_unique_listeners_by_month",
|
||||
$found,
|
||||
600,
|
||||
);
|
||||
cache()
|
||||
->save("{$podcastId}_analytics_podcast_unique_listeners_by_month", $found, 600,);
|
||||
}
|
||||
return $found;
|
||||
}
|
||||
|
|
@ -204,9 +183,7 @@ class AnalyticsPodcastModel extends Model
|
|||
public function getDataTotalListeningTimeByDay(int $podcastId): array
|
||||
{
|
||||
if (
|
||||
!($found = cache(
|
||||
"{$podcastId}_analytics_podcast_listening_time_by_day",
|
||||
))
|
||||
! ($found = cache("{$podcastId}_analytics_podcast_listening_time_by_day",))
|
||||
) {
|
||||
$found = $this->select('date as labels')
|
||||
->selectSum('duration', 'values')
|
||||
|
|
@ -218,11 +195,8 @@ class AnalyticsPodcastModel extends Model
|
|||
->orderBy('labels', 'ASC')
|
||||
->findAll();
|
||||
|
||||
cache()->save(
|
||||
"{$podcastId}_analytics_podcast_listening_time_by_day",
|
||||
$found,
|
||||
600,
|
||||
);
|
||||
cache()
|
||||
->save("{$podcastId}_analytics_podcast_listening_time_by_day", $found, 600,);
|
||||
}
|
||||
return $found;
|
||||
}
|
||||
|
|
@ -235,9 +209,7 @@ class AnalyticsPodcastModel extends Model
|
|||
public function getDataTotalListeningTimeByMonth(int $podcastId): array
|
||||
{
|
||||
if (
|
||||
!($found = cache(
|
||||
"{$podcastId}_analytics_podcast_listening_time_by_month",
|
||||
))
|
||||
! ($found = cache("{$podcastId}_analytics_podcast_listening_time_by_month",))
|
||||
) {
|
||||
$found = $this->select('DATE_FORMAT(date,"%Y-%m-01") as labels')
|
||||
->selectSum('duration', 'values')
|
||||
|
|
@ -248,11 +220,8 @@ class AnalyticsPodcastModel extends Model
|
|||
->orderBy('labels', 'ASC')
|
||||
->findAll();
|
||||
|
||||
cache()->save(
|
||||
"{$podcastId}_analytics_podcast_listening_time_by_month",
|
||||
$found,
|
||||
600,
|
||||
);
|
||||
cache()
|
||||
->save("{$podcastId}_analytics_podcast_listening_time_by_month", $found, 600,);
|
||||
}
|
||||
return $found;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue