Quick way to find max of scalar property

I have a collection where objects have an isoEditionDate property in the form YYYY-MM-DD which can therefore be compared with standard operators.

recent_date = "0001-01-01"
objects_scanned = 0
for item in wv_artcoll.iterator():
    objects_scanned += 1
     if item.properties["isoEditionDay"] > recent_date:
          recent_date = item.properties["isoEditionDay"]
      f"Most recent edition day found: {recent_date} in {objects_scanned} objects."

Is there a quicker, more efficient, way of assessing what is the greatest value in that property?


That will run thru all objects :grimacing:

Have you tried sorting by date?

1 Like

As always you are more knowledgeable than wikipedia, more kind than ChatGPT and more cool than a Marvel hero :slight_smile: Thanks

If anyone should stumble on this with the same need, here is an example:

wv_artcoll = wv_client.collections.get(wv_artcollname)
response = wv_artcoll.query.fetch_objects(
       sort=Sort.by_property(name="isoEditionDay", ascending=False), limit=1
     f"Most recent edition day found: {response.objects[0].properties['isoEditionDay']}"
1 Like