From ee4f604712ed38fe7c7c346e61b782d06e44ad46 Mon Sep 17 00:00:00 2001 From: Uku Taht Date: Thu, 21 May 2020 19:08:39 +0300 Subject: [PATCH] Update hydrate command --- lib/mix/tasks/hydrate_clickhouse.ex | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/mix/tasks/hydrate_clickhouse.ex b/lib/mix/tasks/hydrate_clickhouse.ex index a8f9776bc..1254baa8a 100644 --- a/lib/mix/tasks/hydrate_clickhouse.ex +++ b/lib/mix/tasks/hydrate_clickhouse.ex @@ -98,12 +98,13 @@ defmodule Mix.Tasks.HydrateClickhouse do end def hydrate_events(repo, _args \\ []) do + start_time = ~N[2020-05-01 00:00:00] end_time = ~N[2020-05-21 10:46:51] - total = Repo.aggregate(from(e in Plausible.Event, where: e.timestamp < ^end_time), :count, :id) + total = Repo.aggregate(from(e in Plausible.Event, where: e.timestamp < ^end_time and e.timestamp >= ^start_time), :count, :id) event_chunks = from( e in Plausible.Event, - where: e.timestamp < ^end_time, + where: e.timestamp < ^end_time and e.timestamp >= ^start_time, order_by: e.id ) |> chunk_query(50_000, repo)