<commit_before>{% from "macros/datetime.jinja" import insert_timeago with context %}
{% from "macros/links.jinja" import user_link, club_link %}


{% macro render_events_table(events) -%}
<table class="table table-events">
  <tbody>
    {% for event in events -%}
    {{ render_event_row(event) }}
    {%- endfor %}
  </tbody>
</table>
{%- endmacro %}


{% macro render_event_row(event) -%}
<tr>
  <td class="icon">
    {{ render_event_icon(event) }}
  </td>
  <td>
    <p>
      {% if event.unread %}<span class="badge badge-warning">{{ _('New') }}</span>{% endif %}
      <small>{{ insert_timeago(event.time) }}</small>
    </p>
    <p>
    {{ render_event_text(event) }}
    </p>
    <p>
    {% if event.grouped -%}
      {% for event in event.subevents -%}
        <small>
          {% if event.unread %}<span class="badge badge-warning badge-empty"></span>{% endif %}
          {{ render_event_text(event) }}
          <a href="{{ event_link(event) }}"><i class="icon-circle-arrow-right"></i></a>
        </small>
        <br/>
      {%- endfor %}
    {%- endif %}
    </p>
  </td>
  <td class="show">
    {{ _render_show_button(event_link(event)) }}
  </td>
</tr>
{%- endmacro %}


{% macro render_event_icon(event) -%}
{% if event.type == types.FLIGHT_COMMENT -%}
  <i class="icon-comments-alt"></i>
{%- elif event.type == types.FLIGHT %}
  <i class="icon-plane"></i>
{%- elif event.type == types.FOLLOWER %}
  <i class="icon-user"></i>
{%- elif event.type == types.NEW_USER %}
  <i class="icon-asterisk small"></i>
{%- elif event.type == types.CLUB_JOIN %}
  <i class="icon-group small"></i>
{%- endif %}&nbsp;
{%- endmacro %}


{% macro render_event_text(event) -%}
{% if event.grouped -%}
  {% if event.type == types.FLIGHT -%}
    {{ render_grouped_flights_event_text(event) }}
  {%- elif event.type == types.FOLLOWER -%}
    {{ render_grouped_followers_event_text(event) }}
  {%- else %}
    Error: Unknown event group
  {%- endif %}
{%- else %}
  {% if event.type == types.FLIGHT_COMMENT -%}
    {{ render_flight_comment_event_text(event) }}
  {%- elif event.type == types.FLIGHT %}
    {{ render_flight_event_text(event) }}
  {%- elif event.type == types.FOLLOWER %}
    {{ render_follower_event_text(event) }}
  {%- elif event.type == types.NEW_USER %}
    {{ render_new_user_event_text(event) }}
  {%- elif event.type == types.CLUB_JOIN %}
    {{ render_club_join_event_text(event) }}
  {%- else %}
    Error: Unknown event
  {%- endif %}
{%- endif %}
{%- endmacro %}


{% macro render_flight_comment_event_text(event) -%}
{% if g.current_user and (event.flight.pilot_id == current_user.id or event.flight.co_pilot_id == current_user.id) -%}
  {{ _('<strong>%(pilot)s</strong> commented on your <strong>%(distance)s</strong> flight on the <strong>%(date)s</strong>.',
       pilot=user_link(event.actor),
       distance=h.format_distance(event.flight.olc_classic_distance),
       date=h.format_date(event.flight.date_local)) }}
{%- elif g.current_user and event.actor_id == g.current_user.id -%}
  {{ _('You commented on a <strong>%(distance)s</strong> flight on the <strong>%(date)s</strong>.',
       distance=h.format_distance(event.flight.olc_classic_distance),
       date=h.format_date(event.flight.date_local)) }}
{%- else -%}
  {{ _('<strong>%(pilot)s</strong> commented on a <strong>%(distance)s</strong> flight on the <strong>%(date)s</strong>.',
       pilot=user_link(event.actor),
       distance=h.format_distance(event.flight.olc_classic_distance),
       date=h.format_date(event.flight.date_local)) }}
{%- endif %}
{%- endmacro %}


{% macro render_flight_event_text(event) -%}
{% if g.current_user and event.actor_id == g.current_user.id -%}
  {{ _('You uploaded a <strong>%(distance)s</strong> flight on the <strong>%(date)s</strong>.',
       distance=h.format_distance(event.flight.olc_classic_distance),
       date=h.format_date(event.flight.date_local)) }}
{%- else -%}
  {{ _('<strong>%(pilot)s</strong> uploaded a new <strong>%(distance)s</strong> flight on the <strong>%(date)s</strong>.',
       pilot=user_link(event.actor),
       distance=h.format_distance(event.flight.olc_classic_distance),
       date=h.format_date(event.flight.date_local)) }}
{%- endif %}
{%- endmacro %}


{% macro render_grouped_flights_event_text(event) -%}
{% if g.current_user and event.actor_id == g.current_user.id -%}
  {{ _('You uploaded <strong>%(num_flights)s</strong> new flights.',
       num_flights=event.subevents|count) }}
{%- else -%}
  {{ _('<strong>%(pilot)s</strong> uploaded <strong>%(num_flights)s</strong> new flights.',
       pilot=user_link(event.actor), num_flights=event.subevents|count) }}
{%- endif %}
{%- endmacro %}


{% macro render_follower_event_text(event) -%}
{% if g.current_user and event.user_id == g.current_user.id -%}
  {{ _('<strong>%(pilot)s</strong> started following you.', pilot=user_link(event.actor)) }}
{%- elif g.current_user and event.actor_id == g.current_user.id -%}
  {{ _('You started following <strong>%(pilot)s</strong>.', pilot=user_link(event.user)) }}
{%- else -%}
  {{ _('<strong>%(pilot)s</strong> started following <strong>%(pilot2)s</strong>.', pilot=user_link(event.actor), pilot2=user_link(event.user)) }}
{%- endif %}
{%- endmacro %}


{% macro render_grouped_followers_event_text(event) -%}
{% if g.current_user and event.actor_id == g.current_user.id -%}
  {{ _('You started following <strong>%(num_pilots)s</strong> other pilots.', num_pilots=event.subevents|count) }}
{%- else -%}
  {{ _('<strong>%(pilot)s</strong> started following <strong>%(num_pilots)s</strong> other pilots.', pilot=user_link(event.actor), num_pilots=event.subevents|count) }}
{%- endif %}
{%- endmacro %}


{% macro render_new_user_event_text(event) -%}
{% if g.current_user and event.actor_id == g.current_user.id -%}
  {{ _('You joined SkyLines.') }}
{%- else -%}
  {{ _('<strong>%(pilot)s</strong> joined SkyLines.', pilot=user_link(event.actor)) }}
{%- endif %}
{%- endmacro %}


{% macro render_club_join_event_text(event) -%}
{% if g.current_user and event.actor_id == g.current_user.id -%}
  {{ _('You joined <strong>%(club)s</strong>.',
       club=club_link(event.club)) }}
{%- else -%}
  {{ _('<strong>%(pilot)s</strong> joined <strong>%(club)s</strong>.',
       pilot=user_link(event.actor),
       club=club_link(event.club)) }}
{%- endif %}
{%- endmacro %}


{% macro _render_show_button(link) -%}
<a href="{{ link }}" class="btn btn-mini">{{ _('Show') }}</a>
{%- endmacro %}


{% macro event_link(event) -%}
{% if event.grouped -%}
  {% if event.type == types.FLIGHT -%}
    {{ url_for('flights.pilot', id=event.actor_id) }}
  {%- endif %}
{%- else %}
  {% if event.type == types.FLIGHT_COMMENT -%}
    {{ url_for('flight.index', flight_id=event.flight_id) }}
  {%- elif event.type == types.FLIGHT %}
    {{ url_for('flight.index', flight_id=event.flight_id) }}
  {%- elif event.type == types.FOLLOWER %}
    {{ url_for('user.index', user_id=event.user_id) }}
  {%- elif event.type == types.NEW_USER %}
    {{ url_for('user.index', user_id=event.actor_id) }}
  {%- elif event.type == types.CLUB_JOIN %}
    {{ url_for('club.index', club_id=event.club_id) }}
  {%- endif %}
{%- endif %}
{%- endmacro %}<commit_msg>events: Fixed link for "Pilot X started following you" events<commit_after>{% from "macros/datetime.jinja" import insert_timeago with context %}
{% from "macros/links.jinja" import user_link, club_link %}


{% macro render_events_table(events) -%}
<table class="table table-events">
  <tbody>
    {% for event in events -%}
    {{ render_event_row(event) }}
    {%- endfor %}
  </tbody>
</table>
{%- endmacro %}


{% macro render_event_row(event) -%}
<tr>
  <td class="icon">
    {{ render_event_icon(event) }}
  </td>
  <td>
    <p>
      {% if event.unread %}<span class="badge badge-warning">{{ _('New') }}</span>{% endif %}
      <small>{{ insert_timeago(event.time) }}</small>
    </p>
    <p>
    {{ render_event_text(event) }}
    </p>
    <p>
    {% if event.grouped -%}
      {% for event in event.subevents -%}
        <small>
          {% if event.unread %}<span class="badge badge-warning badge-empty"></span>{% endif %}
          {{ render_event_text(event) }}
          <a href="{{ event_link(event) }}"><i class="icon-circle-arrow-right"></i></a>
        </small>
        <br/>
      {%- endfor %}
    {%- endif %}
    </p>
  </td>
  <td class="show">
    {{ _render_show_button(event_link(event)) }}
  </td>
</tr>
{%- endmacro %}


{% macro render_event_icon(event) -%}
{% if event.type == types.FLIGHT_COMMENT -%}
  <i class="icon-comments-alt"></i>
{%- elif event.type == types.FLIGHT %}
  <i class="icon-plane"></i>
{%- elif event.type == types.FOLLOWER %}
  <i class="icon-user"></i>
{%- elif event.type == types.NEW_USER %}
  <i class="icon-asterisk small"></i>
{%- elif event.type == types.CLUB_JOIN %}
  <i class="icon-group small"></i>
{%- endif %}&nbsp;
{%- endmacro %}


{% macro render_event_text(event) -%}
{% if event.grouped -%}
  {% if event.type == types.FLIGHT -%}
    {{ render_grouped_flights_event_text(event) }}
  {%- elif event.type == types.FOLLOWER -%}
    {{ render_grouped_followers_event_text(event) }}
  {%- else %}
    Error: Unknown event group
  {%- endif %}
{%- else %}
  {% if event.type == types.FLIGHT_COMMENT -%}
    {{ render_flight_comment_event_text(event) }}
  {%- elif event.type == types.FLIGHT %}
    {{ render_flight_event_text(event) }}
  {%- elif event.type == types.FOLLOWER %}
    {{ render_follower_event_text(event) }}
  {%- elif event.type == types.NEW_USER %}
    {{ render_new_user_event_text(event) }}
  {%- elif event.type == types.CLUB_JOIN %}
    {{ render_club_join_event_text(event) }}
  {%- else %}
    Error: Unknown event
  {%- endif %}
{%- endif %}
{%- endmacro %}


{% macro render_flight_comment_event_text(event) -%}
{% if g.current_user and (event.flight.pilot_id == current_user.id or event.flight.co_pilot_id == current_user.id) -%}
  {{ _('<strong>%(pilot)s</strong> commented on your <strong>%(distance)s</strong> flight on the <strong>%(date)s</strong>.',
       pilot=user_link(event.actor),
       distance=h.format_distance(event.flight.olc_classic_distance),
       date=h.format_date(event.flight.date_local)) }}
{%- elif g.current_user and event.actor_id == g.current_user.id -%}
  {{ _('You commented on a <strong>%(distance)s</strong> flight on the <strong>%(date)s</strong>.',
       distance=h.format_distance(event.flight.olc_classic_distance),
       date=h.format_date(event.flight.date_local)) }}
{%- else -%}
  {{ _('<strong>%(pilot)s</strong> commented on a <strong>%(distance)s</strong> flight on the <strong>%(date)s</strong>.',
       pilot=user_link(event.actor),
       distance=h.format_distance(event.flight.olc_classic_distance),
       date=h.format_date(event.flight.date_local)) }}
{%- endif %}
{%- endmacro %}


{% macro render_flight_event_text(event) -%}
{% if g.current_user and event.actor_id == g.current_user.id -%}
  {{ _('You uploaded a <strong>%(distance)s</strong> flight on the <strong>%(date)s</strong>.',
       distance=h.format_distance(event.flight.olc_classic_distance),
       date=h.format_date(event.flight.date_local)) }}
{%- else -%}
  {{ _('<strong>%(pilot)s</strong> uploaded a new <strong>%(distance)s</strong> flight on the <strong>%(date)s</strong>.',
       pilot=user_link(event.actor),
       distance=h.format_distance(event.flight.olc_classic_distance),
       date=h.format_date(event.flight.date_local)) }}
{%- endif %}
{%- endmacro %}


{% macro render_grouped_flights_event_text(event) -%}
{% if g.current_user and event.actor_id == g.current_user.id -%}
  {{ _('You uploaded <strong>%(num_flights)s</strong> new flights.',
       num_flights=event.subevents|count) }}
{%- else -%}
  {{ _('<strong>%(pilot)s</strong> uploaded <strong>%(num_flights)s</strong> new flights.',
       pilot=user_link(event.actor), num_flights=event.subevents|count) }}
{%- endif %}
{%- endmacro %}


{% macro render_follower_event_text(event) -%}
{% if g.current_user and event.user_id == g.current_user.id -%}
  {{ _('<strong>%(pilot)s</strong> started following you.', pilot=user_link(event.actor)) }}
{%- elif g.current_user and event.actor_id == g.current_user.id -%}
  {{ _('You started following <strong>%(pilot)s</strong>.', pilot=user_link(event.user)) }}
{%- else -%}
  {{ _('<strong>%(pilot)s</strong> started following <strong>%(pilot2)s</strong>.', pilot=user_link(event.actor), pilot2=user_link(event.user)) }}
{%- endif %}
{%- endmacro %}


{% macro render_grouped_followers_event_text(event) -%}
{% if g.current_user and event.actor_id == g.current_user.id -%}
  {{ _('You started following <strong>%(num_pilots)s</strong> other pilots.', num_pilots=event.subevents|count) }}
{%- else -%}
  {{ _('<strong>%(pilot)s</strong> started following <strong>%(num_pilots)s</strong> other pilots.', pilot=user_link(event.actor), num_pilots=event.subevents|count) }}
{%- endif %}
{%- endmacro %}


{% macro render_new_user_event_text(event) -%}
{% if g.current_user and event.actor_id == g.current_user.id -%}
  {{ _('You joined SkyLines.') }}
{%- else -%}
  {{ _('<strong>%(pilot)s</strong> joined SkyLines.', pilot=user_link(event.actor)) }}
{%- endif %}
{%- endmacro %}


{% macro render_club_join_event_text(event) -%}
{% if g.current_user and event.actor_id == g.current_user.id -%}
  {{ _('You joined <strong>%(club)s</strong>.',
       club=club_link(event.club)) }}
{%- else -%}
  {{ _('<strong>%(pilot)s</strong> joined <strong>%(club)s</strong>.',
       pilot=user_link(event.actor),
       club=club_link(event.club)) }}
{%- endif %}
{%- endmacro %}


{% macro _render_show_button(link) -%}
<a href="{{ link }}" class="btn btn-mini">{{ _('Show') }}</a>
{%- endmacro %}


{% macro event_link(event) -%}
{% if event.grouped -%}
  {% if event.type == types.FLIGHT -%}
    {{ url_for('flights.pilot', id=event.actor_id) }}
  {%- endif %}
{%- else %}
  {% if event.type == types.FLIGHT_COMMENT -%}
    {{ url_for('flight.index', flight_id=event.flight_id) }}
  {%- elif event.type == types.FLIGHT %}
    {{ url_for('flight.index', flight_id=event.flight_id) }}
  {%- elif event.type == types.FOLLOWER %}
    {% if g.current_user and event.user_id == g.current_user.id -%}
      {{ url_for('user.index', user_id=event.actor_id) }}
    {%- else -%}
      {{ url_for('user.index', user_id=event.user_id) }}
    {%- endif %}
  {%- elif event.type == types.NEW_USER %}
    {{ url_for('user.index', user_id=event.actor_id) }}
  {%- elif event.type == types.CLUB_JOIN %}
    {{ url_for('club.index', club_id=event.club_id) }}
  {%- endif %}
{%- endif %}
{%- endmacro %}
{'fraction_non_alphanumeric': 0.20784823996712778, 'fraction_numerical': 0.00027393507738665936, 'mean_word_length': 3.9468157181571817, 'pattern_counts': {'":': 0, '<': 197, '<?xml version=': 0, '>': 197, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3865782', 'n_tokens_mistral': 5733, 'n_tokens_neox': 5263, 'n_words': 840}