Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
csalvato committed Jun 10, 2016
2 parents 3888ac6 + f56e4d6 commit 4299222
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion PowerSupplyUtilities/R/create_google_display_event_log.r
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ create_google_display_event_log <- function(from=Sys.Date(),

# Retrieve revenue data
db_transactions <- get_transactions_data(from=from, to=to)
#db_influencer_metrics <- get_referrals_data(from=from, to=to)
db_influencer_metrics <- get_referrals_data(from=from, to=to)
db_first_transactions <- get_first_transaction_dates_for_users(from=from, to=to, users=db_transactions$app_user_id)

# Join Mixpanel Conversion Data with transaction data
Expand Down
2 changes: 2 additions & 0 deletions PowerSupplyUtilities/R/search_engine_marketing_report.r
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ search_engine_marketing_report <- function( adwords_keywords_elog=NULL,
AdWordsUtilities::overall_performance_over_time(gdn_elog)
AdWordsUtilities::desktop_gdn_performance_over_time(gdn_elog)
AdWordsUtilities::mobile_gdn_performance_over_time(gdn_elog)
PowerSupplyUtilities::orders_per_week(gdn_elog,
campaign_filter="Rmktg")

}

Expand Down
21 changes: 13 additions & 8 deletions transactions_query.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
, u.name as user_name
, u.id as app_user_id
, t.discount_amount
, ti.credit_used
, t.credit
, t.sales_tax_amount
, (CASE t.refunded
WHEN 't' THEN
Expand All @@ -17,12 +17,15 @@
ELSE
ti.price - t.sales_tax_amount + t.discount_amount
END) as retail_price
, (CASE t.refunded
WHEN 't' THEN
0
ELSE
ti.price - ti.credit_used
END) as money_in_the_bank_paid_to_us
, (CASE
WHEN t.refunded = 't' THEN
0
WHEN t.credit > 0 THEN
ti.price - t.credit
ELSE
ti.price
END
) as money_in_the_bank_paid_to_us
, (CASE
WHEN d.type = 'GiftCard'
THEN 'Gift Card'
Expand All @@ -41,5 +44,7 @@
inner join
users u on t.user_id = u.id
where
t.created_at between '@{start_date}' and '@{end_date}'
t.created_at between date'@{start_date}' and (date '@{end_date}' + integer '1')
and t.complete = TRUE
-- Adding 1 makes sure that no values are cut off by time zones.
order by t.created_at desc"

0 comments on commit 4299222

Please sign in to comment.