Page MenuHomePhabricator

[keyserver] fetchUsernames helper function
ClosedPublic

Authored by varun on Jun 27 2023, 7:29 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Apr 21, 2:53 AM
Unknown Object (File)
Sun, Apr 6, 5:44 PM
Unknown Object (File)
Sun, Apr 6, 5:43 PM
Unknown Object (File)
Sun, Apr 6, 5:43 PM
Unknown Object (File)
Fri, Apr 4, 6:22 PM
Unknown Object (File)
Feb 22 2025, 7:31 AM
Unknown Object (File)
Feb 18 2025, 3:36 AM
Unknown Object (File)
Jan 17 2025, 7:52 AM
Subscribers

Details

Summary

gets all the usernames from the users table

Test Plan

tested with subsequent diff

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

varun requested review of this revision.Jun 27 2023, 7:46 AM

Let's rename fetchUsernames to fetchAllUsernames before landing.

keyserver/src/fetchers/user-fetchers.js
377

Can we rename this to fetchAllUsernames so it's a little clearer + symmetric w/ fetchAllUserIDs above

379–383

In fetchAllUserIDs, we do:

const query = SQL`SELECT id FROM users`;
const [result] = await dbQuery(query);
return result.map(row => row.id.toString());

can we match that? Up to you

This revision is now accepted and ready to land.Jun 27 2023, 9:14 AM
keyserver/src/fetchers/user-fetchers.js
379–383

If the result is empty, I think your suggested code will throw an error because you can't call map on undefined. I'm guessing this is fine for id since it's the primary key, but I don't think it is for username

keyserver/src/fetchers/user-fetchers.js
379–383

@varun I don't follow your reasoning. If you're afraid that result can be null or undefined, then the same risk occurs on line 380, when you call result.length.

In fact, result should never be null or undefined... if dbQuery encounters an error then it will throw, and if it doesn't then result will be an array.

keyserver/src/fetchers/user-fetchers.js
379–383

ah fair. i'll change this

This revision was automatically updated to reflect the committed changes.