redis / redis-om-python

Object mapping, and more, for Redis and Python
MIT License
1.12k stars 112 forks source link

implement count function #336

Open wiseaidev opened 2 years ago

wiseaidev commented 2 years ago

Related to #283

Implemented as described here. I think I forget to implement the second one with FILTER. It seems like we don't have to pass FILTER in args cause it will work the same as passing multiple fields.

Note that passing LIMIT 0 0 into the query will not work as described in the docs, it will throw an exception. It seems like the docs are outdated or something. The default value LIMIT 0 10 works.

await model.find((model.field1 == value1) & (model.field2 == value2), ...).count()
codecov-commenter commented 2 years ago

Codecov Report

Merging #336 (fe1dd1b) into main (dcd84e0) will decrease coverage by 0.13%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #336      +/-   ##
==========================================
- Coverage   77.25%   77.12%   -0.14%     
==========================================
  Files          12       12              
  Lines        1165     1154      -11     
==========================================
- Hits          900      890      -10     
+ Misses        265      264       -1     
Flag Coverage Δ
unit 77.12% <100.00%> (-0.14%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
aredis_om/model/model.py 86.21% <100.00%> (-0.06%) :arrow_down:

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

wiseaidev commented 2 years ago

@dvora-h, this PR is ready for reviews!

XChikuX commented 1 year ago

@dvora-h @chayim @simonprickett @guyroyse

chayim commented 1 year ago

Missed this in the GH notifications. Looking today there's an implementation of count. This would change that implementation.

IMHO we should combine the ideas. Yours uses a batch size, which can be more performant based on data types (great)! though it should make use of DEFAULT_PAGE_SIZE for the batch argument, much like all. WDYT @wiseaidev?