OVO Tech Blog

Feeding a hungry "To Do" list from difference sources

Introduction

Andrew Salvadore

Andrew Salvadore


Feeding a hungry "To Do" list from difference sources

Posted by Andrew Salvadore on .
Featured

Feeding a hungry "To Do" list from difference sources

Posted by Andrew Salvadore on .

Moving from engineering to management means spending a lot more time in meetings. My calendar is a fairly close representation of my day's activities. Very often if it's not in the calendar it is not going to happen. Which is fine. Problem is there are also other things that I need to remember to get done. Over time I realised I still need to keep a "To Do" list but most importantly have a little side project to keep coding 😉.

In my efforts to improve my time management and focus, I have tried many different options in the past and the biggest challenge is always sticking to it. I tend to start full of energy and belief and then after a holiday or any sort of interruption I never get back to it.

Recently I started experimenting with a new Trello board to manage my day. So far I have been pretty consistent and it already survived a couple of holidays. I think the main difference is that everything is connected to the board and I can use it as a single planning tool.

I realised most of the items in my "To Do" list are mainly coming from:

  • My Calendar
  • Conversations with other people
  • Emails
  • Slack
  • My phone's others apps like Hacker News, Reddit, Twitter, and other things I want to follow up on.

Let's go over those one by one so I can show you how those are feeding a single board.

Calendar

The beauty of having cards for calendar events is that I use it to take notes as well. The trello search works pretty well when I then want to go back and find something.

For the calendar synchronisation itself I wrote a few lines of code using the node-google-calendar and the trello npm libraries. The code is fairly simple it just fetches the calendar events for a given day, does a bit of filtering for events I don't need as a card and then creates cards in a specific "To Sort" column.

const CalendarAPI = require('node-google-calendar');
const TrelloAPI = require("trello");
const joda = require('js-joda')
const rest = require('restler');


const ZonedDateTime = joda.ZonedDateTime;
const LocalTime = joda.LocalTime;
const LocalDate = joda.LocalDate;
const ZoneId = joda.ZoneId;

It required a bit of date manipulations so I used js-joda for that. The following method is what I use to build the calendar api request parameter. It take a relativeDay parameter where 0 means today, -1 yesterday, 1 tomorrow, etc.

function calendarRequestParams(relativeDay) {
    const lastMidnight = ZonedDateTime
    .of(LocalDate.now(), LocalTime.MIDNIGHT, ZoneId.SYSTEM)
        .withFixedOffsetZone()
    return {
        timeMin: lastMidnight.plusDays(relativeDay).toString(),
        timeMax: lastMidnight.plusDays(relativeDay + 1).toString(),
        showDeleted: false,
        singleEvents: true,
        fields: 'items(creator/displayName,end/dateTime,start/dateTime,summary,htmlLink,attendees/email,attendees/responseStatus,colorId)',
        orderBy: 'startTime'
    };
}

There are a number of other utility functions that I will skip to make things easier to follow and then the main function that is called from the express controller is the following

const endDateFieldId = 'xyz'
const trelloBaseURI = "https://api.trello.com"

module.exports.createCardFromCalendar = async (trelloApiConfig, calendarConfig, relativeDay) => {
    const trello = new TrelloAPI(trelloApiConfig.key, trelloApiConfig.token);

    const calendarId = calendarConfig.id
    const apiSettings = convertApiConfigToSetting(calendarConfig)
    const cal = new CalendarAPI(apiSettings);
    const toSortTrelloListId = calendarConfig.trello.list.id


    const filteredEvents = await cal.Events.list(calendarId, calendarRequestParams(relativeDay))
        .then(convertToDomainModel(calendarId))
        .then((eventsList) => {
            return eventsList.filter((event) => shouldFilter(event))
        });

    return Promise.all(filteredEvents.map(async (event) => {
        const card = await trello.addCardWithExtraParams(event.summary, {
            due: event.start.dateTime,
            desc: "[Calendar Link](" + event.url + ")",
            idLabels: colorToLabelMapping(calendarConfig.trello.labelMapping, event.color)
        }, toSortTrelloListId)

        const addEndDatePayload = { value: { date: event.end.dateTime } }
        return rest.putJson(
            `${trelloBaseURI}/1/card/${card.id}/customField/${endDateFieldId}/item?key=${trelloApiConfig.key}&token=${trelloApiConfig.token}`,
            addEndDatePayload
        )
    }))
}

/* Calendar event colours map to labels in my trello board */
function colorToLabelMapping(labelMapping, color) {}

/* google -> my object format conversion */
function convertToDomainModel(calendarId) {}

/* creates a settings object for the google calendar API. Something like
{
     serviceAcctId: config.api.client_email,
     timezone: 'UTC+08:00',
     calendarId: { 'primary': config.id }, // same as email
     key: config.api.private_key
} */
function convertApiConfigToSetting(config) {}

/* event filtering predicate */
function shouldFilter(event) {}

I used the custom fields plugin for the event end datetime and the trello native dueDate field for the start time. The second rest.putJson call is used to populate the event end datetime. Unfortunately the trello library didn't support the put call.

This runs on a daily schedule using an appEngine cron job on Google Cloud.

Conversations with other people

This one is pretty low tech. I have my phone with me all the time and I just pop in a new card using the trello app.

Emails

For emails we use GMail that has a great little add-on that integrates with Trello directly. Just search for it in the GSuite Marketplace.

Slack

For slack I use zapier. There is a neat little way to send starred message straight to a trello board using a simple trigger -> action sequence.

Phone's others apps

Everything on the phone has a "Share" functionality these days. Using that you can create a trello card from pretty much everything!

Wrapping up

I hope this post inspired you to take control of your "To Do" list and get your time management to the next level. There are a few other trello tricks that I am using to manage this board but I guess those will be for another post!

Till then,

#keepautomating!

Andrew Salvadore

Andrew Salvadore

View Comments...