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

Enrich ROI endpoint with Trade count data #37

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
13 changes: 10 additions & 3 deletions src/v1/roi/roi.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ export class RoiService {
left join tokens t0 on t0.id = s."token0Id"
left join tokens t1 on t1.id = s."token1Id"
),
trade_count AS (
SELECT "strategyId" as id, COUNT(*) as trade_count
FROM "strategy-updated-events"
WHERE reason = 1
GROUP BY "strategyId"
),
all_txs AS (
SELECT *
FROM created
Expand Down Expand Up @@ -279,9 +285,10 @@ export class RoiService {
LEFT JOIN lifetime l ON l.id = n.id
WHERE descr = 'ZFinal Novation'
)
SELECT id, ROI
FROM recent_roi_only
ORDER BY ROI DESC;
SELECT r.id, r.ROI, COALESCE(t.trade_count, 0) AS Trades
FROM recent_roi_only r
LEFT JOIN trade_count t ON r.id = t.id
ORDER BY r.ROI DESC;
`;

const result = await this.strategy.query(query);
Expand Down