code: def stats_view(request, activity_id=None):
      
      if not (request.user.is_eighth_admin or request.user.is_teacher):
          return render(request, "error/403.html", {"reason": "You do not have permission to view statistics for this activity."}, status=403)
  
      activity = get_object_or_404(EighthActivity, id=activity_id)
  
      if request.GET.get("print", False):
          response = HttpResponse(content_type="application/pdf")
          buf = generate_statistics_pdf([activity], year=int(request.GET.get("year", 0)) or None)
          response.write(buf.getvalue())
          buf.close()
          return response
  
      current_year = current_school_year()
  
      if EighthBlock.objects.count() == 0:
          earliest_year = current_year
      else:
          earliest_year = EighthBlock.objects.order_by("date").first().date.year
  
      if request.GET.get("year", False):
          year = int(request.GET.get("year"))
      else:
          year = None
  
      future = request.GET.get("future", False)
  
      context = {"activity": activity, "years": list(reversed(range(earliest_year, current_year + 1))), "year": year, "future": future}
  
      if year:
          context.update(calculate_statistics(activity, year=year, future=future))
      else:
          context.update(calculate_statistics(activity, get_start_date(request), future=future))
      return render(request, "eighth/statistics.html", context)
docs: If a the GET parameter `year` is set, it uses stats from given year
          with the following caveats:
              - If it's the current year and start_date is set, start_date is ignored
              - If it's the current year, stats will only show up to today - they won't
                go into the future.
          `all_years` (obviously) displays all years.