Skip to content

Repository files navigation

anyquery-rescuetime

An Anyquery plugin that lets you query your RescueTime activity data with SQL.

Configuration

The plugin requires a RescueTime API key.

  1. Get your key at https://www.rescuetime.com/anapi/manage.
  2. Pass it when installing the plugin

Local development

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');"

Installed from registry

anyquery plugin install anyquery_rescuetime

Anyquery will prompt you for the api_key during installation.

Tables

activities

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

Categories ranked by time spent.

SELECT * FROM categories WHERE restrict_begin = '2023-11-01' AND restrict_end = '2023-11-07';

productivity

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

activity_log

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_timeminute (5-minute chunks), hour, day, week, or month. Defaults to hour.

Columns: date, time_spent_seconds, number_of_people, activity, category, document, productivity.

daily_summary

Pre-rolled daily summaries for the last two weeks.

SELECT date, productivity_pulse, total_hours, total_duration_formatted
FROM daily_summary;

Pagination and rate limits

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.

Development

Requirements:

  • Go 1.22+
  • Anyquery 0.4+

Build:

make

Run 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');

License

MIT

About

An anyquery plugin for Rescuetime

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages