Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 67665 invoked from network); 10 Jan 2009 21:40:29 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 10 Jan 2009 21:40:29 -0000 Received: (qmail 35647 invoked by uid 500); 10 Jan 2009 21:40:27 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 35601 invoked by uid 500); 10 Jan 2009 21:40:27 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 35590 invoked by uid 99); 10 Jan 2009 21:40:27 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 10 Jan 2009 13:40:27 -0800 X-ASF-Spam-Status: No, hits=3.7 required=10.0 tests=HTML_MESSAGE,SPF_PASS,WEIRD_PORT X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of webjogger@gmail.com designates 209.85.134.188 as permitted sender) Received: from [209.85.134.188] (HELO mu-out-0910.google.com) (209.85.134.188) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 10 Jan 2009 21:40:18 +0000 Received: by mu-out-0910.google.com with SMTP id i10so4343354mue.5 for ; Sat, 10 Jan 2009 13:39:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type:references; bh=qU7lmXm3/d4g2D/HhnZ4GlaKFqhMQ2qehpPmuhikpXg=; b=lTcmKk8h5B+4mafZbtwVzrr/aw18lhMUxm8HPkD/GB/kMIVFyo2SXSYK7OaHEwKrFr dwJyrEFL3k/iPJIzI17TaWwY4kCQVRQQ/tsku36cALGL7ztE3QZxmIHIXyYaMKlZqSYm Rokh1l/sjkMvqZvRlZAB4A94JsQ99vMXx8qmA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:references; b=bOBOVb603eFV92V8AW4cBHQReFwtDqRwJKfkdfLOafd3PJzlSgAzkmGGKeVt+b7UPW ZZLe8tvXTUhS0JJcHkqSh1xm6DvPSnsL7eHK5u/28ZD10WpxYFE+bPe3T9P4yPWXJq29 hl0WO++QBM/xl9c8FYuMmvn25m5E0P7HmB9JA= Received: by 10.103.214.8 with SMTP id r8mr9740719muq.92.1231623597074; Sat, 10 Jan 2009 13:39:57 -0800 (PST) Received: by 10.103.246.16 with HTTP; Sat, 10 Jan 2009 13:39:57 -0800 (PST) Message-ID: <4c69d7170901101339n5c5ddafbna10d244bbc8c0a9e@mail.gmail.com> Date: Sat, 10 Jan 2009 13:39:57 -0800 From: "paul jobs" To: user@couchdb.apache.org Subject: Re: Couchdb views using time In-Reply-To: <6836C7C0-A294-4507-ABF6-F8FCE7463099@gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_224587_13155726.1231623597064" References: <4c69d7170901091547w6f43b7c1wf9612ff459ba8c7a@mail.gmail.com> <4c69d7170901091547g2a42a2ccnccfdc38482b4e5c4@mail.gmail.com> <4c69d7170901092341j512473e3wc6f31c7bcf78619d@mail.gmail.com> <4c69d7170901100031s33f19cfv70e6fcc10d74b81b@mail.gmail.com> <6836C7C0-A294-4507-ABF6-F8FCE7463099@gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_224587_13155726.1231623597064 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline how to use startkey=now-1 hour http://server:5984/truthbox/_view/truthbox/by_created?count=10&group=true gives ou this {"total_rows":37718,"offset":0,"rows":[ {"id":"47d7bef01ae278afd16f56736ae5c87b","key":"2008-12-16T14:45:41Z","value":{"_id":"47d7bef01ae278afd16f56736ae5c87b","_rev":"641284558","msg":"right to those cute lickle tosies....and i will chew your toenails when im there....right up till i get to your pubic hair....x","fromuid":900415470,"touid":573627038,"subject":"PMSL","created":"2008-12-16T14:45:41Z"}}, ]} http://server:5984/truthbox/_view/truthbox/by_created?count=10&group=true*&startkey=(now - 1 hour)* gives nothing as output "key":"2008-12-16T14:45:41Z", On Sat, Jan 10, 2009 at 12:44 AM, Antony Blakey wrote: > > On 10/01/2009, at 7:01 PM, paul jobs wrote: > > so paul what you are saying is this >> so if we use sortable_timestamp or created/date/time in my case >> the rows are automatically sorted in descending order and use the 1st 100 >> u >> get and process them in python >> >> is it possible to construct this in the view itself and get like the 340 >> items that are created in the last one hour without resorting to python >> > > No. You are suggesting having the view consist of those records from the > last hour. The problem is that CouchDB requires that the map and reduce > functions are strictly functional i.e. the will always produce the same > output for the same input. CouchDB will not work if this isn't the case > because the view rows created by a map will be regenerated only when the > document from which they are computed, changes. > > In your case you are expecting that the output will depend on the current > time. > > OTOH, why do you need to process them in python - the view request to > return those records from the last hour is easy - just use startkey=(now - 1 > hour). > > >> Sorry if i am asking something basic >> Thanks >> On Fri, Jan 9, 2009 at 11:51 PM, Paul Davis > >wrote: >> >> >> On Fri, Jan 9, 2009 at 9:41 PM, paul jobs wrote: >>> >>>> Thanks chris >>>> Ok, but how to get the list of items that are in the last one hour, >>>> since >>>> the list is about 3 million users >>>> >>> >>> Paul, >>> >>> emit([doc.user, doc.sortable_timestamp], null) >>> >>> Paul >>> >>> >>> so extracting the 3 million using this view and then processing the >>>> >>> results >>> >>>> in python doesnt seem feasible >>>> thanks a lot >>>> >>>> On Fri, Jan 9, 2009 at 10:52 PM, Chris Anderson >>>> >>> wrote: >>> >>>> >>>> just have a map view that calls emit(doc.timestamp, null) as long as >>>>> your timestamp format sorts correctly. >>>>> >>>>> On Fri, Jan 9, 2009 at 3:47 PM, paul jobs wrote: >>>>> >>>>>> This is very useful for eg., to delete posts older than one day >>>>>> get users who logged in the last 1 hour etc >>>>>> >>>>>> On Fri, Jan 9, 2009 at 3:47 PM, paul jobs >>>>>> >>>>> wrote: >>> >>>> >>>>>> select * from users where ((extract('epoch' from now()) - >>>>>>> >>>>>> extract('epoch' >>>>> >>>>>> from last_login)) < 3000000) order by last_login DESC >>>>>>> >>>>>>> is it possible to construct such views using couchdb permanent views? >>>>>>> >>>>>>> thanks >>>>>>> >>>>>>> >>>>>> >>>>> >>>>> >>>>> -- >>>>> Chris Anderson >>>>> http://jchris.mfdz.com >>>>> >>>>> >>>> >>> > Antony Blakey > ------------- > CTO, Linkuistics Pty Ltd > Ph: 0438 840 787 > > It's amazing that the one side of the conversation that survived is "I > don't know art, but I know what I like". The reply from the artist was > "Madam, so does a cow". > -- Carl Kirkendall > > > ------=_Part_224587_13155726.1231623597064--