From 8117847fde0c0ec6dfe206f68cb4076c7a353440 Mon Sep 17 00:00:00 2001 From: Gediminas Zlatkus Date: Mon, 2 Dec 2019 21:12:44 +0200 Subject: [PATCH] Fix most recent data not being displayed --- CHANGELOG.md | 4 ++++ main.js | 15 ++++++++++----- manifest.json | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f2b0ec9..fb3d21f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 0.2.1 + +* Fixed most recent data not being displayed by adding 24 month limit. + ## 0.2.0 * Added tooltips to show rating values within the charts. diff --git a/main.js b/main.js index b263c98..027c13a 100644 --- a/main.js +++ b/main.js @@ -41,13 +41,18 @@ function fetchStats(userId) { } function fetchStatsHistory(userId) { - const body = new FormData; + const body = new FormData(); body.append("job", 12); body.append("user_no", userId); - body.append("month_begin", 10); - body.append("month_end", 12); - body.append("year_begin", 2017); - body.append("year_end", 2050); + + const now = new Date(); + const year = now.getFullYear(); + const month = now.getMonth() + 1; + body.append("year_begin", year - 2); // GTS API returns up to two years of data + body.append("month_begin", month); + body.append("year_end", year); + body.append("month_end", month); + return fetch("https://www.gran-turismo.com/us/api/gt7sp/profile/", { method: "POST", body }) .then(response => response.json()) .then(({ stats_history }) => stats_history); diff --git a/manifest.json b/manifest.json index 276b3ed..133e183 100644 --- a/manifest.json +++ b/manifest.json @@ -1,5 +1,5 @@ { - "version": "0.2.0", + "version": "0.2.1", "manifest_version": 2, "name": "DR/SR Charts", "description": "See your DR/SR charts under your GT Sport profile.",