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
\set start_time '\'2018-10-15 00:00:00.0\'' | |
\set end_time '\'2018-10-22 00:00:00.0\'' | |
with calls as ( | |
SELECT * FROM calls | |
INNER JOIN audio_minute_rate_schemes amrs on amrs.id = calls.audio_minute_rate_scheme_id | |
LEFT JOIN ( | |
SELECT DISTINCT ON(call_id) rating as tqr_rating, created_at, call_id | |
FROM transcript_quality_ratings | |
ORDER BY call_id, created_at DESC |
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
#!/usr/bin/ruby | |
if ARGV.length < 2 | |
puts "USAGE: vo <table_key> <id/name>..." | |
exit 1 | |
end | |
def compile_cmd(table, arg, id) | |
psql_string = "psql platform -c" | |
where = id ? table[:id_where] : table[:string_where] |
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
#!/usr/bin/ruby | |
if ARGV.length < 2 | |
puts "USAGE: vo <table_key> <id/name>..." | |
exit 1 | |
end | |
def compile_cmd(table, arg, id) | |
psql_string = "psql platform -c" | |
where = id ? table[:id_where] : table[:string_where] |
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
#!/usr/bin/ruby | |
def pprint(statuses) | |
if statuses.length == 0 | |
puts "no statuses found" | |
return | |
end | |
statuses.each do |code, uid| | |
puts "#{code}: #{uid}" | |
end |
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
#!/bin/bash | |
function tab() { | |
osascript 2>/dev/null <<EOF | |
tell application "System Events" | |
tell process "Terminal" to keystroke "t" using command down | |
end | |
tell application "Terminal" | |
activate | |
do script with command "$*" in window 1 |
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
#!/bin/bash | |
function tab() { | |
osascript 2>/dev/null <<EOF | |
tell application "System Events" | |
tell process "Terminal" to keystroke "t" using command down | |
end | |
tell application "Terminal" | |
activate | |
do script with command "$*" in window 1 |
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
now = Time.zone.now.in_time_zone("US/Pacific") | |
today = now.to_date | |
month_start = today.beginning_of_month | |
week_start = today.beginning_of_week | |
date_contexts = [] | |
(1..4).each do |i| | |
d = month_start - i.month | |
date_contexts << { | |
s_date: d, |
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
select | |
case when segments.confidence < 75 | |
then '< 75' | |
else '> 75' end confidance, | |
sum(time_spent_working)::float / (sum(duration)::float / 1000.0) secs_per_audio_sec | |
from segments | |
inner join calls on calls.id = segments.call_id | |
where 1=1 | |
and calls.created_at >= date_trunc('year', now()) | |
and EXTRACT(EPOCH FROM current_timestamp-calls.occurred_at)/(3600*24) between 0 and 60 |
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
\timing | |
WITH | |
crs as ( | |
select | |
cr.id as cr_id, | |
cr.numerator_id as cr_nid, | |
cr.denominator_id as cr_did, | |
tct.team_id as team_id, | |
tct.call_type_id as ct_id, | |
u.id as u_id |
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
\timing | |
WITH | |
crs as ( | |
select | |
cr.id as cr_id, | |
cr.numerator_id as cr_nid, | |
cr.denominator_id as cr_did, | |
tct.team_id as team_id, | |
tct.call_type_id as ct_id, | |
u.id as u_id |