๋ฒ๊ทธ ์ค๋ช
์๊ฐ ๋ฒ์ selector์ ์ ํ ๊ฐ๋ฅํ ์ต์
์ 10๋ถ, 30๋ถ, 1์๊ฐ์ด๋ฉฐ, 10์ด ๊ฐ๊ฒฉ์ผ๋ก ๋ฐ์ดํฐ๋ฅผ ๋ฐ์์ค๊ธฐ ๋๋ฌธ์
api ๋ฐ์ดํฐ๋ฅผ ์ฌ๋ฐ๋ฅด๊ฒ ๋ฐ์์ฌ ๊ฒฝ์ฐ 61, 181, 361๊ฐ์ ๋ฐ์ดํฐ๋ค์ด ๋ค์ด์์ผ ํ ๊ฒ์ผ๋ก ๋ณด์
๋๋ค.
ํ์ง๋ง, ์์ ์ ๊ฑฐ์น์ง ์์ ๊ธฐ์กด ์ํ์์ ํด๋น api๋ฅผ ์ฌ์ฉํ๊ฒ ๋ ๋ 1๊ฐ ๋๋ 0๊ฐ์ ๋ฐ์ดํฐ๋ง ๋ค์ด์ค๋ ์ํฉ์ด๋ผ resolvers๋ด pie, timeseries, value ๋ด ์ฝ๋๋ฅผ ํ์ธํ์ฌ ์์ ์ด ํ์ํด ๋ณด์
๋๋ค.
์ฌํ ๋ฐฉ๋ฒ
์๋์ ์ฝ๋๋ฅผ ํตํด์ api ํธ์ถ ํจ์๋ฅผ ๊ตฌํํ์ต๋๋ค.
unixtime ๋จ์ ์๊ฐ์ ์ด ๋จ์๋ก ๋ฃ์์ ๋ ๋ฐ์ดํฐ๊ฐ 0๊ฐ ๋๋ 1๊ฐ๊ฐ ๋ค์ด์ค๋ ์ํฉ์
๋๋ค.
// ํ์ฌ ์๊ฐ์ Unix ์๊ฐ์ผ๋ก ๋ณํ
const currentUnixTime = Math.floor(Date.now() / 1000)
const selectorOption = {
tenMin: 600,
thirtyMin: 1800,
oneHour: 3600
}
const defaultSelector = selectorOption.tenMin
const getTimesHandler = async () => {
const requestData = {
from: currentUnixTime - defaultSelector,
to: currentUnixTime
}
const timeseriesData = await getTimeseries(requestData.from, requestData.to)
console.log(timeseriesData)
}
์์คํ
ํ๊ฒฝ (์ ํ ์ฌํญ)
No response