# Results and history

## Result tables

Every table run writes to `TOMBA.results.<output_table>`, in your account. Roles with `app_public` can read
them.

```sql
SHOW TABLES IN SCHEMA TOMBA.results;

SELECT * FROM TOMBA.results.LEADS_FOUND WHERE lookup_status = 'found';
```

Results stay until you drop them or uninstall the app. To keep them, copy them to your own database:

```sql
CREATE TABLE my_db.public.leads_found AS SELECT * FROM TOMBA.results.LEADS_FOUND;
```

Drop a result table you no longer need:

```sql
CALL TOMBA.core.drop_result('LEADS_FOUND');
```

The Streamlit app's **Results** page previews tables, downloads them as CSV, and drops them after a
confirmation.

## Run history

`TOMBA.core.runs` has one row per call: lookups, table runs, company searches, background and scheduled
runs.

```sql
SELECT started_at, tool, procedure_name, status, rows_total, rows_found, output_rows,
       search_credits + verification_credits AS credits, charged_usd, output_table, message
  FROM TOMBA.core.runs
 ORDER BY started_at DESC
 LIMIT 50;
```

Useful columns:

- `status`: `QUEUED`, `RUNNING`, `SUCCEEDED`, `PARTIAL`, `FAILED`, `CANCELLED` or `ABANDONED`
- `progress_pct`, `rows_expected`: progress of a running run
- `stop_kind`, `auto_resume`: why a run stopped, and whether it resumes by itself
- `rows_cached`: rows answered from the cache
- `charged_usd`: what Snowflake charges you for the run

## Usage by day

```sql
SELECT * FROM TOMBA.core.usage_by_day ORDER BY day DESC;
CALL TOMBA.core.usage_summary(30);        -- the last 30 days, per day and tool
```
