Slide 25
Slide 25 text
݄ؒͷ17Λूܭ͢Δαϯϓϧίʔυ
function countMonthlyUser(year, month) {
const from = `${zeroFill(year, 4)}${zeroFill(month, 2)}01`
const toDate = new Date(year, month, 0)
const to = `${zeroFill(year, 4)}${zeroFill(month, 2)}${zeroFill(toDate.getDate(), 2)}`
const query = `SELECT
FORMAT_TIMESTAMP("%Y-%m", TIMESTAMP_MICROS(event_timestamp), "Asia/Tokyo") AS date
, COUNT(distinct if(user_id IS NOT NULL, user_id, user_pseudo_id)) AS count_user
FROM \`${tableName}.events_*\`
WHERE _TABLE_SUFFIX BETWEEN '${from}' AND '${to}'
GROUP BY
date
`
const request = {
query: query,
useLegacySql: false
}
const result = BigQuery.Jobs.query(request, projectId)
if (!result || !result.rows) {
return 0
} else if (result.rows.length == 0) {
return 0
} else {
if (result.rows[0].f.length == 0) {
return 0
} else {
return result.rows[0].f[1].v
}
}
}
IUUQTHJUIVCDPNGSPNLL4BNQMF#JH2VFSZ8JUI4QSFBETIFFU