Skip to content

Commit

Permalink
optionally clear cache with query param
Browse files Browse the repository at this point in the history
  • Loading branch information
markdturner committed Aug 29, 2024
1 parent 1fa5ba9 commit 093d15c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/api/timesheet/services/timesheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const clockifyConfig = {
headers: {
"X-Api-Key": process.env.CLOCKIFY_KEY,
},
id: 'clockify',
cache: {
// one hour
maxAge: 60 * 60 * 1000
Expand All @@ -25,6 +26,7 @@ const leaveConfig = {
headers: {
Authorization: `Bearer ${process.env.LEAVE_API_TOKEN}`
},
id: 'leave',
cache: {
// one hour
maxAge: 60 * 60 * 1000
Expand Down Expand Up @@ -89,7 +91,15 @@ module.exports = {

const year = query ? Number(query.filters.year.$eq) : null,
userIDs = query.filters.userIDs ? query.filters.userIDs.$in : null,
projectIDs = query.filters.projectIDs ? query.filters.projectIDs.$in : null
projectIDs = query.filters.projectIDs ? query.filters.projectIDs.$in : null,
clearCache = query.clearCache && query.clearCache === 'true' ? true : false

console.log('clearCache:', clearCache)

if (clearCache) {
await axios.storage.remove('clockify')
await axios.storage.remove('leave')
}

const response = await fetchDetailedReport(year, userIDs, projectIDs)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"name": "Apache 2.0",
"url": "https://www.apache.org/licenses/LICENSE-2.0.html"
},
"x-generation-date": "2024-08-29T19:41:29.757Z"
"x-generation-date": "2024-08-29T19:49:13.196Z"
},
"x-strapi-config": {
"path": "/documentation",
Expand Down

0 comments on commit 093d15c

Please sign in to comment.