8d5ec411f1
参考受控版本分布的饼图实现,新增国家维度分布: - AnalyticsDailyDim 增加 KIND_VISIT_COUNTRY / KIND_DEVICE_COUNTRY 常量 - AnalyticsReportService::aggregateDay() 按 country 聚合访问 UV 与受控设备数 - present() 汇总并返回 by_visit_country / by_device_country(ISO 代码转中文名展示) - 视图新增两个国家饼图卡片与两个国家明细标签区 性能与正确性修复: - ensureCached() 改为一次查询校验所有按日聚合 kind 的缓存完整性, 避免旧缓存完整时新维度不被聚合的问题 - 新增迁移为 page_visits / devices 建立 (created_at, country) 复合索引, 对齐 os_version 维度的索引做法,加速按日期范围 + GROUP BY country 的聚合
54 lines
1.1 KiB
PHP
54 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class AnalyticsDailyDim extends Model
|
|
{
|
|
public $timestamps = false;
|
|
|
|
public const KIND_VISIT_OS = 'visit_os';
|
|
|
|
public const KIND_VISIT_VERSION = 'visit_version';
|
|
|
|
public const KIND_DEVICE_VERSION = 'device_version';
|
|
|
|
public const KIND_VISIT_COUNTRY = 'visit_country';
|
|
|
|
public const KIND_DEVICE_COUNTRY = 'device_country';
|
|
|
|
public const KIND_SURVIVAL = 'survival';
|
|
|
|
public const KIND_SURVIVAL_WALLET = 'survival_wallet';
|
|
|
|
public const DIM_IOS = 'iOS';
|
|
|
|
public const DIM_OTHER = '其他';
|
|
|
|
public const DIM_UNKNOWN = '未知';
|
|
|
|
protected $fillable = [
|
|
'stat_date',
|
|
'scope_key',
|
|
'kind',
|
|
'dim',
|
|
'uv',
|
|
'effective_uv',
|
|
'devices',
|
|
'seconds_sum',
|
|
'computed_at',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'uv' => 'integer',
|
|
'effective_uv' => 'integer',
|
|
'devices' => 'integer',
|
|
'seconds_sum' => 'integer',
|
|
'computed_at' => 'datetime',
|
|
];
|
|
}
|
|
}
|