Skip to content

Instantly share code, notes, and snippets.

@camillebaldock
Last active January 14, 2016 05:08
Show Gist options
  • Select an option

  • Save camillebaldock/1092f66251ad1461b473 to your computer and use it in GitHub Desktop.

Select an option

Save camillebaldock/1092f66251ad1461b473 to your computer and use it in GitHub Desktop.
Dashing Wunderlist widget

Description

A Dashing widget for displaying the number of tasks in my Wundermail that are due today or before.

See a live demo here.

Usage

Setup the following environment variables:

  • WUNDERLIST_CLIENT_TOKEN
  • WUNDERLIST_CLIENT_ID

See instructions here to learn how to setup your token and client ID.

Dependencies

rest-client

Add it to your Dashing application's Gemfile:

gem 'rest-client'

and run bundle install.

<li data-sizex="1" data-sizey="1">
<div data-id="wunderlist" data-view="Number" data-title="Today"></div>
</li>
require 'rest_client'
require 'date'
SCHEDULER.every "30m" do
headers = {
"X-Access-Token" => ENV["WUNDERLIST_CLIENT_TOKEN"],
"X-Client-ID" => ENV["WUNDERLIST_CLIENT_ID"]
}
lists_response = RestClient.get "https://a.wunderlist.com/api/v1/lists", headers
lists_hash = JSON.parse(lists_response.to_str)
list_ids = lists_hash.map do |list|
list["id"]
end
total = 0
list_ids.each do |list_id|
tasks_response = RestClient.get "https://a.wunderlist.com/api/v1/tasks?list_id=#{list_id}", headers
tasks = JSON.parse(tasks_response.to_str)
due_tasks = tasks.select do |task|
task["due_date"] && Date.parse(task["due_date"]) <= Date.today
end
total += due_tasks.count
end
send_event('wunderlist', { current: total })
end
@minisaurus

Copy link
Copy Markdown

Is there a way to pull tasks only from a specific list?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment