Merge pull request '调整百度统计计算方法' (#391) from KingChan/forgeplus:standalone_develop into standalone_develop

This commit is contained in:
KingChan 2025-06-19 09:49:50 +08:00
commit 14350f6812
2 changed files with 3 additions and 4 deletions

View File

@ -74,8 +74,7 @@ class Admins::DashboardsController < Admins::BaseController
@access_token = tongji_service.access_token
Rails.logger.info "baidu_tongji_auth access_token ===== #{@access_token}"
# @overview_data = tongji_service.api_overview
last_date = DailyPlatformStatistic.order(:date).last || Time.now
start_date = last_date.date
start_date = DailyPlatformStatistic.order(:date).last.try(:date) || Time.now.to_date
end_date = Time.now
if @access_token.present?
@overview_data = Rails.cache.fetch("dashboardscontroller:baidu_tongji:overview_data", expires_in: 10.minutes) do

View File

@ -81,8 +81,8 @@ module Baidu
return [] unless access_token.present? && start_date.present?
source_from_data = api("source/link/a", start_date, start_date, "pv_count")
# 提取链接项和对应的数据项
link_items = source_from_data.dig("result", "items", 0) || []
value_items = source_from_data.dig("result", "items", 1) || []
link_items = source_from_data["items"][0]
value_items = source_from_data["items"][1]
# 目标链接名称
target_name = "http://cn.bing.com"