Returns your lending history within a time range specified by the
        "start" and "end" POST parameters as UNIX timestamps. "limit" may also
        be specified to limit the number of rows returned.
435443
def returnLendingHistory(self, start=0, end=2**32-1, limit=None):
        
        return self._private('returnLendingHistory', start=start, end=end,
                             limit=limit)
698118
@GET
    @Path("{id}/history/{start: " + DATE_REGEX + "}-{end: " + DATE_REGEX + "}")
    public Response fetchHistory(@PathParam("id") URI_ID id,
                                 @PathParam("start") Timestamp start,
                                 @PathParam("end") Timestamp end) throws Exception {
        return super.fetchHistory(id, start, end);
    }
765531
def start_date(self):
        
        if self.start_==None:
            if len(self.time_index_max) > 0:
                return str(min(self.time_index_max))[0:10]
            else:
                print(
                    RuntimeWarning(
                        'QAACCOUNT: THIS ACCOUNT DOESNOT HAVE ANY TRADE'
                    )
                )
        else:
            return self.start_
1360778
def _GetTimelineStatEntriesLegacy(client_id, file_path, with_history=True):
  """"""

  folder_urn = aff4.ROOT_URN.Add(str(client_id)).Add(file_path)

  child_urns = []
  for _, children in aff4.FACTORY.RecursiveMultiListChildren([folder_urn]):
    child_urns.extend(children)

  if with_history:
    timestamp = aff4.ALL_TIMES
  else:
    timestamp = aff4.NEWEST_TIME

  for fd in aff4.FACTORY.MultiOpen(child_urns, age=timestamp):
    file_path = "/".join(str(fd.urn).split("/")[2:])

    if not with_history:
      yield file_path, fd.Get(fd.Schema.STAT), fd.Get(fd.Schema.HASH)
      continue

    result = {}

    stats = fd.GetValuesForAttribute(fd.Schema.STAT)
    for s in stats:
      result[s.age] = [s, None]

    hashes = fd.GetValuesForAttribute(fd.Schema.HASH)
    for h in hashes:
      prev = result.setdefault(h.age, [None, None])
      prev[1] = h

    for ts in sorted(result):
      v = result[ts]
      yield file_path, v[0], v[1]
716931
def _retrieve(self, namespace, stream, start_id, end_time, order, limit,
                configuration):
    
    start_id_event = Event(start_id)
    end_id_event = Event(uuid_from_kronos_time(end_time,
                                               _type=UUIDType.HIGHEST))
    stream_events = self.db[namespace][stream]

    # Find the interval our events belong to.
    lo = bisect.bisect_left(stream_events, start_id_event)
    if lo + 1 > len(stream_events):
      return
    if stream_events[lo] == start_id_event:
      lo += 1
    hi = bisect.bisect_right(stream_events, end_id_event)

    if order == ResultOrder.DESCENDING:
      index_it = xrange(hi - 1, lo - 1, -1)
    else:
      index_it = xrange(lo, hi)

    for i in index_it:
      if limit <= 0:
        break
      limit -= 1
      yield marshal.dumps(stream_events[i])
872446
def query_timeseries(self, query, from_time=None, to_time=None, by_post=False):
    
    return timeseries.query_timeseries(self, query, from_time, to_time, by_post=by_post)
980888
def query_by_account(self, account_id, end_time=None, start_time=None):
        
        path = {}
        data = {}
        params = {}

        # REQUIRED - PATH - account_id
        """ID"""
        path["account_id"] = account_id

        # OPTIONAL - start_time
        """The beginning of the time range from which you want events."""
        if start_time is not None:
            params["start_time"] = start_time

        # OPTIONAL - end_time
        """The end of the time range from which you want events."""
        if end_time is not None:
            params["end_time"] = end_time

        self.logger.debug("GET /api/v1/audit/authentication/accounts/{account_id} with query params: {params} and form data: {data}".format(params=params, data=data, **path))
        return self.generic_request("GET", "/api/v1/audit/authentication/accounts/{account_id}".format(**path), data=data, params=params, no_data=True)
691468
def prev_page(self):
        
        if self.history.position > self.lines and self.history.top:
            mid = min(len(self.history.top),
                      int(math.ceil(self.lines * self.history.ratio)))

            self.history.bottom.extendleft(
                self.buffer[y]
                for y in range(self.lines - 1, self.lines - mid - 1, -1))
            self.history = self.history \
                ._replace(position=self.history.position - mid)

            for y in range(self.lines - 1, mid - 1, -1):
                self.buffer[y] = self.buffer[y - mid]
            for y in range(mid - 1, -1, -1):
                self.buffer[y] = self.history.top.pop()

            self.dirty = set(range(self.lines))
906369
def _get_earliest_valid_timestamp(self, symbol, interval):
        
        kline = self.get_klines(
            symbol=symbol,
            interval=interval,
            limit=1,
            startTime=0,
            endTime=None
        )
        return kline[0][0]
950055
def get_posts(self, offset=0, limit=1000, order=None, filters=None):
        
        order = self._get_order(order)
        cache_key = self.get_cache_key(offset, limit, order, filters)
        content = cache.get(cache_key)
#        if content:
#            return content
        try:
            if self.up_to_date():
                pass # not time to update yet
            else:
                self.update()
        except:
            raise
            pass # query the database for now and update later
        query = self._get_query(order=order, filters=filters)
        posts = query[int(offset):int(offset)+int(limit)]
        posts = self._format(posts)
        cache_duration = conf.GOSCALE_CACHE_DURATION if posts else 1
        cache.set(cache_key, posts, cache_duration)
        return posts
175734
def log_entries_in_range(entries, start, end):
    ''''''
    start = _timestamp_from_string(start)
    end = _timestamp_from_string(end)
    for entry in entries:
        log_timestamp = entry.get('timestamp', 0)
        if log_timestamp >= start and log_timestamp <= end:
            yield entry
1348544
def fetch_recent_submissions(self, max_duration):
        
        if max_duration:
            self.min_date = self.max_date - SECONDS_IN_A_DAY * max_duration
        for submission in self.subreddit.new(limit=None):
            if submission.created_utc <= self.min_date:
                break
            if submission.created_utc > self.max_date:
                continue
            self.submissions[submission.id] = MiniSubmission(submission)
862418
function()
    {
      // get the start position and start time
      var startIndex = rowIndex;
      var startTime  = Date.now();

      var each = options.each;
      while (rowIndex < rowsLength)
      {
        // invoke the each() callback on the current row
        var ret = each(rows[rowIndex++]);

        context.numRowsProcessed++;

        // if the callback returned false, stop processing rows
        if (ret === false)
        {
          var stoppedProcessingRows = true;
          break;
        }

        // use the current position and current time to check if we've been
        // processing rows for too long; if so, leave the rest for the next
        // tick of the event loop
        if ((rowIndex - startIndex) >= context.rowBatchSize &&
            (Date.now() - startTime) > context.rowBatchDuration)
        {
          process.nextTick(processRows);
          break;
        }
      }

      // if there are no more rows for us to process in this chunk
      if (!(rowIndex < rowsLength) || stoppedProcessingRows)
      {
        // if we exhausted all the rows in this chunk and we haven't yet
        // processed all the rows we want to process, ask the result stream to
        // do another read
        if (!(rowIndex < rowsLength) &&
            context.numRowsProcessed !== context.maxNumRowsToProcess)
        {
          resultStream.read();
        }
        else
        {
          // we've either processed all the rows we wanted to process or we
          // were told to stop processing rows by the each() callback; either
          // way, close the result stream to complete the operation
          resultStream.asyncClose();
        }
      }
    }
1315078
def find(*args, **kwargs):
    
    # default end_at to now and start to 1 day from now
    end_at = kwargs.get('end_at', datetime.datetime.now())
    start_at = kwargs.get('start_at', end_at - datetime.timedelta(days=1))

    # default # of records to fetch to be 50
    limit = kwargs.get('limit', 50)

    # if no user is defined, fetch for ALL
    user = kwargs.get('user', None)
    if user:
        return request_log.find(start_at, end_at, limit, spec={'user': user})
    else:
        return request_log.find(start_at, end_at, limit)
343077
def get_splits_in_period(self, start: Datum, end: Datum) -> List[Split]:
        
        # from gnucash_portfolio.lib import generic

        query = (
            self.book.session.query(Split)
            .join(Transaction)
            .filter(Split.account == self.account,
                    Transaction.post_date >= start.value.date(),
                    Transaction.post_date <= end.value.date()
                    )
        )
        # sql = generic.get_sql(query)
        return query.all()
632302
def ReadClientStartupInfoHistory(self, client_id, timerange=None):
    """"""
    from_time, to_time = self._ParseTimeRange(timerange)

    history = self.startup_history.get(client_id)
    if not history:
      return []
    res = []
    for ts in sorted(history, reverse=True):
      if ts < from_time or ts > to_time:
        continue

      client_data = rdf_client.StartupInfo.FromSerializedString(history[ts])
      client_data.timestamp = ts
      res.append(client_data)
    return res
1145949
def last(self, db=_DefaultDB):
        '''
        
        '''
        self._acqXactForReading()
        try:
            with self.xact.cursor(db=db.db) as curs:
                if not curs.last():
                    return None
                return curs.key(), curs.value()
        finally:
            self._relXactForReading()