"'''This file was to check what xoxo records went through our system
    to send to Pascal

'''"


setCluster(9)
qShowCols("label")
get_label_meta(name="%xoxo%")


ids.xo <- get_label_id("xoxo")


colsToPull.main <- c("labelid", "releaseid", "countryid", "storeid")
colsToAgg=".RU"
whereIn <- list(labelid = ids.xo, releaseid="880270110520", conjunction="OR")
minDate <- "2014-01-01"


dateCol <- "activityperiodid"
colsToPull=c(dateCol, colsToPull.main)
DT.xoxo_sales <- makeQry(tbl="fact_sales", colsToPull=colsToPull, colsToAgg=colsToAgg, dateCol=dateCol, minDate=minDate, whereIn=whereIn) %>% runQry(verbose.max.width=90) %>% addAllMeta_(showWarnings=FALSE)
DT.xoxo_sales[, lapply(.SD, sumn), .SD=c("revenue", "units"), keyby=list(labelid, artist_name, releaseid, release_name, store_name)]

## ---------- 

dateCol <- "download_activity_date"
colsToPull=c(dateCol, colsToPull.main)
DT.xoxo_analytics <- makeQry(tbl="fact_analytics", colsToPull=colsToPull, colsToAgg=colsToAgg, dateCol=dateCol, minDate=minDate, whereIn=whereIn) %>% runQry(verbose.max.width=90, firstOfMonth=TRUE) %>% addAllMeta_(showWarnings=FALSE)
DT.xoxo_analytics[, lapply(.SD, sumn), .SD=c("revenue", "units"), keyby=list(labelid, artist_name, releaseid, release_name, store_name)]


