{% extends "one_column_body.html" %}
{% from "analytics/macros.html" import linked_number_if_positive %}
{% block title %}{% filter trim %}{% trans %}Analytics / Home{% endtrans %}{% endfilter %}{% endblock %}
{% block layout_class %}{{ super() }} analytics-page{% endblock %}
{% block forum_header %}{% endblock %}
{% block content %}
<div class="title-row">
  <h1><a href="{{ url('analytics_index') }}">{% trans %}Analytics{% endtrans %}</a> / {% trans %}Users{% endtrans %} / {% trans %}All Users{% endtrans %}</h1>
  {% include "analytics/date_selector.html" %}
</div>
<div class="analytics-summary">
  <div class="analytics-summary-number">
    <div>{% trans %}All:{% endtrans %} {{ all_users_count }}</div>
    <p>{% trans %}All users{% endtrans %}</p>
  </div>
  <div class="analytics-summary-number">
    <div>
        {{ default_segment_name }}:
        {{ default_segment_data['num_users'] }}
    </div>
    <p>
      {{ default_segment_description }}
    </p>
  </div>
  {% if orgs_enabled %}
    <div class="analytics-summary-number">
      <div>{% trans %}Organizations:{% endtrans %} {{ orgs_count }}</div>
      <p>{% trans %}According to the email domain names{% endtrans %}</p>
    </div>
  {% endif %}
</div>
<table>
  <thead>
    <tr>
      <th>{% trans %}Group/Organization{% endtrans %}</th>
      <th>{% trans %}Num Users{% endtrans %}</th>
      <th>{% trans %}Users Added{% endtrans %}</th>
      <th>{% trans %}Questions{% endtrans %}</th>
      <th>{% trans %}Answers{% endtrans %}</th>
      <th>{% trans %}Upvotes{% endtrans %}</th>
      <th>{% trans %}Downvotes{% endtrans %}</th>
      <th>{% trans %}All Events{% endtrans %}</th>
      <th>{% trans %}Time on Site{% endtrans %}</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>{% trans %}All{% endtrans %}</td>
      <td>
          {{ all_data['num_users'] }}
      </td>
      <td>
        {{ linked_number_if_positive(all_data["num_users_added"],
                                     url('analytics_activity',
                                         dates=dates_url_param,
                                         activity_segment=analytics_activity_field.REGISTERED,
                                         content_segment='all-content',
                                         users_segment='all-users'))
        }}
      </td>
      <td>
        {{ linked_number_if_positive(all_data["num_questions"],
                                     url('analytics_activity',
                                         content_segment='all-content',
                                         activity_segment=analytics_activity_field.QUESTION_POSTED,
                                         dates=dates_url_param,
                                         users_segment='all-users'))
        }}
      </td>
      <td>
        {{ linked_number_if_positive(all_data["num_answers"],
                                     url('analytics_activity',
                                         content_segment='all-content',
                                         activity_segment=analytics_activity_field.ANSWER_POSTED,
                                         dates=dates_url_param,
                                         users_segment='all-users'))
        }}
      </td>
      <td>
        {{ linked_number_if_positive(all_data["num_upvotes"],
                                     url('analytics_activity',
                                         content_segment='all-content',
                                         activity_segment=analytics_activity_field.CONTENT_UPVOTED,
                                         dates=dates_url_param,
                                         users_segment='all-users'))
        }}
      </td>
      <td>
        {{ linked_number_if_positive(all_data["num_downvotes"],
                                     url('analytics_activity',
                                         content_segment='all-content',
                                         activity_segment=analytics_activity_field.CONTENT_DOWNVOTED,
                                         dates=dates_url_param,
                                         users_segment='all-users'))
        }}
      </td>
      <td>
        <a href={{url('analytics_activity', activity_segment='all-activity', content_segment='all-content', users_segment='all-users', dates=dates_url_param)}}>
          {% include "analytics/arrow_right.html" %}
        </a>
      </td>
      <td>
        {{ all_data['time_on_site']|format_time_on_site }}
      </td>
    </tr>
    {% for named_segment_data in named_segments_data %}
    <tr>
      <td><a href="{{ url('analytics_users', dates=dates_url_param, users_segment=named_segment_data['slug']) }}">{{ named_segment_data['name'] }}</a></td>
      <td>{{ named_segment_data['num_users'] }}</td>
      <td>
        {{ linked_number_if_positive(named_segment_data["num_users_added"],
                                     url('analytics_activity',
                                         dates=dates_url_param,
                                         activity_segment=analytics_activity_field.REGISTERED,
                                         content_segment='all-content',
                                         users_segment=named_segment_data['slug']))
        }}
      </td>
      <td>
        {{ linked_number_if_positive(named_segment_data["num_questions"],
                                     url('analytics_activity',
                                         content_segment='all-content',
                                         activity_segment=analytics_activity_field.QUESTION_POSTED,
                                         dates=dates_url_param,
                                         users_segment=named_segment_data['slug']))
        }}
      </td>
      <td>
        {{ linked_number_if_positive(named_segment_data["num_answers"],
                                     url('analytics_activity',
                                         content_segment='all-content',
                                         activity_segment=analytics_activity_field.ANSWER_POSTED,
                                         dates=dates_url_param,
                                         users_segment=named_segment_data['slug']))
        }}
      </td>
      <td>
        {{ linked_number_if_positive(named_segment_data["num_upvotes"],
                                     url('analytics_activity',
                                         content_segment='all-content',
                                         activity_segment=analytics_activity_field.CONTENT_UPVOTED,
                                         dates=dates_url_param,
                                         users_segment=named_segment_data['slug']))
        }}
      </td>
      <td>
        {{ linked_number_if_positive(named_segment_data["num_downvotes"],
                                     url('analytics_activity',
                                         content_segment='all-content',
                                         activity_segment=analytics_activity_field.CONTENT_DOWNVOTED,
                                         dates=dates_url_param,
                                         users_segment=named_segment_data['slug']))
        }}
      </td>
      <td>
        <a href={{url('analytics_activity', activity_segment='all-activity', content_segment='all-content', users_segment=named_segment_data['slug'], dates=dates_url_param)}}>
          {% include "analytics/arrow_right.html" %}
        </a>
      </td>
      <td>
        {{ named_segment_data['time_on_site']|format_time_on_site }}
      </td>
    </tr>
    {% endfor %}
    <tr>
      <td><a href="{{ url('analytics_users', dates=dates_url_param, users_segment=default_segment_data['slug']) }}">{{ default_segment_data['name'] }}</a></td>
      <td>{{ default_segment_data['num_users'] }}</td>
      <td>
        {{ linked_number_if_positive(default_segment_data["num_users_added"],
                                     url('analytics_activity',
                                         dates=dates_url_param,
                                         activity_segment=analytics_activity_field.REGISTERED,
                                         content_segment='all-content',
                                         users_segment=default_segment_data['slug']))
        }}
      </td>
      <td>
        {{ linked_number_if_positive(default_segment_data["num_questions"],
                                     url('analytics_activity',
                                         content_segment='all-content',
                                         activity_segment=analytics_activity_field.QUESTION_POSTED,
                                         dates=dates_url_param,
                                         users_segment=default_segment_data['slug']))
        }}
      </td>
      <td>
        {{ linked_number_if_positive(default_segment_data["num_answers"],
                                     url('analytics_activity',
                                         content_segment='all-content',
                                         activity_segment=analytics_activity_field.ANSWER_POSTED,
                                         dates=dates_url_param,
                                         users_segment=default_segment_data['slug']))
        }}
      </td>
      <td>
        {{ linked_number_if_positive(default_segment_data["num_upvotes"],
                                     url('analytics_activity',
                                         content_segment='all-content',
                                         activity_segment=analytics_activity_field.CONTENT_UPVOTED,
                                         dates=dates_url_param,
                                         users_segment=default_segment_data['slug']))
        }}
      </td>
      <td>
        {{ linked_number_if_positive(default_segment_data["num_downvotes"],
                                     url('analytics_activity',
                                         content_segment='all-content',
                                         activity_segment=analytics_activity_field.CONTENT_DOWNVOTED,
                                         dates=dates_url_param,
                                         users_segment=default_segment_data['slug']))
        }}
      </td>
      <td>
        <a href="{{ url('analytics_activity', activity_segment='all-activity', content_segment='all-content', users_segment=default_segment_data['slug'], dates=dates_url_param) }}">
          {% include "analytics/arrow_right.html" %}
        </a>
      </td>
      <td>
        {{ default_segment_data['time_on_site']|format_time_on_site }}
      </td>
    </tr>
  </tbody>
</table>
{% endblock %}
