An Anyquery plugin that lets you query your RescueTime activity data with SQL.
The plugin requires a RescueTime API key.
- Get your key at https://www.rescuetime.com/anapi/manage.
- Pass it when installing the plugin
Edit devManifest.json and add your API key:
{
"executable": "anyquery_rescuetime.out",
"build_command": "make",
"user_config": {
"default": {
"api_key": "YOUR_RESCUETIME_API_KEY"
}
},
...
}Then load the plugin in dev mode:
anyquery --dev -q "SELECT load_dev_plugin('anyquery_rescuetime', 'devManifest.json');"anyquery plugin install anyquery_rescuetimeAnyquery will prompt you for the api_key during installation.
Activities ranked by time spent.
SELECT * FROM activities;
-- Filter to a date range
SELECT * FROM activities WHERE restrict_begin = '2023-11-01' AND restrict_end = '2023-11-07';
-- Or using table-valued syntax
SELECT * FROM activities('2023-11-01', '2023-11-07');Columns: rank, date, time_spent_seconds, number_of_people, activity, category, document, productivity.
Categories ranked by time spent.
SELECT * FROM categories WHERE restrict_begin = '2023-11-01' AND restrict_end = '2023-11-07';Productivity levels ranked by time spent.
SELECT * FROM productivity WHERE restrict_begin = '2023-11-01' AND restrict_end = '2023-11-07';Productivity codes:
| Code | Meaning |
|---|---|
| -2 | Very distracting |
| -1 | Distracting |
| 0 | Neutral |
| 1 | Productive |
| 2 | Very productive |
Time-series log of your activities. Use this for a granular breakdown of what you did and when.
-- Default hourly granularity for today
SELECT * FROM activity_log;
-- 5-minute chunks for a specific day
SELECT * FROM activity_log('2023-11-14', '2023-11-14', 'minute');
-- Daily summary for a week
SELECT * FROM activity_log('2023-11-01', '2023-11-07', 'day');Parameters:
restrict_begin— start date (YYYY-MM-DD)restrict_end— end date (YYYY-MM-DD)resolution_time—minute(5-minute chunks),hour,day,week, ormonth. Defaults tohour.
Columns: date, time_spent_seconds, number_of_people, activity, category, document, productivity.
Pre-rolled daily summaries for the last two weeks.
SELECT date, productivity_pulse, total_hours, total_duration_formatted
FROM daily_summary;The plugin fetches 200 rows per page and automatically paginates until Last.fm has no more data. If you specify a LIMIT, it stops early.
Large exports make many API calls and may be slow or hit Last.fm rate limits. Consider materializing the data with CREATE TABLE AS SELECT instead of querying live repeatedly.
Requirements:
- Go 1.22+
- Anyquery 0.4+
Build:
makeRun tests:
go test ./...Load in Anyquery dev mode:
anyquery --dev
# then inside the shell:
SELECT load_dev_plugin('anyquery_rescuetime', 'devManifest.json');Reload after changes:
SELECT reload_dev_plugin('anyquery_rescuetime');MIT