<div class="mb-6 mt-2">
  <h3 class="text-lg leading-6 font-medium text-gray-900">
    基本信息
  </h3>
  <div class="mt-5 grid grid-cols-1 gap-5 sm:grid-cols-3">
    <div class="bg-white overflow-hidden shadow rounded-lg">
      <div class="px-4 py-5 sm:p-6">
        <dl>
          <dt class="text-sm leading-5 font-medium text-gray-500 truncate">
            文章数量
          </dt>
          <dd class="mt-1 text-3xl leading-9 font-semibold text-gray-900">
            <%= Article.count %>
          </dd>
        </dl>
      </div>
    </div>
    <div class="bg-white overflow-hidden shadow rounded-lg">
      <div class="px-4 py-5 sm:p-6">
        <dl>
          <dt class="text-sm leading-5 font-medium text-gray-500 truncate">
            用户数量
          </dt>
          <dd class="mt-1 text-3xl leading-9 font-semibold text-gray-900">
            <%= User.count %>
          </dd>
        </dl>
      </div>
    </div>

    <div class="bg-white overflow-hidden shadow rounded-lg">
      <div class="px-4 py-5 sm:p-6">
        <dl>
          <dt class="text-sm leading-5 font-medium text-gray-500 truncate">
            标签数量
          </dt>
          <dd class="mt-1 text-3xl leading-9 font-semibold text-gray-900">
            <%= Tag.count %>
          </dd>
        </dl>
      </div>
    </div>

    <div class="bg-white overflow-hidden shadow rounded-lg">
      <div class="px-4 py-5 sm:p-6">
        <dl>
          <dt class="text-sm leading-5 font-medium text-gray-500 truncate">
            本日新增
          </dt>
          <dd class="mt-1 text-3xl leading-9 font-semibold text-gray-900">
            <%= Article.current_day.count %>
          </dd>
        </dl>
      </div>
    </div>

    <div class="bg-white overflow-hidden shadow rounded-lg">
      <div class="px-4 py-5 sm:p-6">
        <dl>
          <dt class="text-sm leading-5 font-medium text-gray-500 truncate">
            本周新增
          </dt>
          <dd class="mt-1 text-3xl leading-9 font-semibold text-gray-900">
            <%= Article.current_week.count %>
          </dd>
        </dl>
      </div>
    </div>

    <div class="bg-white overflow-hidden shadow rounded-lg">
      <div class="px-4 py-5 sm:p-6">
        <dl>
          <dt class="text-sm leading-5 font-medium text-gray-500 truncate">
            本月新增
          </dt>
          <dd class="mt-1 text-3xl leading-9 font-semibold text-gray-900">
            <%= Article.current_month.count %>
          </dd>
        </dl>
      </div>
    </div>

  </div>
</div>

<div class="mb-6 mt-2">
  
  <div class="w-full sm:flex items-center">
    <h3 class="text-lg leading-6 font-medium text-gray-900">
      浏览统计
    </h3>
    <%= render partial: 'date_filter' %>
  </div>
  <div class="mt-5 grid grid-cols-1 gap-5 sm:grid-cols-3">
    <div class="bg-white overflow-hidden shadow rounded-lg">
      <div class="px-4 py-5 sm:p-6">
        <dl>
          <dt class="text-sm leading-5 font-medium text-gray-500 truncate">
            浏览量
          </dt>
          <dd class="mt-1 text-3xl leading-9 font-semibold text-gray-900">
            <%=pretty_num @page_view_count %>
          </dd>
        </dl>
      </div>
    </div>
    <div class="bg-white overflow-hidden shadow rounded-lg">
      <div class="px-4 py-5 sm:p-6">
        <dl>
          <dt class="text-sm leading-5 font-medium text-gray-500 truncate">
            平均浏览时长
          </dt>
          <dd class="mt-1 text-3xl leading-9 font-semibold text-gray-900">
            <%=pretty_time @avg_time %>
          </dd>
        </dl>
      </div>
    </div>


    <div class="bg-white overflow-hidden shadow rounded-lg">
      <div class="px-4 py-5 sm:p-6">
        <dl>
          <dt class="text-sm leading-5 font-medium text-gray-500 truncate">
            文章浏览量
          </dt>
          <dd class="mt-1 text-3xl leading-9 font-semibold text-gray-900">
            <%= pretty_num @article_page_view_count %>
          </dd>
        </dl>
      </div>
    </div>

    <div class="bg-white overflow-hidden shadow rounded-lg">
      <div class="px-4 py-5 sm:p-6">
        <dl>
          <dt class="text-sm leading-5 font-medium text-gray-500 truncate">
            搜索量
          </dt>
          <dd class="mt-1 text-3xl leading-9 font-semibold text-gray-900">
            <%=pretty_num @search_count %>
          </dd>
        </dl>
      </div>
    </div>

    <div class="bg-white overflow-hidden shadow rounded-lg">
      <div class="px-4 py-5 sm:p-6">
        <dl>
          <dt class="text-sm leading-5 font-medium text-gray-500 truncate">
            搜索浏览
          </dt>
          <dd class="mt-1 text-3xl leading-9 font-semibold text-gray-900">
            <%= pretty_num @search_view_count %>
          </dd>
        </dl>
      </div>
    </div>

    <div class="bg-white overflow-hidden shadow rounded-lg">
      <div class="px-4 py-5 sm:p-6">
        <dl>
          <dt class="text-sm leading-5 font-medium text-gray-500 truncate">
            有用数量
          </dt>
          <dd class="mt-1 text-3xl leading-9 font-semibold text-gray-900">
            <%= pretty_num @useful_count %>
          </dd>
        </dl>
      </div>
    </div>

    

  </div>
</div>

<div class="mb-6 mt-2">
  <h3 class="text-lg leading-6 font-medium text-gray-900">
    搜索关键词
  </h3>
  <!-- This example requires Tailwind CSS v2.0+ -->
  <div class="mt-4 flex flex-col">
    <div class="-my-2 overflow-x-auto sm:-mx-6 lg:-mx-8">
      <div class="py-2 align-middle inline-block min-w-full sm:px-6 lg:px-8">
        <div class="shadow overflow-hidden border-b border-gray-200 sm:rounded-lg">
          <table class="min-w-full divide-y divide-gray-200">
            <thead class="bg-gray-50">
              <tr>
                <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                  搜索
                </th>
                <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                  数量
                </th>
              </tr>
            </thead>
            <tbody class="bg-white divide-y divide-gray-200">
              <% Event.where(event_name: 'view_search_results').where("json_extract(event_props, '$.search_term') is not null").select("JSON_UNQUOTE(json_extract(event_props, '$.search_term')) as keyword, count(*) as count").group("1").order("2 desc").each do |event|  %>
                <tr>
                  <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">
                    <%= event.keyword %>
                  </td>
                  <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
                    <%= event.count %>
                  </td>
      
                </tr>
              <% end %>

              <!-- More people... -->
            </tbody>
          </table>
        </div>
      </div>
    </div>
  </div>
</div>

<div class="mb-6 mt-2">
  <h3 class="text-lg leading-6 font-medium text-gray-900">
    浏览量Top 10
  </h3>
  <!-- This example requires Tailwind CSS v2.0+ -->
  <div class="mt-4 flex flex-col">
    <div class="-my-2 overflow-x-auto sm:-mx-6 lg:-mx-8">
      <div class="py-2 align-middle inline-block min-w-full sm:px-6 lg:px-8">
        <div class="shadow overflow-hidden border-b border-gray-200 sm:rounded-lg">
          <table class="min-w-full divide-y divide-gray-200">
            <thead class="bg-gray-50">
              <tr>
                <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                  标题
                </th>
                <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                  浏览量
                </th>
              </tr>
            </thead>
            <tbody class="bg-white divide-y divide-gray-200">
              <% Event.where(event_name: 'page_view').where("path regexp '/articles/[0-9]+$' or path regexp '/en/articles/[0-9]+$'").group("location_url, title").select("location_url, title, count(*) as count").order("3 desc").limit(10).each do |event|  %>
                <tr>
                  <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">
                    <%= link_to event.title, event.location_url, class: 'text-blue-500' %>
                  </td>
                  <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
                    <%= event.count %>
                  </td>
      
                </tr>
              <% end %>

              <!-- More people... -->
            </tbody>
          </table>
        </div>
      </div>
    </div>
  </div>
</div>

<div class="mb-6 mt-2">
  <h3 class="text-lg leading-6 font-medium text-gray-900">
    新用户
  </h3>
  <ul class="my-2 lg:my-4 text-center grid grid-cols-4 gap-4 lg:grid-cols-8 lg:gap-8" data-target='bookmarks.list'>
    <% User.order(id: :desc).limit(24).each do |user| %>
      <li>
        <div class="space-y-2">
          <%= lavatar_tag(user.letter_char, 16, title: user.username, class: "w-12 h-12 mx-auto rounded-full lg:w-20 lg:h-20") %>
          <div class="text-xs leading-4 font-medium lg:text-sm lg:leading-5">
            <h4><%= user.username %></h4>
          </div>
        </div>
      </li>
    <% end %>
  </ul>
</div>
