fix redis connection. fix delete account

This commit is contained in:
Brian Cao 2022-09-01 11:11:11 -07:00
parent 12704c81e5
commit afe6d8994b
3 changed files with 15 additions and 7 deletions

2
.gitignore vendored
View File

@ -36,5 +36,5 @@ yarn-error.log*
.env.test.local .env.test.local
.env.production.local .env.production.local
*.development.yml *.dev.yml

View File

@ -9,6 +9,10 @@ const INITIALIZED = 'redis:initialized';
export const DELETED = 'deleted'; export const DELETED = 'deleted';
function getClient() { function getClient() {
if (!process.env.REDIS_URL) {
return null;
}
const redis = new Redis(process.env.REDIS_URL); const redis = new Redis(process.env.REDIS_URL);
if (process.env.NODE_ENV !== 'production') { if (process.env.NODE_ENV !== 'production') {

View File

@ -4,12 +4,16 @@ import redis, { DELETED } from 'lib/redis';
export async function deleteAccount(user_id) { export async function deleteAccount(user_id) {
const { client } = prisma; const { client } = prisma;
const websiteUuids = await client.website const websites = await client.website.findMany({
.findMany({
where: { user_id }, where: { user_id },
select: { website_uuid: true }, select: { website_uuid: true },
}) });
.map(a => a.website_uuid);
let websiteUuids = [];
if (websites.length > 0) {
websiteUuids = websites.map(a => a.website_uuid);
}
return client return client
.$transaction([ .$transaction([