Skip to content

Commit 703aeb2

Browse files
committed
Extend /home with tz4 and dal bakers count
1 parent a7ecc63 commit 703aeb2

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

Tzkt.Api/Models/Home/AccountsData.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,7 @@ public class AccountsData
77
public int ActiveAccounts { get; set; }
88
public int PublicAccounts { get; set; }
99
public int TotalContracts { get; set; }
10+
public int TotalTz4Bakers { get; set; }
11+
public int TotalDalBakers { get; set; }
1012
}
1113
}

Tzkt.Api/Services/Home/HomeService.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,21 @@ async Task<AccountsData> GetAccountsData(IDbConnection db)
609609
{
610610
In = [1, 2],
611611
}
612-
})
612+
}),
613+
TotalTz4Bakers = await db.ExecuteScalarAsync<int>("""
614+
SELECT COUNT(*)::integer
615+
FROM "Accounts"
616+
WHERE "Type" = 1
617+
AND "BakingPower" != 0
618+
AND ("Address" LIKE 'tz4%' OR "ConsensusAddress" IS NOT NULL AND "ConsensusAddress" LIKE 'tz4%')
619+
"""),
620+
TotalDalBakers = await db.ExecuteScalarAsync<int>("""
621+
SELECT COUNT(*)::integer
622+
FROM "Accounts"
623+
WHERE "Type" = 1
624+
AND "BakingPower" != 0
625+
AND "CompanionAddress" IS NOT NULL
626+
"""),
613627
};
614628
}
615629

0 commit comments

Comments
 (0)