Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use count_documents() to count mongo documents instead of old and deprecated count() #1032

Merged
merged 1 commit into from
Dec 11, 2023

Conversation

baonq-me
Copy link
Contributor

Use count_documents() to count Mongo documents instead of old and deprecated count()

    **adminInfo(),
  File "/Users/quocbao/cve-search/web/home/utils.py", line 297, in adminInfo
    return {"stats": getDBStats(True), "updateOutput": filterUpdateField(output)}
  File "/Users/quocbao/cve-search/lib/DatabaseLayer.py", line 457, in getDBStats
    "size": getSize(key.lower()),
  File "/Users/quocbao/cve-search/lib/DatabaseLayer.py", line 445, in getSize
    return db[collection].count()
  File "/Users/quocbao/cve-search/venv/lib/python3.10/site-packages/pymongo/collection.py", line 3509, in __call__
    raise TypeError(
TypeError: 'Collection' object is not callable. If you meant to call the 'count' method on a 'Collection' object it is failing because no such method exists.
2023-12-11 14:40:33,404 - werkzeug - INFO     - 127.0.0.1 - - [11/Dec/2023 14:40:33] "GET /admin/ HTTP/1.1" 500 -

CleanShot 2023-12-11 at 14 47 47

Since commit 8d4c6d4 pymongo 4.5.0 have some breaking changes, for example they removed method. From version 4.0 they remove many methods including count()
https://pymongo.readthedocs.io/en/stable/changelog.html

Removed pymongo.collection.Collection.count().

@P-T-I P-T-I linked an issue Dec 11, 2023 that may be closed by this pull request
@P-T-I
Copy link
Member

P-T-I commented Dec 11, 2023

Thank you!

@P-T-I P-T-I merged commit ee4eb34 into cve-search:master Dec 11, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AttributeError when searching for a specific CVE in Ubuntu 23.10
2 participants