refactor: add rector to enforce type declarations, code quality + style and remove dead code

- update CI process to include quality stage (tests + code review)
- add captainhook to install git pre-commit & pre-push hooks
- remove .devcontainer Dockerfile to use project's docker-compose services: all
services can now be started automatically using vscode
- update docs/setup-development.md
This commit is contained in:
Yassine Doghri 2021-05-06 14:00:48 +00:00
commit 5c5c6da4be
No known key found for this signature in database
GPG key ID: 3E7F89498B960C9F
302 changed files with 9802 additions and 4674 deletions

View file

@ -10,32 +10,41 @@
namespace Analytics\Models;
use Analytics\Entities\AnalyticsWebsiteByEntryPage;
use CodeIgniter\Model;
class AnalyticsWebsiteByEntryPageModel extends Model
{
/**
* @var string
*/
protected $table = 'analytics_website_by_entry_page';
protected $allowedFields = [];
protected $returnType = \Analytics\Entities\AnalyticsWebsiteByEntryPage::class;
/**
* @var string
*/
protected $returnType = AnalyticsWebsiteByEntryPage::class;
/**
* @var bool
*/
protected $useSoftDeletes = false;
/**
* @var bool
*/
protected $useTimestamps = false;
/**
* Gets entry pages data for a podcast
*
* @param int $podcastId
*
* @return array
* @return AnalyticsWebsiteByEntryPage[]
*/
public function getData(int $podcastId): array
{
if (!($found = cache("{$podcastId}_analytics_website_by_entry_page"))) {
$oneWeekAgo = date('Y-m-d', strtotime('-1 week'));
$found = $this->select(
'IF(entry_page_url=\'/\',\'/\',SUBSTRING_INDEX(entry_page_url,\'/\',-1)) as labels',
"IF(entry_page_url='/','/',SUBSTRING_INDEX(entry_page_url,'/',-1)) as labels",
)
->selectSum('hits', 'values')
->where([