I am trying to get a specific table from one of my models. More specifically I am looking for the total count of these tables that meet the requirements.
#<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"=>"gscott@whereswaldo.com",
"utm_campaign"=>"simplyjobs.com",
"rawLocationName"=>"12345"}},
"success"=>true},
time: Sat, 07 May 2016 19:46:19 UTC +00:00>
I am trying to get the count of the tables which have a 'type' => 'post-to-host' AND 'partner' => 'Glassdoor' AND 'success' => true AND 'time' => Time.now.month/day/year
This was my attempt:
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
I am not so familiar with SQL, any help is appreciated.
Aucun commentaire:
Enregistrer un commentaire