r - 使用 Google Core Reporting API 解决 500 服务器错误
问题描述
在这一点上,我完全不知道如何解决我的查询问题。我们已经使用 R 包 RGA 大约一年了,没有任何问题。我有一个脚本,它一直在从 7 个视图中获取数据,根据我们网站上的特定页面匹配会话并将它们汇总到我们的产品中。
这几个月来一直没有问题。不知从何而来,我收到了 503 和 500 个内部服务器错误,我不知道为什么。
我尝试将 fetch.by 状态更改为“月”、“季度”、“年”、“日”等……但我认为初始查询太大了。
我还尝试更改 max.results 选项并一次仅获取一个配置文件 ID。我们有 7 个要处理。
date1 <- as.character(cut(Sys.Date(), "month"))
date1_name <- format(as.Date(date1), format = '%Y%m')
date2 <- as.character(Sys.Date())
date2_name <- format(as.Date(date2), format = '%Y%m')
dimensions <- c("ga:yearMonth"
)
metrics <- c("ga:sessions"
)
filters2 <- "ga:sessions>0"
#fetch trip level data for all users and for the micro-goal segment
# country_short_table
short_unq <- unique(country_short_table$destination)
brand_trip_unique <- unique(trip_country_brand$brand_trip)
brand_trip=1
brand_trip=73
all_sessions <- data.frame()
for (brand_trip in 1:length(brand_trip_unique)){
mkt <- gsub('_.*', '', brand_trip_unique[brand_trip])
trip <- gsub('.*_', '', brand_trip_unique[brand_trip])
id <- as.character(ids[ids$market==mkt, 'id'])
segment <- paste('ga:pagePath=~(reisen|circuit)/.*/', trip, sep = '')
segment_def <- paste('users::condition::',segment,sep = '')
table <- get_ga(profileId = id,
start.date = date1,
end.date = date2,
metrics = metrics,
dimensions = dimensions
,filters = filters2
,segment = segment_def
,samplingLevel = "HIGHER_PRECISION"
,fetch.by = "quarter"
,max.results = NULL
)
if (is.list(table)==T) {
table$trip <- trip
table$market <- mkt
all_sessions <- bind_rows(all_sessions, table)
} else {
next()
}
}
目标:你能推荐任何我可以避免这个问题的方法,也许是通过分隔日期查询并按月的几周或几天循环它们?我需要每天汇总每月数据,但我不确定如何编辑我继承的这个脚本。
解决方案
推荐阅读
- r - 选择 R 中均值最高的组
- vue.js - 前端/后端路由配置
- android - 升级到 AndroidX 和 Android Studio 4.0 后出现 java.lang.ClassNotFoundException 错误
- terraform - 我应该如何在多 pod 中使用 terraform?
- r - 如何匹配另一个数据集范围内的行
- android - 如何保护我用于加密数据的密钥?
- python - python -> ocrmypdf 包转换为可执行文件
- atom-editor - Windows 10 上的原子氢:未安装内核
- spring-cloud - 使用 Spring Cloud Bus Kafka 的多个实例
- python-3.x - 从 Python 中的 XSD 文件中提取带有文档的枚举