Skip to content

Commit

Permalink
Fixes bug with the cache
Browse files Browse the repository at this point in the history
  • Loading branch information
paulpopus committed May 25, 2023
1 parent 30d4f9f commit af4a21a
Show file tree
Hide file tree
Showing 9 changed files with 1,746 additions and 1,438 deletions.
4 changes: 2 additions & 2 deletions demo/src/payload.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import Tags from "./collections/Tags";
import Users from "./collections/Users";
import Media from "./collections/Media";
import Homepage from "./globals/Homepage";
import dashboardAnalytics from "../../dist/index";
import dashboardAnalytics from "../../src/index";

import { PlausibleProvider, GoogleProvider } from "../../dist/types/providers";
import { PlausibleProvider, GoogleProvider } from "../../src/types/providers";

const PLAUSIBLE_API_KEY = process.env.PLAUSIBLE_API_KEY;
const PLAUSIBLE_HOST = process.env.PLAUSIBLE_HOST;
Expand Down
1,552 changes: 859 additions & 693 deletions demo/yarn.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/routes/getGlobalAggregate/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ const handler = (provider: ApiProvider, options: RouteOptions) => {
if (cachedData) {
if (
differenceInMinutes(
Date.parse(cachedData.cacheTimestamp),
timeNow
timeNow,
Date.parse(cachedData.cacheTimestamp)
) > cacheLifetime
) {
const data = await provider
Expand Down
4 changes: 2 additions & 2 deletions src/routes/getGlobalChart/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ const handler = (provider: ApiProvider, options: RouteOptions) => {
if (cachedData) {
if (
differenceInMinutes(
Date.parse(cachedData.cacheTimestamp),
timeNow
timeNow,
Date.parse(cachedData.cacheTimestamp)
) > cacheLifetime
) {
const data = await provider
Expand Down
4 changes: 2 additions & 2 deletions src/routes/getLive/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ const handler = (provider: ApiProvider, options: RouteOptions) => {
if (cachedData) {
if (
differenceInMinutes(
Date.parse(cachedData.cacheTimestamp),
timeNow
timeNow,
Date.parse(cachedData.cacheTimestamp)
) > cacheLifetime
) {
const data = await provider.getLiveData({});
Expand Down
4 changes: 2 additions & 2 deletions src/routes/getPageAggregate/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ const handler = (provider: ApiProvider, options: RouteOptions) => {
if (cachedData) {
if (
differenceInMinutes(
Date.parse(cachedData.cacheTimestamp),
timeNow
timeNow,
Date.parse(cachedData.cacheTimestamp)
) > cacheLifetime
) {
const data: AggregateData = await provider
Expand Down
4 changes: 2 additions & 2 deletions src/routes/getPageChart/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ const handler = (provider: ApiProvider, options: RouteOptions) => {
if (cachedData) {
if (
differenceInMinutes(
Date.parse(cachedData.cacheTimestamp),
timeNow
timeNow,
Date.parse(cachedData.cacheTimestamp)
) > cacheLifetime
) {
const data: ChartData = await provider
Expand Down
4 changes: 2 additions & 2 deletions src/routes/getReport/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ const handler = (provider: ApiProvider, options: RouteOptions) => {
if (cachedData) {
if (
differenceInMinutes(
Date.parse(cachedData.cacheTimestamp),
timeNow
timeNow,
Date.parse(cachedData.cacheTimestamp)
) > cacheLifetime
) {
const data = await provider
Expand Down
1,604 changes: 873 additions & 731 deletions yarn.lock

Large diffs are not rendered by default.

0 comments on commit af4a21a

Please sign in to comment.