Page MenuHomePhabricator

[identity] db method to get users for a set of farcaster ids
ClosedPublic

Authored by varun on Mar 27 2024, 12:41 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Jun 23, 10:34 AM
Unknown Object (File)
Sun, Jun 9, 4:41 AM
Unknown Object (File)
Thu, Jun 6, 7:36 AM
Unknown Object (File)
Thu, Jun 6, 7:36 AM
Unknown Object (File)
Thu, Jun 6, 7:35 AM
Unknown Object (File)
Thu, Jun 6, 7:35 AM
Unknown Object (File)
May 7 2024, 4:14 PM
Unknown Object (File)
Apr 14 2024, 4:53 PM
Subscribers

Details

Summary

we need this method to implement the GetFarcasterUsers RPC

Depends on D11400

Test Plan

Registered some wallet and password users with FIDs, confirmed that their corresponding user info was returned by the db method when called with the same FIDs

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

services/identity/src/database/farcaster.rs
64–84 ↗(On Diff #38379)

this felt messy but wasn't immediately obvious to me how to write it cleaner using the traits from comm_lib

services/identity/src/database/farcaster.rs
30–33 ↗(On Diff #38379)

Wondering if BatchGetItem wouldn't fit better here.
How large the farcaster_ids input would be in a typical scenario?

66–82 ↗(On Diff #38379)

Maybe sth like this? Option<T> implements TryFromAttribute so you can use take_attr() - it returns None when the attribute is missing

bartek requested changes to this revision.Mar 27 2024, 10:54 PM

Requesting changes to discuss possible usage of BatchGetItem

services/identity/src/database/farcaster.rs
21 ↗(On Diff #38379)

Why do you need this tuple struct? I guess it's for distinguishing between proto and db types

This revision now requires changes to proceed.Mar 27 2024, 10:54 PM
bartek added inline comments.
services/identity/src/database/farcaster.rs
30–33 ↗(On Diff #38379)

Okay I realized that BatchGetItem doesn't support indexes so we have to use queries

This revision is now accepted and ready to land.Mar 28 2024, 8:37 AM
services/identity/src/database/farcaster.rs
21 ↗(On Diff #38379)

it's so that i can implement TryFrom<AttributeMap>. I don't own the FarcasterUser type, so I have to wrap it in a type that I do own

30–33 ↗(On Diff #38379)

input could be hundreds or thousands of IDs. i called the RPC with 1000 random IDs and although it took 2.5 seconds to complete my request, it didn't fail.

services/identity/src/database/farcaster.rs
66–82 ↗(On Diff #38379)

this is a lot cleaner, thanks!