Get statistics for selected users and concepts

    since:
      time as timestamp - get stats changed since
    users:
      list of identifiers of users
    concepts (Optional):
      list of identifiers of concepts
    language:
      language of concepts

def user_stats_bulk(request):
    """
    Get statistics for selected users and concepts

    since:
      time as timestamp - get stats changed since
    users:
      list of identifiers of users
    concepts (Optional):
      list of identifiers of concepts
    language:
      language of concepts
    """

    language = get_language(request)
    users = load_query_json(request.GET, "users")
    if request.user.is_staff:
        if not hasattr(request.user, 'userprofile') or User.objects.filter(pk__in=users,
                       userprofile__classes__owner=request.user.userprofile).count() < len(users):
            return render_json(request, {
                'error': _('Some requested users are not in owned classes'),
                'error_type': 'permission_denied'
            }, template='concepts_json.html', status=401)
    since = None
    if 'since' in request.GET:
        since = datetime.datetime.fromtimestamp(int(request.GET['since']))
    concepts = None
    if "concepts" in request.GET:
        concepts = Concept.objects.filter(lang=language, active=True,
                                          identifier__in=load_query_json(request.GET, "concepts"))
    stats = UserStat.objects.get_user_stats(users, language, concepts=concepts, since=since)
    data = {"users": []}
    for user, s in stats.items():
        data["users"].append({
            "user_id": user,
            "concepts": s,
        })
    return render_json(request, data, template='concepts_json.html', help_text=user_stats_bulk.__doc__)