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)
Fri, Nov 29, 5:35 AM
Unknown Object (File)
Wed, Nov 13, 5:28 AM
Unknown Object (File)
Tue, Nov 12, 9:52 PM
Unknown Object (File)
Mon, Nov 4, 1:55 PM
Unknown Object (File)
Oct 22 2024, 2:47 PM
Unknown Object (File)
Oct 22 2024, 2:47 PM
Unknown Object (File)
Oct 22 2024, 2:44 PM
Unknown Object (File)
Oct 11 2024, 11:31 AM
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
No Lint Coverage
Unit
No Test Coverage

Event Timeline

services/identity/src/database/farcaster.rs
64–84

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

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

66–82

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

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

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

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

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

this is a lot cleaner, thanks!