Last active
December 25, 2015 10:49
-
-
Save Akiyah/6964690 to your computer and use it in GitHub Desktop.
あるサービスのDAU(Daily Active Users)をHRForecastに登録するサンプル
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# install.packages('httpRequest') # 未インストールの場合 | |
require('httpRequest') | |
dau <- function(date) { | |
# 本当はデータベースなどから集計してDAUを出すが、ここではサンプルのため乱数にしている | |
value <- floor(runif(1) * 1000) | |
} | |
plot_dau <- function(date) { | |
value <- dau(date) | |
data <- paste0("number=", value, "&datetime=", date) | |
path <- "/api/team1/service1/dau" # グラフの名前 | |
simplePostToHost("localhost", path, "", data, "5127") # HRForecastにPOSTする | |
} | |
plot_dau(Sys.Date()) # 今日の分 | |
plot_dau(Sys.Date() - 1) # 昨日の分 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment