后台概览增加缓存,增加上周统计数据

This commit is contained in:
2024-01-22 12:57:04 +08:00
parent 9ef255f3b6
commit f98c044715
2 changed files with 67 additions and 22 deletions

View File

@@ -15,6 +15,19 @@
</tr>
</thead>
<tbody>
<% if @current_week_statistic.size ==1 && @pre_week_statistic.present? %>
<tr class="">
<td>上周合计</td>
<td><%= @pre_week_statistic.map(&:pv).sum %></td>
<td><%= @pre_week_statistic.map(&:visitor).sum %></td>
<td><%= @pre_week_statistic.map(&:ip).sum %></td>
<td><%= (@pre_week_statistic.map(&:source_through).sum.to_f / 7).round(2) %></td>
<td><%= (@pre_week_statistic.map(&:source_link).sum.to_f / 7).round(2) %></td>
<td><%= (@pre_week_statistic.map(&:source_search).sum.to_f / 7).round(2) %></td>
<td><%= ((@pre_week_statistic.map(&:source_custom) - [nil]).sum.to_f / 7).round(2) %></td>
</td>
</tr>
<% end %>
<% @current_week_statistic.each_with_index do |week, index| %>
<tr class="">
<td><%= week.date %> </td>
@@ -28,13 +41,18 @@
</td>
</tr>
<% end %>
<!-- <tr class="">-->
<!-- <td><span style="color: #ff8200">合计</span></td>-->
<!-- <td><span style="color: #ff8200"><%#= @current_week_statistic.sum(:pv) %></span></td>-->
<!-- <td><span style="color: #ff8200"><%#= @current_week_statistic.sum(:visitor) %></span></td>-->
<!-- <td><span style="color: #ff8200"><%#= @current_week_statistic.sum(:ip) %></span></td>-->
<!-- </td>-->
<!-- </tr>-->
<tr class="">
<% current_week_size = @current_week_statistic.size %>
<td><span style="color: #ff8200">本周合计</span></td>
<td><span style="color: #ff8200"><%= @current_week_statistic.map(&:pv).sum %></span></td>
<td><span style="color: #ff8200"><%= @current_week_statistic.map(&:visitor).sum %></span></td>
<td><span style="color: #ff8200"><%= @current_week_statistic.map(&:ip).sum %></span></td>
<td><span style="color: #ff8200"><%= (@current_week_statistic.map(&:source_through).sum.to_f / current_week_size).round(2) %>%</span></td>
<td><span style="color: #ff8200"><%= (@current_week_statistic.map(&:source_link).sum.to_f / current_week_size).round(2) %>%</span></td>
<td><span style="color: #ff8200"><%= (@current_week_statistic.map(&:source_search).sum.to_f / current_week_size).round(2) %>%</span></td>
<td><span style="color: #ff8200"><%= ((@current_week_statistic.map(&:source_custom) - [nil]).sum.to_f / current_week_size).round(2) %>%</span></td>
</td>
</tr>
</tbody>
</table>