Browse Source

是否开启百度统计

pull/347/head
xxq250 2 years ago
parent
commit
1ed41b93d8
2 changed files with 19 additions and 17 deletions
  1. +17
    -17
      app/controllers/admins/dashboards_controller.rb
  2. +2
    -0
      app/views/admins/dashboards/index.html.erb

+ 17
- 17
app/controllers/admins/dashboards_controller.rb View File

@@ -69,25 +69,25 @@ class Admins::DashboardsController < Admins::BaseController
@subject_icon = ["fa-user","fa-git", "fa-sitemap", "fa-warning", "fa-comments", "fa-share-alt", "fa-upload"]
@subject_data = [@user_count, @project_count, @organization_count, @issue_count, @comment_count, @pr_count, @commit_count]


tongji_service = Baidu::TongjiService.new
@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
start_date = last_date.date
end_date = Time.now
if @access_token.present?
@overview_data = Rails.cache.fetch("dashboardscontroller:baidu_tongji:overview_data", expires_in: 10.minutes) do
tongji_service.source_from_batch_add(start_date, end_date)
@overview_data = tongji_service.overview_batch_add(start_date, end_date)
@overview_data
if EduSetting.get("open_baidu_tongji").to_s == "true"
tongji_service = Baidu::TongjiService.new
@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
end_date = Time.now
if @access_token.present?
@overview_data = Rails.cache.fetch("dashboardscontroller:baidu_tongji:overview_data", expires_in: 10.minutes) do
tongji_service.source_from_batch_add(start_date, end_date)
@overview_data = tongji_service.overview_batch_add(start_date, end_date)
@overview_data
end
end
end

@current_week_statistic = DailyPlatformStatistic.where(date: current_week)
@pre_week_statistic = DailyPlatformStatistic.where(date: pre_week)

@current_week_statistic = DailyPlatformStatistic.where(date: current_week)
@pre_week_statistic = DailyPlatformStatistic.where(date: pre_week)
end


end


+ 2
- 0
app/views/admins/dashboards/index.html.erb View File

@@ -85,7 +85,9 @@
</tr>
</tbody>
</table>
<% if EduSetting.get("open_baidu_tongji").to_s == "true" %>
<%= render partial: 'admins/dashboards/baidu_tongji' %>
<% end %>
</div>
<div id="project-language-modals">
</div>

Loading…
Cancel
Save