Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSO query updates #150

Open
wants to merge 1 commit into
base: impact-metrics
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/server/api/routers/metrics/utils/getProjects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export async function getProjects({
project_name: { _in: Object.keys(tempProjectMap) },
event_source: { _eq: "BASE" },
},
orderBy: [{ active_contract_count_90_days: "desc" }],
orderBy: [{ activeContractCount90Days: "desc" }],
limit: 300,
offset: 0,
};
Expand All @@ -37,7 +37,7 @@ export async function getProjects({
const projectMetricsMap: ProjectIdToMetricsMap = Object.fromEntries(
projects.map((project) => {
// Replace with correct projectId
const projectId = tempProjectMap[project.project_name] ?? "";
const projectId = tempProjectMap[project.projectName] ?? "";
const metrics = metricIds.reduce<ProjectMetrics>(
(acc, metricId) => ({
...acc,
Expand Down
72 changes: 36 additions & 36 deletions src/types/metrics.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
export enum AvailableMetrics {
active_contract_count_90_days = "Active Contract Count (90 Days)",
address_count = "Address Count",
address_count_90_days = "Address Count (90 Days)",
days_since_first_transaction = "Days Since First Transaction",
gas_fees_sum = "Gas Fees Sum",
gas_fees_sum_6_months = "Gas Fees Sum (6 Months)",
high_activity_address_count_90_days = "High Activity Address Count (90 Days)",
low_activity_address_count_90_days = "Low Activity Address Count (90 Days)",
medium_activity_address_count_90_days = "Medium Activity Address Count (90 Days)",
multi_project_address_count_90_days = "Multi Project Address Count (90 Days)",
new_address_count_90_days = "New Address Count (90 Days)",
returning_address_count_90_days = "Returning Address Count (90 Days)",
transaction_count = "Transaction Count",
transaction_count_6_months = "Transaction Count (6 Months)",
activeContractCount90Days = "Active Contract Count (90 Days)",
addressCount = "Address Count",
addressCount90Days = "Address Count (90 Days)",
daysSinceFirstTransaction = "Days Since First Transaction",
gasFeesSum = "Gas Fees Sum",
gasFeesSum6Months = "Gas Fees Sum (6 Months)",
highActivityAddressCount90Days = "High Activity Address Count (90 Days)",
lowActivityAddressCount90Days = "Low Activity Address Count (90 Days)",
mediumActivityAddressCount90Days = "Medium Activity Address Count (90 Days)",
multiProjectAddressCount90Days = "Multi Project Address Count (90 Days)",
newAddressCount90Days = "New Address Count (90 Days)",
returningAddressCount90Days = "Returning Address Count (90 Days)",
transactionCount = "Transaction Count",
transactionCount6Months = "Transaction Count (6 Months)",
}

export type OSOMetric = {
active_contract_count_90_days: number;
address_count: number;
address_count_90_days: number;
days_since_first_transaction: number;
gas_fees_sum: number;
gas_fees_sum_6_months: number;
high_activity_address_count_90_days: number;
low_activity_address_count_90_days: number;
medium_activity_address_count_90_days: number;
multi_project_address_count_90_days: number;
new_address_count_90_days: number;
returning_address_count_90_days: number;
transaction_count: number;
transaction_count_6_months: number;
activeContractCount90Days: number;
addressCount: number;
addressCount90Days: number;
daysSinceFirstTransaction: number;
gasFeesSum: number;
gasFeesSum6Months: number;
highActivityAddressCount90Days: number;
lowActivityAddressCount90Days: number;
mediumActivityAddressCount90Days: number;
multiProjectAddressCount90Days: number;
newAddressCount90Days: number;
returningAddressCount90Days: number;
transactionCount: number;
transactionCount6Months: number;
};

export type MetricId = keyof OSOMetric;
Expand All @@ -41,19 +41,19 @@ export type Metric = {
};

type OSOMetricProjectMeta = {
event_source: string;
display_name: string;
project_id: string;
project_name: string;
project_namespace: string;
project_source: string;
eventSource: string;
displayName: string;
projectId: string;
projectName: string;
projectNamespace: string;
projectSource: string;
};

export type OSOMetrics = (OSOMetric & OSOMetricProjectMeta)[];

export type OSOMetricCSVProjectMeta = {
project_name: string;
project_id: string;
projectName: string;
projectId: string;
};

export type OSOMetricsCSV = OSOMetricCSVProjectMeta & OSOMetric;
20 changes: 10 additions & 10 deletions src/utils/fetchMetrics/fetchImpactMetrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@ const fetch = createCachedFetch({ ttl: 1000 * 60 * 10 });

function createMetricsQuery(metrics: string[]) {
return `
query Metrics(
$where: onchain_metrics_by_project_v1_bool_exp,
$orderBy: [onchain_metrics_by_project_v1_order_by!],
query Oso_onchainMetricsByProjectV1(
$where: Oso_OnchainMetricsByProjectV1BoolExp,
$orderBy: [Oso_OnchainMetricsByProjectV1OrderBy!],
$limit: Int,
$offset: Int) {
onchain_metrics_by_project_v1(
oso_onchainMetricsByProjectV1(
where: $where
order_by: $orderBy
limit: $limit
offset: $offset
) {
event_source
display_name
project_id
project_name
project_namespace
project_source
eventSource
displayName
projectId
projectName
projectNamespace
projectSource

${metrics.join("\n")}
}
Expand Down
4 changes: 2 additions & 2 deletions src/utils/fetchMetrics/types.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
type OrderBy = "asc" | "desc";
type OrderBy = "Asc" | "Desc";
export type ImpactMetricsQuery = {
where: {
project_name: { _in: string[] };
event_source: { _eq: "BASE" };
};
orderBy: { active_contract_count_90_days: OrderBy }[];
orderBy: { activeContractCount90Days: OrderBy }[];
limit: number;
offset: number;
};
Expand Down