Skip to content
Greg Walker (he/him) edited this page Jan 18, 2023 · 4 revisions

Charlie developer documentation > Tock

The Tock utility wraps some Tock API access in an easier-to-use package. The Tock API and authentication key are preconfigured by the utility from environment variables so bots don't have to worry about it.

NOTE: All of the methods in this utility are cached for 10 minutes.

function getCurrent18FTockUsers() : Promise<[TockUser]>

Gets a list of all Tock users who are current 18F employees. Users who have left 18F or are on extended leave may still show up as Tock users, and this function will filter those out.

NOTE: Not everyone who Tocks works in 18F. However, the rules for knowing who outside of 18F should Tock are complicated and not necessarily represented in Tock API data, so we can't automate it.

Returns

  • A Promise that resolves to a list of current 18F Tock users:

    [
      {
        user: "Tock username",
        email: "Tock email",
        tock_id: "Tock user ID",
      },
    ];

function get18FUsersWhoHaveNotTocked(Moment now, Number weeksAgo) : Promise<[TockUser]>

Gets a list of all current 18F Tock users who have not recorded their time in Tock for the specified pay period, relative to a given "now."

Argument Description
now A Moment object representing the "now" from which to calculate the first day of the reporting period.
weeksAgo How many weeks before "now" to go back in time. Can be zero for the current workweek or negative for future ones, but going into the future doesn't make sense because it'll report everyone.

Default: 1

This function will find the users who have not submitted a Tock timesheet for workweek containing "now" minus however many weeks you want to go back. For example:

get18FUsersWhoHaveNotTocked(<2022-07-13>, 2);

This would find Tock users who have not yet submitted a Tock timecard for the workweek beginning June 26, 2022. That's because the workweek containing the "now" argument begins July 10, 2022, and then we go back two preceding weeks.

Returns

  • A Promise that resolves to a list of current 18F Tock users:

    [
      {
        user: "Tock username",
        email: "Tock email",
        tock_id: "Tock user ID",
      },
    ];

function get18FTockSlackUsers() : Promise<[TockSlackUser]>

Gets all current 18F Tock users who are also Slack users, and merges their information from the two platforms together.

Returns

  • A Promise that resolves to a list of current 18F Tock users who are also Slack users:

    [
      {
        user: "Slack 'real name'",
        email: "Tock/Slack email",
        slack_id: "Slack user ID",
        tock_id: "Tock user ID",
        tz: "Slack timezone",
      },
    ];