Merged in fix/reward-remove-cache (pull request #1542)
fix(reward): remove cache from profile service * fix(reward): remove cache from profile service Approved-by: Anton Gunnarsson
This commit is contained in:
@@ -10,8 +10,6 @@ import {
|
|||||||
} from "@/server/trpc"
|
} from "@/server/trpc"
|
||||||
import { langInput } from "@/server/utils"
|
import { langInput } from "@/server/utils"
|
||||||
|
|
||||||
import { getCacheClient } from "@/services/dataCache"
|
|
||||||
|
|
||||||
import { getAllLoyaltyLevels, getLoyaltyLevel } from "../loyaltyLevel/query"
|
import { getAllLoyaltyLevels, getLoyaltyLevel } from "../loyaltyLevel/query"
|
||||||
import {
|
import {
|
||||||
rewardsAllInput,
|
rewardsAllInput,
|
||||||
@@ -174,11 +172,6 @@ export const rewardQueryRouter = router({
|
|||||||
? api.endpoints.v1.Profile.Reward.reward
|
? api.endpoints.v1.Profile.Reward.reward
|
||||||
: api.endpoints.v1.Profile.reward
|
: api.endpoints.v1.Profile.reward
|
||||||
|
|
||||||
const cacheClient = await getCacheClient()
|
|
||||||
|
|
||||||
return cacheClient.cacheOrGet(
|
|
||||||
endpoint,
|
|
||||||
async () => {
|
|
||||||
const apiResponse = await api.get(endpoint, {
|
const apiResponse = await api.get(endpoint, {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${ctx.session.token.access_token}`,
|
Authorization: `Bearer ${ctx.session.token.access_token}`,
|
||||||
@@ -295,18 +288,13 @@ export const rewardQueryRouter = router({
|
|||||||
: [],
|
: [],
|
||||||
couponCode: firstRedeemableCouponToExpire,
|
couponCode: firstRedeemableCouponToExpire,
|
||||||
coupons:
|
coupons:
|
||||||
apiReward && "coupon" in apiReward
|
apiReward && "coupon" in apiReward ? apiReward.coupon || [] : [],
|
||||||
? apiReward.coupon || []
|
|
||||||
: [],
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
getCurrentRewardSuccessCounter.add(1)
|
getCurrentRewardSuccessCounter.add(1)
|
||||||
|
|
||||||
return { rewards }
|
return { rewards }
|
||||||
},
|
|
||||||
"1h"
|
|
||||||
)
|
|
||||||
}),
|
}),
|
||||||
surprises: contentStackBaseWithProtectedProcedure
|
surprises: contentStackBaseWithProtectedProcedure
|
||||||
.input(langInput.optional()) // lang is required for client, but not for server
|
.input(langInput.optional()) // lang is required for client, but not for server
|
||||||
@@ -318,10 +306,6 @@ export const rewardQueryRouter = router({
|
|||||||
? api.endpoints.v1.Profile.Reward.reward
|
? api.endpoints.v1.Profile.Reward.reward
|
||||||
: api.endpoints.v1.Profile.reward
|
: api.endpoints.v1.Profile.reward
|
||||||
|
|
||||||
const cacheClient = await getCacheClient()
|
|
||||||
return await cacheClient.cacheOrGet(
|
|
||||||
endpoint,
|
|
||||||
async () => {
|
|
||||||
const apiResponse = await api.get(endpoint, {
|
const apiResponse = await api.get(endpoint, {
|
||||||
cache: undefined,
|
cache: undefined,
|
||||||
headers: {
|
headers: {
|
||||||
@@ -429,9 +413,6 @@ export const rewardQueryRouter = router({
|
|||||||
.flatMap((surprises) => (surprises ? [surprises] : []))
|
.flatMap((surprises) => (surprises ? [surprises] : []))
|
||||||
|
|
||||||
return surprises
|
return surprises
|
||||||
},
|
|
||||||
"1h"
|
|
||||||
)
|
|
||||||
}),
|
}),
|
||||||
unwrap: protectedProcedure
|
unwrap: protectedProcedure
|
||||||
.input(rewardsUpdateInput)
|
.input(rewardsUpdateInput)
|
||||||
|
|||||||
Reference in New Issue
Block a user