Skip to content

Commit

Permalink
hotfix: return only user if exists (#890)
Browse files Browse the repository at this point in the history
  • Loading branch information
wa0x6e authored Jul 15, 2024
1 parent 93da3f6 commit 0fdc458
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/graphql/operations/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,9 @@ import { formatUser, formatAddresses, PublicError } from '../helpers';
export default async function (parent, args) {
const addresses = formatAddresses([args.id]);
if (!addresses.length) throw new PublicError('Invalid address');
const query = `
SELECT
u.*,
SUM(l.vote_count) as votesCount,
SUM(l.proposal_count) as proposalsCount,
MAX(l.last_vote) as lastVote
FROM users u
LEFT JOIN leaderboard l ON l.user = u.id
WHERE id = ?
LIMIT 1`;

const query = `SELECT u.* FROM users u WHERE id = ? LIMIT 1`;

try {
const users = await db.queryAsync(query, addresses[0]);
if (users.length === 1) return formatUser(users[0]);
Expand Down

0 comments on commit 0fdc458

Please sign in to comment.