Q.uuid <- "select uuid, storeId, downloaddate from fact_analytics_ingestion_history where status = 'ingested';"
uuid <- runQry(Q.uuid)

ignore <- c(497, 440)

uuid <- uuid[storeid %ni% ignore]
setkey(uuid, storeid, downloaddate)


miniQs <- function(tbl, store, uuids) {
  if (length(tbl) != 1)
    stop ("`tbl` should be exactly length 1")
  if (length(store) != 1)
    stop ("`store` should be exactly length 1")
  if (!(length(uuids) >= 1))
    stop ("`uuids` should have at least length 1")

  paste("select count (*), storeid, uuid from ", tbl, 
        " where storeid =", store, " and uuid in ", pasteQ(uuids), 
        " group by storeid, uuid" 
        )
}


Qs <- miniQs("fact_analytics", 487, c("3460adbcfbd4b35f6d9a5f9d64377772", "c692c6f066b5a59030109fb8e4f4b7d7"))

# lapply(Qs, runQry)

analytics      <- runQry(" x SELECT count(*), storeId From fact_analytics")

qShowCols("fact_analytics")


 [1] "artistid"          "dayid"             "labelid"           "storeid"           "genreid"
 [6] "releaseid"         "trackid"           "countryid"         "transactiontypeid" "zipid"
[11] "catalogid"         "isrcid"            "imprintid"         "currencyid"        "storeuserid"
[16] "processeddaytime"  "royalty"           "royaltydollar"     "units"             "paidunits"
[21] "freeunits"         "uuid"              "subaccountid"


#  
#  
#  analytics      <- runQry("SELECT * From fact_analytics")
#  (analytics.err <- runQry("SELECT * From fact_analytics_error"))
#  
#  setkey(analytics, storeid, processeddaytime)
#  setkey(analytics.err, storeid, processeddaytime)
#  
#  
#  are(analytics, tight=TRUE)
#  are(analytics.err, tight=TRUE)
#  compareDTs(analytics.err, analytics)
#  
#  
#  ===============
#  
