My agentic slop goes here. Not intended for anyone else!
1#!/bin/bash 2 3# Build the project 4dune build 5 6# Example 1: Convert a single .rec file to stdout 7echo "Converting single file to stdout:" 8dune exec owntracks2clickhouse avsm/avsm-ip15/2025-08.rec | head -5 9 10# Example 2: Convert a single .rec file to output file 11echo -e "\nConverting single file to output.jsonl:" 12dune exec owntracks2clickhouse avsm/avsm-ip15/2025-08.rec -o single_output.jsonl 13echo "Created single_output.jsonl" 14 15# Example 3: Process all .rec files in a directory recursively 16echo -e "\nProcessing all .rec files recursively:" 17dune exec owntracks2clickhouse avsm -r -o all_records.jsonl 18 19# Example 4: Create ClickHouse table and import data 20cat << 'EOF' 21 22To import into ClickHouse, create a table like this: 23 24CREATE TABLE owntracks_locations ( 25 timestamp DateTime64(3), 26 timestamp_epoch UInt32, 27 point Point, 28 latitude Float64, 29 longitude Float64, 30 altitude Nullable(Float64), 31 accuracy Nullable(Float64), 32 battery Nullable(UInt8), 33 tracker_id Nullable(String) 34) ENGINE = MergeTree() 35ORDER BY (tracker_id, timestamp); 36 37Then import the JSON lines file: 38 39clickhouse-client --query="INSERT INTO owntracks_locations FORMAT JSONEachRow" < all_records.jsonl 40 41Or using clickhouse-local for testing: 42 43clickhouse-local --query=" 44 SELECT 45 tracker_id, 46 toDate(timestamp) as date, 47 count() as points, 48 round(avg(battery), 2) as avg_battery 49 FROM file('all_records.jsonl', 'JSONEachRow') 50 GROUP BY tracker_id, date 51 ORDER BY date DESC 52 LIMIT 10 53" 54EOF