Skip to content

Commit

Permalink
feat: mark hey score as 0 for suspended accounts (#4912)
Browse files Browse the repository at this point in the history
  • Loading branch information
bigint authored May 15, 2024
2 parents ba29621 + 2fa73da commit 9117112
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions apps/api/src/routes/score/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import lensPg from 'src/db/lensPg';
import catchedError from 'src/helpers/catchedError';
import {
SCORE_WORKER_URL,
SWR_CACHE_AGE_1_HOUR_12_HRS
SUSPENDED_FEATURE_ID,
SWR_CACHE_AGE_1_HOUR_12_HRS,
SWR_CACHE_AGE_10_MINS_30_DAYS
} from 'src/helpers/constants';
import { noBody } from 'src/helpers/responses';
import calculateAdjustments from 'src/helpers/score/calculateAdjustments';
Expand All @@ -21,14 +23,22 @@ export const get: Handler = async (req, res) => {
}

try {
const [cachedProfile, pro] = await heyPg.multi(
const [cachedProfile, pro, suspended] = await heyPg.multi(
`
SELECT * FROM "CachedProfileScore" WHERE "id" = $1 LIMIT 1;
SELECT * FROM "Pro" WHERE "id" = $1 LIMIT 1;
SELECT * FROM "ProfileFeature" WHERE enabled = TRUE AND "featureId" = $2 AND "profileId" = $1;
`,
[id as string]
[id as string, SUSPENDED_FEATURE_ID]
);

if (suspended.length > 0) {
return res
.status(200)
.setHeader('Cache-Control', SWR_CACHE_AGE_10_MINS_30_DAYS)
.json({ score: 0, success: true });
}

if (
cachedProfile[0]?.expiresAt &&
new Date() < cachedProfile[0].expiresAt
Expand Down

1 comment on commit 9117112

@vercel
Copy link

@vercel vercel bot commented on 9117112 May 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

web – ./apps/web

web-heyxyz.vercel.app
hey.xyz
heyxyz.vercel.app
web-git-main-heyxyz.vercel.app

Please sign in to comment.