-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
84 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 50 additions & 10 deletions
60
warehouse/dbt/models/marts/superchain/rf4_trusted_users.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,81 @@ | ||
with eigentrust_top_users as ( | ||
{# draft model for testing #} | ||
select farcaster_id | ||
select CAST(farcaster_id as string) as farcaster_id | ||
from {{ ref('stg_karma3__globaltrust') }} | ||
where | ||
snapshot_time = '2024-05-01' | ||
snapshot_time = '2024-05-21' | ||
and strategy_id = 1 | ||
order by eigentrust_rank desc | ||
limit 50000 | ||
), | ||
|
||
web_of_trust as ( | ||
select CAST(fof_id as string) as farcaster_id | ||
from ( | ||
select | ||
l2.peer_farcaster_id as fof_id, | ||
COUNT(distinct l1.peer_farcaster_id) as edge_count | ||
from {{ ref('stg_karma3__localtrust') }} as l1 | ||
left join {{ ref('stg_karma3__localtrust') }} as l2 | ||
on l1.peer_farcaster_id = l2.farcaster_id | ||
where | ||
l1.farcaster_id = 5650 | ||
and l1.strategy_id = 1 | ||
and l2.strategy_id = 1 | ||
group by l2.peer_farcaster_id | ||
) | ||
where edge_count > 1 | ||
), | ||
|
||
user_model as ( | ||
select | ||
artifacts_by_user.user_id, | ||
artifacts_by_user.user_source, | ||
artifacts_by_user.user_source_id, | ||
artifacts_by_user.artifact_name, | ||
CAST( | ||
eigentrust_top_users.farcaster_id | ||
is not null as bool | ||
artifacts_by_user.user_source_id < '20939' | ||
as int64 | ||
) as farcaster_prepermissionless, | ||
CAST( | ||
eigentrust_top_users.farcaster_id is not null | ||
as int64 | ||
) as eigentrust_verification, | ||
CAST( | ||
passport_scores.evidence_rawscore | ||
>= passport_scores.evidence_threshold as bool | ||
web_of_trust.farcaster_id is not null | ||
as int64 | ||
) as vitalik_verification, | ||
CAST( | ||
COALESCE( | ||
passport_scores.evidence_rawscore | ||
>= passport_scores.evidence_threshold, | ||
false | ||
) | ||
as int64 | ||
) as passport_verification | ||
from {{ ref('int_artifacts_by_user') }} as artifacts_by_user | ||
left join {{ ref('stg_passport__scores') }} as passport_scores | ||
on artifacts_by_user.artifact_name = passport_scores.passport_address | ||
left join eigentrust_top_users | ||
on artifacts_by_user.user_source_id = eigentrust_top_users.farcaster_id | ||
left join web_of_trust | ||
on artifacts_by_user.user_source_id = web_of_trust.farcaster_id | ||
) | ||
|
||
select | ||
user_id, | ||
user_source, | ||
user_source_id, | ||
artifact_name | ||
artifact_name, | ||
farcaster_prepermissionless, | ||
eigentrust_verification, | ||
vitalik_verification, | ||
passport_verification, | ||
( | ||
farcaster_prepermissionless | ||
+ eigentrust_verification | ||
+ vitalik_verification | ||
+ passport_verification | ||
>= 1 | ||
) as is_trusted_user | ||
from user_model | ||
where | ||
passport_verification is true | ||
or eigentrust_verification is true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 18 additions & 2 deletions
20
warehouse/dbt/models/staging/karma3/stg_karma3__localtrust.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,27 @@ | ||
{# | ||
Get all Karma3 EigenTrust scores | ||
for Farcaster IDs | ||
for Farcaster IDs - Local Trust | ||
#} | ||
|
||
{{ | ||
config( | ||
materialized='table', | ||
partition_by={ | ||
"field": "farcaster_id", | ||
"data_type": "int64", | ||
"range": { | ||
"start": 0, | ||
"end": 1000000, | ||
"interval": 25000 | ||
} | ||
} | ||
) | ||
}} | ||
|
||
select | ||
strategy_id, | ||
CAST(i as string) as farcaster_id, | ||
i as farcaster_id, | ||
j as peer_farcaster_id, | ||
CAST(v as numeric) as eigentrust_rank, | ||
CAST(date as timestamp) as snapshot_time | ||
from {{ source("karma3", "localtrust") }} |