couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From muji <>
Subject Sanity check and advice on positional chart query
Date Tue, 12 Mar 2013 12:42:30 GMT

I'm working on an application which has a requirement to list charts
(eg: fan chart/music chart) based on activity which corresponds to a

Currently, I have two document types *score* and *rank*, a score
document represents an individual activity (with a corresponding
score) and a *rank* document is the sum of all *score* documents to
generate a ranking within the chart.

I can provide a list of current chart rankings by querying a view
listing the *rank* documents and ordering by the cumulative score.

We have more complex requirements such as querying by date range and
other criteria which I will try to address later; for the moment my
problem is that I need to calculate the *position* in the chart for a

My current thinking is that if I segregate the charts on a
per-database level and have a view that lists the *rank* documents
then I can use the view *offset* field (+1) to determine the position
in the chart. Do you think this approach is flawed? Is there a better
way to approach the problem?

For paged representations of the chart we plan on deferring the
calculation to the client which can easily determine the position from
current page index, page limit and index into the records. But the
query I am trying to resolve now corresponds to the statement "Your
chart position is 127". I hope that makes sense...

With a very simple test case I've set up using *offset* in this manner
appears to work as expected, I'm wondering if some of the couchdb
people here with more experience than me have any

Thanks for any help,

mischa (aka muji).

View raw message