Re: [Rhythmbox-devel] query on PROP_MTIME with limit



On Sat, Jun 5, 2010 at 10:32 AM, Jean-Lou Dupont <jl jldupont com> wrote:
> Hi - I'd like to perform a query on PROP_MTIME with a limit e.g. retrieve
> the "X" entries in the database for which PROP_MTIME > t.
> How would I go about doing this?

Aside from the actual query (already covered, more or less), a
rhythmdb query model includes a sort order (compare function, data,
reverse flag) and a limit (type and value). In order to set a limit,
you need to set a sort order. In this case, you'd probably want to
sort on modification time as well as use it in the query.

>From python code, you can't directly set any of the built in sort
order functions, but you can provide a python function to do the
sorting. Probably something like this:

def mtime_sort(a, b):
    return db.entry_get(a, rhythmdb.PROP_MTIME) - db.entry_get(b,
rhythmdb.PROP_MTIME)

query_model.set_sort_order(mtime_sort)

To set the limit, use the limit-type and limit-value properties:

query_model.props.limit_type = rhythmdb.QUERY_MODEL_LIMIT_COUNT
query_model.props.limit_value = 50

I'm not actually sure if any of this works. Please file bugs if it doesn't.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]