This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"total_rows":0,"offset":0,"rows":[]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
map: function(doc) { | |
if (doc.type === 'queue') { | |
emit(null, 1); | |
} | |
}, | |
reduce: '_sum' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Assuming the docs have created_at, delete everything older than | |
# 5 minutes. We assume an emit like this: | |
# | |
# emit(Date.parse(doc.created_at), doc._rev) | |
# | |
# Notice that the value in emitted kv pair is the doc's current _rev | |
old = (Time.now - 300).utc.to_i * 1000 | |
opts = { :startkey => old, :descending => true } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def update_doc doc | |
loop do | |
yield doc | |
begin | |
save_doc doc | |
break | |
rescue RestClient::RequestFailed => e | |
if e.http_code == 409 | |
doc = get doc['_id'] | |
next |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
map: function(doc) { | |
if (something_or_the_other) { | |
emit(doc.attribute, doc); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RestClient::Request | |
Empty = {}.freeze | |
def default_headers | |
Empty | |
end | |
end | |
module RestAPI | |
Headers = { :content_type => :json }.freeze | |
def default_headers |
NewerOlder