forked from turbot/steampipe-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsalesforce.sp
223 lines (192 loc) · 3.93 KB
/
salesforce.sp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
locals {
lightning = "https://turbothqindiaprivateltd-dev-ed.lightning.force.com/lightning/"
}
dashboard "salesforce" {
tags = {
service = "salesforce"
}
container {
title = "Quick facts"
card {
width = 2
sql = <<EOQ
select count(*) as contacts from salesforce_contact
EOQ
}
card {
width = 2
sql = <<EOQ
select count(*) as leads from salesforce_lead
EOQ
}
card {
width = 2
sql = <<EOQ
select count(*) as products from salesforce_product
EOQ
}
card {
width = 2
sql = <<EOQ
select count(*) as "Q1 opportunities"
from
salesforce_opportunity
where
not is_won
and forecast_category = 'Pipeline'
and fiscal_year::text = to_char(now(), 'YYYY')
EOQ
}
card {
width = 2
sql = <<EOQ
select count(*) as "Q1 wins"
from
salesforce_opportunity
where
is_won
and fiscal_year::text = to_char(now(), 'YYYY')
and fiscal_quarter = 1
EOQ
}
}
container {
title = "Leads"
chart {
width = 5
type = "donut"
title = "by status"
sql = <<EOQ
select
status,
count(*)
from
salesforce_lead
group by
status
EOQ
}
table {
width = 7
title = "hot"
sql = <<EOQ
select
name,
id as link
from
salesforce_lead
where
status = 'Working - Contacted'
and rating = 'Hot'
EOQ
column "link" {
wrap = "all"
href = "${local.lightning}r/Lead/{{.'link'}}/view"
}
}
}
container {
title = "Contacts"
chart {
width = 5
type = "donut"
title = "by lead department"
sql = <<EOQ
select
department,
count(*)
from
salesforce_contact
where
department is not null
group by
department
EOQ
}
chart {
width = 5
type = "donut"
title = "by lead source"
sql = <<EOQ
select
lead_source,
count(*)
from
salesforce_contact
where
lead_source is not null
group by
lead_source
EOQ
}
table {
width = 8
title = "Twitter Activity"
sql = <<EOQ
with salesforce_info as (
select
id,
name,
twitter_username__c as twitter_username
from
salesforce_contact
where
twitter_username__c is not null
order by
id
)
select
s.name,
'https://twitter.com/' || s.twitter_username as twitter_url,
t.public_metrics->>'tweet_count' as tweets,
t.public_metrics->>'followers_count' as followers
from
salesforce_info s
join
twitter_user t
on
s.twitter_username = t.username
EOQ
}
}
container {
title = "Today's Events"
table {
sql = <<EOQ
select
e.start_date_time,
e.subject,
e.location,
u.name as owner_name,
a.name as account_name,
c.name as contact_name
from
salesforce_event e
join
salesforce_account a on e.account_id = a.id
join
salesforce_contact c on e.who_id = c.id
join
salesforce_user u on e.owner_id = u.id
--where
--e.start_date_time::date = current_date
order by
e.start_date_time desc
EOQ
column "link" {
wrap = "all"
}
}
}
container {
title = "Products"
table {
sql = <<EOQ
select
*
from
salesforce_product
EOQ
}
}
}