Skip to content

Commit

Permalink
feat: user model in dbt (#1362)
Browse files Browse the repository at this point in the history
* This just seeds from Farcaster and Lens atm
* Handles are 0, 1, or many, so I decided not to use handles for
  identification, rather a profile ID
  • Loading branch information
ryscheng committed May 3, 2024
1 parent 135ef3d commit de875e3
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 7 deletions.
27 changes: 27 additions & 0 deletions warehouse/dbt/models/intermediate/directory/int_users.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
with farcaster_users as (
select
user_id,
farcaster_id as user_source_id,
"FARCASTER" as user_source,
display_name,
profile_picture_url,
bio,
url
from {{ ref('stg_farcaster__profiles') }}
),

lens_users as (
select
user_id,
lens_profile_id as user_source_id,
"LENS" as user_source,
full_name as display_name,
profile_picture_url,
bio,
"" as url
from {{ ref('stg_lens__profiles') }}
)

select * from farcaster_users
union all
select * from lens_users
15 changes: 15 additions & 0 deletions warehouse/dbt/models/marts/directory/users_v1.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{
config(meta = {
'sync_to_db': True
})
}}

select
users.user_id,
users.user_source_id,
users.user_source,
users.display_name,
users.profile_picture_url,
users.bio,
users.url
from {{ ref('int_users') }} as users
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
#}

select
profiles.fid as fid,
{{ oso_id('"oso"', 'fid') }} as user_id,
cast(profiles.fid as string) as farcaster_id,
profiles.custody_address as custody_address,
JSON_EXTRACT(profiles.data, "$.username") as username,
JSON_EXTRACT(profiles.data, "$.display") as display_name,
JSON_EXTRACT(profiles.data, "$.pfp") as profile_picture_url,
JSON_EXTRACT(profiles.data, "$.bio") as bio,
JSON_EXTRACT(profiles.data, "$.url") as url
json_value(profiles.data, "$.username") as username,
json_value(profiles.data, "$.display") as display_name,
json_value(profiles.data, "$.pfp") as profile_picture_url,
json_value(profiles.data, "$.bio") as bio,
json_value(profiles.data, "$.url") as url
from {{ source("farcaster", "farcaster_profiles") }} as profiles
3 changes: 2 additions & 1 deletion warehouse/dbt/models/staging/lens/stg_lens__profiles.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
#}

select
profiles.profile_id as profile_id,
{{ oso_id('"oso"', 'profile_id') }} as user_id,
profiles.profile_id as lens_profile_id,
profiles.name as full_name,
profiles.bio as bio,
profiles.profile_picture_snapshot_location_url as profile_picture_url,
Expand Down

0 comments on commit de875e3

Please sign in to comment.