Properly count Blender Sync users
Use a dedicated aggregation pipeline to filter one startup.blend per home project and count them.
This commit is contained in:
@@ -3,7 +3,7 @@ import datetime
|
||||
import functools
|
||||
|
||||
from flask import Blueprint, jsonify
|
||||
from cloud.stats import count_nodes, count_users
|
||||
from cloud.stats import count_nodes, count_users, count_blender_sync
|
||||
|
||||
blueprint = Blueprint('cloud.stats', __name__, url_prefix='/s')
|
||||
|
||||
@@ -14,20 +14,17 @@ log = logging.getLogger(__name__)
|
||||
def get_stats(before: datetime.datetime):
|
||||
query_comments = {'node_type': 'comment'}
|
||||
query_assets = {'node_type': 'asset'}
|
||||
# TODO Actually query per home project (and 1 blend per project)
|
||||
query_user_blender_sync = {'name': 'startup.blend'}
|
||||
|
||||
if before:
|
||||
d = {'_created': {'$lt': before}}
|
||||
query_comments.update(d)
|
||||
query_assets.update(d)
|
||||
query_user_blender_sync.update(d)
|
||||
|
||||
stats = {
|
||||
'comments': count_nodes(query_comments),
|
||||
'assets': count_nodes(query_assets),
|
||||
'users_total': count_users(),
|
||||
'users_blender_sync': count_nodes(query_user_blender_sync),
|
||||
'users_blender_sync': count_blender_sync(),
|
||||
}
|
||||
return stats
|
||||
|
||||
|
Reference in New Issue
Block a user