getTimeSpentIn(state) {
    let sum = 0;

    if (this.open_ && this.open_.state == state) {
      sum += this.open_.duration;
    }

    for (const entry of this.closed_) {
      sum += entry.state == state ? entry.duration : 0;
    }

    return sum;
  }
Go through all entries in the history and count how much time was spend in
the given state.

@param {string} state
@return {number}