incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Somers <somers....@gmail.com>
Subject Re: View with datetime values
Date Fri, 03 Apr 2009 10:44:31 GMT
On Fri, Apr 3, 2009 at 11:45 AM, Tim Somers <somers.tim@gmail.com> wrote:

> Hi,
>
> I'm having a problem indexing datetime values.
> I receive temperature values from a mobile device over gprs. Each message
> contains 8 values, and the datetime of only the last value, eg:
> {
>    "_id": "message_3505_120029682",
>    "_rev": "3715377160",
>    "monitorID": 3505,
>    "doc_type": "MessageWith8Vals",
>    "temp": [
>        31,
>        31,
>        32,
>        31,
>        31,
>        31,
>        31,
>        30
>    ],
>    "LocDateTime": "2009-03-02T14:23:58Z",
>    "ref": 255
> }
> Since there are 5 seconds between values, I thought I could create a view
> which indexes each value with it's own datetime :
> function(doc) {
>   if (doc.doc_type=="MessageWith8Vals") {
>     var secondsBetweenVals = 5;
>     var subDateTime = new Date(doc.LocDateTime);
>
>     var i;
>     for (i=0; i<=7; i++) {
>         subDateTime.setSeconds(subDateTime.getSeconds() -
> secondsBetweenVals);
>         //Just emit the datetime for testing at the moment...
>         emit([doc.monitorID, doc.LocDateTime], subDateTime);
>     }
>
>   }
> }
> but this doesn't seem to work. This is the output :
> {"total_rows":12296,"offset":0,"rows":[
>
> {"id":"message_3505_120029682","key":[3505,"2009-03-02T14:23:58Z"],"value":"2009-03-02T14:23:18Z"},
>
> {"id":"message_3505_120029682","key":[3505,"2009-03-02T14:23:58Z"],"value":"2009-03-02T14:23:18Z"},
>
> {"id":"message_3505_120029682","key":[3505,"2009-03-02T14:23:58Z"],"value":"2009-03-02T14:23:18Z"},
>
> {"id":"message_3505_120029682","key":[3505,"2009-03-02T14:23:58Z"],"value":"2009-03-02T14:23:18Z"},
>
> {"id":"message_3505_120029682","key":[3505,"2009-03-02T14:23:58Z"],"value":"2009-03-02T14:23:18Z"},
>
> {"id":"message_3505_120029682","key":[3505,"2009-03-02T14:23:58Z"],"value":"2009-03-02T14:23:18Z"},
>
> {"id":"message_3505_120029682","key":[3505,"2009-03-02T14:23:58Z"],"value":"2009-03-02T14:23:18Z"},
>
> {"id":"message_3505_120029682","key":[3505,"2009-03-02T14:23:58Z"],"value":"2009-03-02T14:23:18Z"},
> ....
> ]}
> so in effect the full 40 seconds (8x5) is extracted, and emitted 8 times.
> When I change the line
> emit([doc.monitorID, doc.LocDateTime], subDateTime);
> to
> emit([doc.monitorID, doc.LocDateTime], subDateTime.toString());
> the output becomes
> {"total_rows":12296,"offset":0,"rows":[
> {"id":"message_3505_120029682","key":[3505,"2009-03-02T14:23:58Z"],"value":"Mon
> Mar 02 2009 15:23:18 GMT+0100 (CET)"},
> {"id":"message_3505_120029682","key":[3505,"2009-03-02T14:23:58Z"],"value":"Mon
> Mar 02 2009 15:23:23 GMT+0100 (CET)"},
> {"id":"message_3505_120029682","key":[3505,"2009-03-02T14:23:58Z"],"value":"Mon
> Mar 02 2009 15:23:28 GMT+0100 (CET)"},
> {"id":"message_3505_120029682","key":[3505,"2009-03-02T14:23:58Z"],"value":"Mon
> Mar 02 2009 15:23:33 GMT+0100 (CET)"},
> {"id":"message_3505_120029682","key":[3505,"2009-03-02T14:23:58Z"],"value":"Mon
> Mar 02 2009 15:23:38 GMT+0100 (CET)"},
> {"id":"message_3505_120029682","key":[3505,"2009-03-02T14:23:58Z"],"value":"Mon
> Mar 02 2009 15:23:43 GMT+0100 (CET)"},
> {"id":"message_3505_120029682","key":[3505,"2009-03-02T14:23:58Z"],"value":"Mon
> Mar 02 2009 15:23:48 GMT+0100 (CET)"},
> {"id":"message_3505_120029682","key":[3505,"2009-03-02T14:23:58Z"],"value":"Mon
> Mar 02 2009 15:23:53 GMT+0100 (CET)"},
> ....
> ]}
> The values are correct, but not very usable. Any ideas?
>
> By the way, I'm using an svn version 0.9.0a749567 on debian.
>
> Thanks
> Tim
>
>
For info, I just checked out the latest svn, still the same behavior.

Thanks
Tim

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message