mirror of
https://github.com/plausible/analytics.git
synced 2025-01-09 03:26:52 +03:00
Escape quote in event name
This commit is contained in:
parent
ee4f604712
commit
439a4a80c7
@ -98,13 +98,12 @@ 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 and e.timestamp >= ^start_time), :count, :id)
|
||||
total = Repo.aggregate(from(e in Plausible.Event, where: e.timestamp < ^end_time), :count, :id)
|
||||
|
||||
event_chunks = from(
|
||||
e in Plausible.Event,
|
||||
where: e.timestamp < ^end_time and e.timestamp >= ^start_time,
|
||||
where: e.timestamp < ^end_time,
|
||||
order_by: e.id
|
||||
) |> chunk_query(50_000, repo)
|
||||
|
||||
|
@ -16,7 +16,7 @@ defmodule Plausible.Clickhouse do
|
||||
""" <> String.duplicate(" (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?),", length(events))
|
||||
|
||||
args = Enum.reduce(events, [], fn event, acc ->
|
||||
[event.name, event.timestamp, event.domain, event.user_id, event.session_id, event.hostname, escape_quote(event.pathname), escape_quote(event.referrer || ""), escape_quote(event.referrer_source || ""), escape_quote(event.initial_referrer || ""), escape_quote(event.initial_referrer_source || ""), event.country_code || "", event.screen_size || "", event.browser || "", event.operating_system || ""] ++ acc
|
||||
[escape_quote(event.name), event.timestamp, event.domain, event.user_id, event.session_id, event.hostname, escape_quote(event.pathname), escape_quote(event.referrer || ""), escape_quote(event.referrer_source || ""), escape_quote(event.initial_referrer || ""), escape_quote(event.initial_referrer_source || ""), event.country_code || "", event.screen_size || "", event.browser || "", event.operating_system || ""] ++ acc
|
||||
end)
|
||||
|
||||
Clickhousex.query(:clickhouse, insert, args, log: {Plausible.Clickhouse, :log, []})
|
||||
|
Loading…
Reference in New Issue
Block a user