Skip to content

Commit 9586029

Browse files
committed
api: disable size calculations
1 parent a0e4eeb commit 9586029

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

mpcontribs-api/mpcontribs/api/projects/document.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -274,29 +274,29 @@ def post_save(cls, sender, document, **kwargs):
274274

275275
# resolve/lookup component fields
276276
# NOTE also includes dynamic document fields
277-
for component in COMPONENTS.keys():
278-
pipeline.append(
279-
{
280-
"$lookup": {
281-
"from": component,
282-
"localField": component,
283-
"foreignField": "_id",
284-
"as": component,
285-
}
286-
}
287-
)
277+
# for component in COMPONENTS.keys():
278+
# pipeline.append(
279+
# {
280+
# "$lookup": {
281+
# "from": component,
282+
# "localField": component,
283+
# "foreignField": "_id",
284+
# "as": component,
285+
# }
286+
# }
287+
# )
288288

289289
# document size and attachment content size
290290
project_stage = {
291-
"_id": 0,
292-
"size": {"$bsonSize": "$$ROOT"},
293-
"contents": {
294-
"$map": { # attachment sizes
295-
"input": "$attachments",
296-
"as": "attm",
297-
"in": {"$toInt": "$$attm.content"},
298-
}
299-
},
291+
# "_id": 0,
292+
# "size": {"$bsonSize": "$$ROOT"},
293+
# "contents": {
294+
# "$map": { # attachment sizes
295+
# "input": "$attachments",
296+
# "as": "attm",
297+
# "in": {"$toInt": "$$attm.content"},
298+
# }
299+
# },
300300
}
301301

302302
# number of components
@@ -321,14 +321,14 @@ def post_save(cls, sender, document, **kwargs):
321321
pipeline.append({"$project": project_stage})
322322

323323
# forward fields and sum attachment contents
324-
project_stage_2 = {k: 1 for k, v in project_stage.items()}
325-
project_stage_2["contents"] = {"$sum": "$contents"}
324+
project_stage_2 = {k: 1 for k in project_stage.keys()}
325+
# project_stage_2["contents"] = {"$sum": "$contents"}
326326
pipeline.append({"$project": project_stage_2})
327327

328328
# total size and total number of components
329329
group_stage = {
330330
"_id": None,
331-
"size": {"$sum": {"$add": ["$size", "$contents"]}},
331+
# "size": {"$sum": {"$add": ["$size", "$contents"]}},
332332
}
333333
for component in COMPONENTS.keys():
334334
group_stage[component] = {"$sum": f"${component}"}
@@ -357,7 +357,7 @@ def post_save(cls, sender, document, **kwargs):
357357
# prep and save stats
358358
stats_kwargs = {"columns": len(columns), "contributions": ncontribs}
359359
if result and result[0]:
360-
stats_kwargs["size"] = result[0]["size"] / 1024 / 1024
360+
# stats_kwargs["size"] = result[0]["size"] / 1024 / 1024
361361
for component in COMPONENTS.keys():
362362
stats_kwargs[component] = result[0].get(component, 0)
363363
if stats_kwargs[component] > 0:

0 commit comments

Comments
 (0)