docs: def _get_metadata(dataset_ids):
      """
          Get all the metadata for a given list of datasets
      """
      metadata = []
      if len(dataset_ids) == 0:
          return []
      if len(dataset_ids) > qry_in_threshold:
          idx = 0
          extent = qry_in_threshold
          while idx < len(dataset_ids):
              log.info("Querying %s metadatas", len(dataset_ids[idx:extent]))
              rs = db.DBSession.query(Metadata).filter(Metadata.dataset_id.in_(dataset_ids[idx:extent])).all()
              metadata.extend(rs)
              idx = idx + qry_in_threshold
  
              if idx + qry_in_threshold > len(dataset_ids):
                  extent = len(dataset_ids)
              else:
                  extent = extent +qry_in_threshold
      else:
          metadata_qry = db.DBSession.query(Metadata).filter(Metadata.dataset_id.in_(dataset_ids))
          for m in metadata_qry:
              metadata.append(m)
  
      return metadata