Working time consultation

The working time data stored in the Mobilic API can be viewed by the users concerned.

The API provides three consultation operations:

  • for a mission

  • for a mobile worker

  • for a company

Consultation of mission data

L'accès aux données de temps de travail d'une mission n'est autorisée que pour les membres de l'entreprise concernée par la mission.

query {
    mission(id: Int!) {
        name
        activities {
            id
            type
            startTime
            endTime
            userId
        }
        expenditures {
            id
            type
            userId
        }
    }
}

The query returns the list of activities associated with the mission (possibly involving several users).

Data consultation for a mobile worker

Full access to working time data is only allowed for company managers or for the user himself.

query {
    user(id: Int!) {
        firstName
        lastName
        missions {
            edges {
                node {
                    name
                    activities {
                        id
                        type
                        startTime
                        endTime
                        userId
                    }
                    expenditures {
                        id
                        type
                        userId
                    }
                }
            }
        }
    }
}

In the example above, subject to an appropriate level of authorisation, the API will return the list of missions on which the worker has recorded working time.

If you only want to retrieve the activities without having a grouping by missions, it is possible to query directly the activities field :

query {
    user(id: Int!) {
        firstName
        lastName
        activities {
            edges {
                node {
                    id
                    type
                    startTime
                    endTime
                    userId
                    missionId
                }
            }
        }
    }
}

It is also possible to recover the working time already calculated per day.

query {
    user(id: Int!) {
        firstName
        lastName
        workDays {
            edges {
                node {
                    startTime
                    endTime
                    activityDurations
                }
            }
        }
    }
}

Consultation of company data

This operation provides access to all company-specific working time data, that is, all assignments that have been performed by company employees.

Full access to all missions requires being attached as a manager to the company.

query {
    company(id: Int!) {
        name
        missions {
            edges {
                node {
                    id
                    name
                    activities {
                        id
                        type
                        startTime
                        endTime
                        userId
                    }
                    expenditures {
                        id
                        type
                        userId
                    }
                }
            }
        }
    }
}

It is also possible to retrieve the list of current members of the company.

query {
    company(id: Int!) {
        name
        users {
            id
            firstName
            lastName
        }
    }
}

Just like consulting the data of a mobile worker, it is possible to recover the working time already aggregated by day.

query {
    company(id: Int!) {
        name
        workDays {
            edges {
                node {
                    userId
                    startTime
                    endTime
                    activityDurations
                }
            }
        }
    }
}

Case of multi-company management

It is possible to retrieve in a single query the list of all companies on which the user has management rights, via the adminedCompanies field.

query {
  me {
    adminedCompanies {
      name
      workDays {
        edges {
          node {
            userId
            startTime
            endTime
            activityDurations
          }
        }
      }
    }
  }
}

Choice of the retrieved history period

The three fields for retrieving working time data take optional arguments to restrict the history period :

  • the activities (fromTime: TimeStamp, untilTime: TimeStamp) field at a mobile worker level

  • the missions(fromTime: TimeStamp, untilTime: TimeStamp) field at mobile worker or company level

  • the workDays(fromDate: Date, untilDate: Date) field at mobile worker or company level

query {
    user(id: Int!) {
        firstName
        lastName
        activities(fromTime: 1577869200, untilTime: 1578081600) {
            edges {
                node {
                    # all activities that were linked (at least in part) between 01/01/2020 9am and 03/01/2020 8pm
                    id
                    type
                    startTime
                    endTime
                    userId
                    missionId
                }
            }
        }
    }
}
query {
    user(id: Int!) {
        firstName
        lastName
        missions(fromTime: 1577869200) {
            edges {
                node {
                    # all missions for which the mobile worker has working time after 01/01/2020 9am
                    name
                    activities {
                        id
                        type
                        startTime
                        endTime
                        userId
                    }
                    expenditures {
                        id
                        type
                        userId
                    }
                }
            }
        }
    }
}
query {
  me {
    adminedCompanies {
      name
      workDays(fromDate: "2020-01-01") {
        edges {
          node {
            # all working days of the companies concerned from 01/01/2020
            userId
            startTime
            endTime
            activityDurations
          }
        }
      }
    }
  }
}

On the company fields there is also a limit parameter which defines a maximum number of returned jobs, in addition to the date filter. The most recent assignments (within the selected period) will be returned.

Last updated