Skip to content

feat: add epoch, daily, weekly, and monthly agg tables for block_first_seen_by_node#119

Open
samcm wants to merge 6 commits intomasterfrom
block-seen-by-node-aggs
Open

feat: add epoch, daily, weekly, and monthly agg tables for block_first_seen_by_node#119
samcm wants to merge 6 commits intomasterfrom
block-seen-by-node-aggs

Conversation

@samcm
Copy link
Member

@samcm samcm commented Nov 6, 2025

insert meme of dog not knowing what its doing

@samcm samcm requested a review from Savid as a code owner November 6, 2025 06:40
Comment on lines +76 to +77
WHERE slot_start_date_time >= toStartOfDay(fromUnixTimestamp({{ .bounds.start }}))
AND slot_start_date_time < toStartOfDay(fromUnixTimestamp({{ .bounds.end }})) + INTERVAL 1 DAY
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be able to do this one too (untested lmao)

WHERE toStartOfDay(slot_start_date_time) IN (
  SELECT
      arrayJoin(
          arrayMap(
              x -> toDate(start_time) + x,
              range(dateDiff('day', toDate(start_time), toDate(end_time)) + 1)
          )
      )
  FROM
  (
      SELECT
          toDateTime(fromUnixTimestamp({{ .bounds.start }})) AS start_time,
          toDateTime(fromUnixTimestamp({{ .bounds.end }})) AS end_time
  )
)

Comment on lines +78 to +79
WHERE slot_start_date_time >= toStartOfWeek(fromUnixTimestamp({{ .bounds.start }}))
AND slot_start_date_time < toStartOfWeek(fromUnixTimestamp({{ .bounds.end }})) + INTERVAL 1 WEEK
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WHERE toStartOfWeek(slot_start_date_time) IN (
  SELECT
    arrayJoin(
        arrayMap(
            x -> addWeeks(start_w, x),
            range(dateDiff('week', start_w, end_w) + 1)
        )
    ) 
  FROM
  (
      SELECT
          toStartOfWeek(fromUnixTimestamp({{ .bounds.start }})) AS start_w,
          toStartOfWeek(fromUnixTimestamp({{ .bounds.end }})) AS end_w
  )
)

untested

Comment on lines +78 to +79
WHERE slot_start_date_time >= toStartOfMonth(fromUnixTimestamp({{ .bounds.start }}))
AND slot_start_date_time < toStartOfMonth(fromUnixTimestamp({{ .bounds.end }})) + INTERVAL 1 MONTH
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WHERE toStartOfMonth(slot_start_date_time) IN (
  SELECT
    arrayJoin(
        arrayMap(
            x -> addMonths(start_m, x),
            range(dateDiff('month', start_m, end_m) + 1)
        )
    )
  FROM
  (
      SELECT
          toStartOfMonth(fromUnixTimestamp({{ .bounds.start }})) AS start_m,
          toStartOfMonth(fromUnixTimestamp({{ .bounds.end }})) AS end_m
  )
)

untested

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants