Skip to content
This repository has been archived by the owner on Nov 16, 2024. It is now read-only.

Commit

Permalink
add reset tables to clickhouse
Browse files Browse the repository at this point in the history
Signed-off-by: Flipez <code@brauser.io>
  • Loading branch information
Flipez committed May 28, 2024
1 parent cf76ac4 commit c03aa45
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ data/
logfile.log
config.yaml
export.log
vendor/
7 changes: 7 additions & 0 deletions lib/mvg/analyser/clickhouse.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ def setup_tables
end
end

def drop_tables
puts "Will drop all clickhouse tables in 10s"
sleep(10)
connection.drop_table("responses")
connection.drop_table("requests")
end

def insert(rows)
cache.concat(rows)

Expand Down
7 changes: 7 additions & 0 deletions lib/mvg/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,12 @@ def export_bigquery
analyser = MVG::DataHandler.new
analyser.export_bigquery
end

desc "reset-clickhouse", "drops clickhouse tables and creates new, empty ones"
def reset_clickhouse
ch = Analyser::Clickhouse.new("")
ch.drop_tables
ch.setup_tables
end
end
end

0 comments on commit c03aa45

Please sign in to comment.