changed count to count_documents (#23945)
This PR contributes to the elimination of deprecation warnings, specifically the one mentioned above and reported in the Warnings Report: https://build.testeng.edx.org/job/edx-platform-python-pipeline-master/warning_5freport_5fall_2ehtml/ . Changed collection.find(filter).count() to collection.count_documents(filter) in the following file: common/lib/xmodule/xmodule/modulestore/tests/test_split_modulestore.py And collection.find(filter).limit(1).count() to collection.count_documents(filter, limit=1) in the following file: common/lib/xmodule/xmodule/modulestore/mongo/draft.py The method count_documents is part of the collection, not the cursor (find returns a cursor), according to StackOverflow (https://stackoverflow.com/questions/56303331/warning-message-in-pymongo-count-is-deprecated). Because of that after changing count, I removed the calling to the find method and use the filter parameter in count_documents. Also, I removed limit because count_documents accepts limit parameter. This warning occurs due to deprecation: https://pymongo.readthedocs.io/en/3.9.0/api/pymongo/collection.html#pymongo.collection.Collection.count_documents
Please register or sign in to comment