Creates the JSON object for the available time entries route response.

    Returns:
      The JSON object for the available time entries route response.

def available_time_entries_impl(self):
    """Creates the JSON object for the available time entries route response.

    Returns:
      The JSON object for the available time entries route response.
    """
    result = {}
    if self._db_connection_provider:
      db = self._db_connection_provider()
      # For each run, pick a tag.
      cursor = db.execute(
          '''
          SELECT
            TagPickingTable.run_name,
            Tensors.step,
            Tensors.computed_time
          FROM (/* For each run, pick any tag. */
            SELECT
              Runs.run_id AS run_id,
              Runs.run_name AS run_name,
              Tags.tag_id AS tag_id
            FROM Runs
            JOIN Tags
              ON Tags.run_id = Runs.run_id
            WHERE
              Tags.plugin_name = ?
            GROUP BY Runs.run_id) AS TagPickingTable
          JOIN Tensors
            ON Tensors.series = TagPickingTable.tag_id
          WHERE Tensors.step IS NOT NULL
          ORDER BY Tensors.step
          ''', (metadata.PLUGIN_NAME,))
      for (run, step, wall_time) in cursor:
        if run not in result:
          result[run] = []
        result[run].append(self._create_time_entry(step, wall_time))
    else:
      # Read data from disk.
      all_runs = self._multiplexer.PluginRunToTagToContent(
          metadata.PLUGIN_NAME)
      for run, tag_to_content in all_runs.items():
        if not tag_to_content:
          # This run lacks data for this plugin.
          continue
        # Just use the list of tensor events for any of the tags to determine
        # the steps to list for the run. The steps are often the same across
        # tags for each run, albeit the user may elect to sample certain tags
        # differently within the same run. If the latter occurs, TensorBoard
        # will show the actual step of each tag atop the card for the tag.
        tensor_events = self._multiplexer.Tensors(
            run, min(six.iterkeys(tag_to_content)))
        result[run] = [self._create_time_entry(e.step, e.wall_time)
                       for e in tensor_events]
    return result