package main

import (
	"context"
	"database/sql"
	"fmt"
	"os"
	"time"

	"github.com/kami/maven/internal/store"
)

func main() {
	ctx := context.Background()
	st, err := store.Open(ctx, "/tmp/maven-test.db")
	if err != nil {
		fmt.Fprintln(os.Stderr, "open:", err)
		os.Exit(1)
	}
	defer st.Close()

	now := time.Now()
	_, err = st.WriteFact(ctx, now.Add(-4*time.Hour), store.KindSelf, "water", "1", "tap:voice", 1.0, sql.NullInt64{})
	if err != nil {
		fmt.Fprintln(os.Stderr, "write water fact:", err)
		os.Exit(1)
	}
	fmt.Println("seeded water fact 4h ago")

	_, err = st.WriteFact(ctx, now.Add(-time.Minute), store.KindSelf, "desk_active", "1", "presence", 1.0, sql.NullInt64{})
	if err != nil {
		fmt.Fprintln(os.Stderr, "write desk_active fact:", err)
		os.Exit(1)
	}
	fmt.Println("seeded desk_active (presence) 1m ago")

	_, err = st.SetValue(ctx, store.KindConfig, "quiet_hours", "config", "false", now)
	if err != nil {
		fmt.Fprintln(os.Stderr, "write quiet_hours:", err)
		os.Exit(1)
	}
	fmt.Println("seeded quiet_hours=false")
}
