我正在嘗試獲取滿足要求的表中的行數。如何通過滑軌控制檯獲取表中的行數
#<Ahoy::Event:123abc
id: "123abc",
visit_id: "123abc",
user_id: 1,
name: "post_succeeded",
properties:
{"info"=>nil,
"type"=>"post-to-host",
"value"=>0.1,
"partner"=>"Glassdoor",
"request"=>
{"url"=>"http://glassdoor.com",
"params"=>
{"v"=>"1",
"t.k"=>"bac",
"t.p"=>"92",
"action"=>"doJobAlert",
"format"=>"json",
"userip"=>"::1",
"useragent"=>"",
"utm_medium"=>"cpc",
"utm_source"=>"SimplyJobs",
"emailAddress"=>"[email protected]",
"utm_campaign"=>"simplyjobs.com",
"rawLocationName"=>"12345"}},
"success"=>true},
time: Sat, 07 May 2016 19:46:19 UTC +00:00>
要求: '類型'=> '後到主機' 和 '夥伴'=> 'Glassdoor' 和 '成功'=>真實, '時間'=> Time.now.month /天/年
這是我的嘗試:
Ahoy::Event.where("properties ->> 'type' = ?", 'post-to-host' AND "properties ->> 'partner' = ?", 'Glassdoor' AND "properties ->> 'request' ->> 'success' = ?", true AND time: Time.now.month AND time: Time.now.day AND time: Time.now.year).count
我不是那麼熟悉SQL,任何幫助表示讚賞。
某事,這看起來並不像SQL使用where條款 - 它是什麼做的Ruby on Rails的? – cup
是的,我在這裏查看文檔: https://github.com/ankane/ahoy#querying-properties – Ctpelnar1988
通過表您是指表或表中的所有行滿足您的要求? – coderVishal