bro-n-bro / spacebox-api

Flask api for services on top of spacebox
MIT License
4 stars 0 forks source link

Additional endpoint inactive_accounts as historical value #124

Open bro-n-bro-2 opened 11 months ago

bro-n-bro-0 commented 9 months ago

@iljagrabar14

SELECT date, sum(address) OVER (ORDER BY date) AS cumulative_sum
FROM (
    SELECT date, count(signer) as address FROM (
        SELECT * FROM (
            SELECT 
                arrayJoin(
                    arrayMap(
                        x -> toDateTime(x),
                        range(
                            toUInt32(toDateTime('2021-02-18 12:00:00')),
                            toUInt32(now()),
                            3600
                        )
                    )
                ) as date
        ) date
        LEFT JOIN (
            SELECT signer, MAX(timestamp_start_of_hour) + INTERVAL 1 YEAR as timestamp_start_of_hour FROM (
                SELECT toStartOfHour(timestamp) as timestamp_start_of_hour, signer FROM spacebox.`transaction`
                LEFT JOIN spacebox.block  ON `transaction`.height = block.height
            ) as t
            GROUP BY signer
            ORDER BY timestamp_start_of_hour
        ) au ON date.date = au.timestamp_start_of_hour
        ORDER BY date DESC
    )
    WHERE signer != ''
    GROUP BY date
    ORDER BY date
)
iljagrabar14 commented 9 months ago

if db doesn't return value for timestamp, return previous value

iljagrabar14 commented 9 months ago

@bro-n-bro-0 ready to check

bro-n-bro-2 commented 8 months ago

Wrong historical data