Thank you all for your help. Here's the view that is causing issues. We are
using the local time to get the current day of the week. See below.
The documents represent opening hours and are of the form:
{
businessHours: {
s: ['0800','2300'],
m: ['0700','2330'],
...
}
}
function(doc) {
if(doc.businessHours) {
var daysArr = new Array('s','m','t','w','h','f','a');
var day = daysArr[new Date().getDay()];
emit(parseInt(doc.businessHours[day][0].indexOf('0') == 0 ?
doc.businessHours[day][0].substring(1) : doc.businessHours[day][0]), doc)};
}
Thank you for your help.
*
*
*JULIEN DREUX*
[email protected]
514 812-8084
www.justlexit.com
On Wed, Apr 11, 2012 at 3:02 PM, Robert Newson <[email protected]> wrote:
> Hi Julien,
>
> This is a bug in your view, rather than a problem with CouchDB. A view
> is built by reading the _changes feed for the database, and only
> updates to documents will cause their corresponding rows in the view
> to be recalculated. This is all by design.
>
> If you give more details, we can help you fix your view. Someone has
> already noted the general shape of the solution, emitting the
> timestamp in the key and selecting slices with startkey/endkey.
>
> B.
>
>
> On 11 April 2012 14:50, Aurélien Bénel <[email protected]> wrote:
> >> What are the implications of doing this?
> >
> > MapReduce provides you with a very efficient cache mechanism but to
> work, views must be completely context-independent.
> >
> >> What can we do to still keep our views with up to date data?
> >
> > Set your one week slot outside the view definition: either in the view
> URL (with startkey/endkey) or in a list.
> >
> > Regards,
> >
> > Aurélien
>