Skip to content

Commit

Permalink
fix redis connection. fix delete account
Browse files Browse the repository at this point in the history
  • Loading branch information
briancao committed Sep 1, 2022
1 parent 12704c8 commit afe6d89
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ yarn-error.log*
.env.test.local
.env.production.local

*.development.yml
*.dev.yml

4 changes: 4 additions & 0 deletions lib/redis.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ const INITIALIZED = 'redis:initialized';
export const DELETED = 'deleted';

function getClient() {
if (!process.env.REDIS_URL) {
return null;
}

const redis = new Redis(process.env.REDIS_URL);

if (process.env.NODE_ENV !== 'production') {
Expand Down
16 changes: 10 additions & 6 deletions queries/admin/account/deleteAccount.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@ import redis, { DELETED } from 'lib/redis';
export async function deleteAccount(user_id) {
const { client } = prisma;

const websiteUuids = await client.website
.findMany({
where: { user_id },
select: { website_uuid: true },
})
.map(a => a.website_uuid);
const websites = await client.website.findMany({
where: { user_id },
select: { website_uuid: true },
});

let websiteUuids = [];

if (websites.length > 0) {
websiteUuids = websites.map(a => a.website_uuid);
}

return client
.$transaction([
Expand Down

0 comments on commit afe6d89

Please sign in to comment.