Filter collection on age interval (ajax) [SOLVED]

I want to show and filter 'persons' with Collective.collectionfilter (or eea facetednavigaton).
All the 'normal filtering' works, but I am stuck with one problem (which I would like to 'do the same way as collectionfilter).

Every 'person' has a Datetime field (date of birth).

In the collection, I want the person to show up with age ( or today - date of birth).

BUT: I would like to have a slider, so I can filter on a 'age range' (show 'persons' from 23 to 28 years old.
(similar to the 'outbound filter' at ).

Is this doable ? If not, could there be a workaround (like having a cron job every night updating some index ?

Adding a computed "age" field is likely the way to go. And yes, you need to update it regularly and reindex it.

Thanks… got it working


I find all the unique values of 'age' from the index
A javascript slider selects the options for collective.collectionfilter by looping from 'start to end'.
Currently I am just hiding the portlet itself with CSS

Due to a bug in collective.collectionfilter, indexes with just numbers does not work so for now I have indexed them as a string. Not sure if it matters… after all 'age' is only used for collectionfilter (in the 'personal' views pat-moment is used to show 'born')

def ageIndexer(obj):
#born is required, but maybe check anyway?
days_in_year = 365.2425
age = int(( - obj.born).days / days_in_year)
#can not return int since it does not work with collectionfilter
return str("%02d" % age)

I plan to make the reindexing a browser view that gets called every night from a cron script
( There will only be 3 users and a few hundred object for the intranet / database so speed is not really an issue)