Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull all time data in google sheets #9

Open
smartphreak opened this issue Jan 21, 2018 · 3 comments
Open

Pull all time data in google sheets #9

smartphreak opened this issue Jan 21, 2018 · 3 comments
Assignees

Comments

@smartphreak
Copy link

How would you pull all time data for all users into google sheet?

@tdpauw
Copy link
Contributor

tdpauw commented Feb 9, 2018

Hi @smartphreak,
Sorry for the delay.

This google sheet makes use of the Detailed Report API from Toggl. From the documentation I understand the report returns all time entries for all users. Each time entry contains the user id and the full name of the user. This is the same API used by the Toggl user interface Reports > Detailed.

So if you want to have the user information you need to modify the data structure that is created inside the fetchTimesheet() fuction inside the Code.gs file.
This function creates a timesheet hash (dictionary):

timesheet = {
  date1: {
      client1: duration_for_date1,
      client2: duration_for_date2,
      ...
  },
  date2: {
  },
  ...
}

timesheet contains all aggregated time entries per client per day for 1 month.
Every date## property of timesheet represents a day of the month. And contains the time spent per client.
Every client## property of a date## contains the time spent for that client during the day represented by date##.
This timesheet data structure is used to populate a sheet inside the Google Sheet spreadsheet. Which is handled by the createTimesheet() function inside the Code.gs file.
As I am the only person using that workspace, this data structure only represents the data for 1 user.

To create a timesheet per user, you will probably need to create a data structure that could look as follows:

timesheets = {
  uid1: {
     name: 'full name'
     timesheet: {
        date1 : {
             ...
        },
       date2 : { ... },
       ...
     },
   uid2: { ... },
   ...
  }
}

Does this answer your question ?

Now I have to say that looking back at the code, I could have created a simpler data structure based on arrays:

timesheets = [
   {
     uid: 1,
     user: 'John Doe',
     timesheet: [
        {
          clients: [
             {
               name: 'client1',
               duration: 5236
              },
             {
               name: 'client2',
               duration: 5236
              },
              ....
          ]
        },
        { ... },
        ...
     ]
   },
   {
     uid: 2,
     user: 'Jane Doe',
     timesheet: [
        {...}
     ]
   },
  ...
]

@kuttnerd
Copy link

kuttnerd commented Feb 2, 2019

cheers @smartphreak
just came over your question and this repo from @Voronenko may also be helpful for you, as i think, that it does the job you need: https://github.com/Voronenko/toggl_invoice
Best regards

@tdpauw tdpauw self-assigned this Feb 5, 2022
@tdpauw
Copy link
Contributor

tdpauw commented Feb 5, 2022

Hi @smartphreak what do you mean by all the time data per user?
Do you mean all the time data aggregated per user per day?

Like ...

Date User Time
2022-01-05 user1 6:51
2022-01-05 user2 5:12
2022-01-05 user3 8:03
2022-01-06 user1 2:36
2022-01-06 user3 4:21

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants