<div>
  <h2>Statistics</h2>
  <table width="100%" class="user-statistics">
    <tbody>
      <tr>
        <th>Join Date</th>
        <td><%= presenter.join_date %></td>
      </tr>

      <tr>
        <th>Inviter</th>
        <td><%= presenter.inviter(self) %></td>
      </tr>

      <tr>
        <th>Level</th>
        <td><%= presenter.level %></td>
      </tr>

      <tr>
        <th>Permissions</th>
        <td><%= presenter.permissions %></td>
      </tr>

      <% if user.is_banned? && user.recent_ban %>
        <tr>
          <th>Ban reason</th>
          <td><%= format_text presenter.ban_reason %></td>
        </tr>
      <% end %>

      <tr>
        <th>Upload Limit</th>
        <td><%= presenter.upload_limit(self) %> (<%= link_to "help", wiki_pages_path(title: "about:upload_limits") %>)</td>
      </tr>

      <tr>
        <th>Uploads</th>
        <td>
          <%= presenter.upload_count(self) %>
          <% if presenter.has_uploads? %>
            [<%= link_to "tag changes report", reports_upload_tags_path(user_id: user.id) %>]
          <% end %>
          <% if CurrentUser.is_moderator? %>
            [<%= link_to "sample", posts_path(:tags => "user:#{user.name} order:random limit:300") %>]
          <% end %>
        </td>
      </tr>

      <tr>
        <th>Deleted Uploads</th>
        <td>
          <%= presenter.deleted_upload_count(self) %>
          <% if CurrentUser.is_moderator? %>
            [<%= link_to "sample", posts_path(:tags => "user:#{user.name} order:random limit:300 status:deleted") %>]
          <% end %>

        </td>
      </tr>

      <tr>
        <th>Favorites</th>
        <td>
          <%= presenter.favorite_count(self) %>
          <% if CurrentUser.is_moderator? %>
            [<%= link_to "sample", posts_path(:tags => "fav:#{user.name} order:random limit:300") %>]
          <% end %>
        </td>
      </tr>

      <tr>
        <th>Favorite Groups</th>
        <td><%= presenter.favorite_group_count(self) %></td>
      </tr>

      <tr>
        <th>Post Changes</th>
        <td>
          <%= presenter.post_version_count(self) %>
          <% if CurrentUser.is_moderator? && UserRevert.can_revert?(user)%>
            [<%= link_to "revert all", new_user_revert_path(user_id: user.id) %>]
          <% end %>
        </td>
      </tr>

      <tr>
        <th>Note Changes</th>
        <td><%= presenter.note_version_count(self) %> in <%= presenter.noted_posts_count(self) %> posts</td>
      </tr>

      <tr>
        <th>Wiki Page Changes</th>
        <td><%= presenter.wiki_page_version_count(self) %></td>
      </tr>

      <tr>
        <th>Artist Changes</th>
        <td><%= presenter.artist_version_count(self) %></td>
      </tr>

      <tr>
        <th>Commentary Changes</th>
        <td><%= presenter.artist_commentary_version_count(self) %></td>
      </tr>

      <% if PoolArchive.enabled? %>
        <tr>
          <th>Pool Changes</th>
          <td><%= presenter.pool_version_count(self) %></td>
        </tr>
      <% end %>

      <tr>
        <th>Forum Posts</th>
        <td><%= presenter.forum_post_count(self) %></td>
      </tr>

      <tr>
        <th>Approvals</th>
        <td><%= presenter.approval_count(self) %></td>
      </tr>

      <tr>
        <th>Comments</th>
        <td><%= presenter.comment_count(self) %> in <%= presenter.commented_posts_count(self) %> posts</td>
      </tr>

      <% if CurrentUser.user.id == user.id || CurrentUser.is_moderator? %>
        <tr>
          <th>Appeals</th>
          <td><%= presenter.appeal_count(self) %></td>
        </tr>

        <tr>
          <th>Flags</th>
          <td><%= presenter.flag_count(self) %></td>
        </tr>
      <% end %>

      <tr>
        <th>Feedback</th>
        <td><%= presenter.feedbacks(self) %></td>    </tbody>
      </tr>
      
      <% if presenter.previous_names(self).present? %>
        <tr>
          <th>Previous Names</th>
          <td><%= presenter.previous_names(self) %></td>
        </tr>
      <% end %>

      <% if CurrentUser.id == user.id %>
        <% if CurrentUser.has_saved_searches? %>
          <tr>
            <th>Saved Searches</th>
            <td>
              <% SavedSearch.labels_for(CurrentUser.user.id).each do |label| %>
                <%= link_to label, posts_path(tags: "search:#{label}") %>
              <% end %>
            </td>
          </tr>
        <% end %>

        <tr>
          <th>Subscriptions</th>
          <td>
            <em>This feature has been disabled. <%= link_to "Migrate your tag subscriptions to saved searches", tag_subscriptions_path %>.</em>
          </td>
        </tr>

        <tr>
          <th>API Key</th>
          <td>
            <%= link_to (CurrentUser.api_key ? "View" : "Generate"), user_api_key_path(CurrentUser.user) %>
            (<%= link_to "help", wiki_pages_path(title: "help:api") %>)
          </td>
        </tr>

        <tr>
          <th>API Limits</th>
          <td>
            <%= CurrentUser.user.remaining_api_limit %>
            / <%= CurrentUser.user.api_burst_limit %> <span class="hint">(may not be up to date)</span>
          </td>
        </tr>
      <% end %>
  </table>
</div>
