Retrieves chat logs

    :param room: the `Chatroom`
    :param start_date: the earliest date to get logs for
    :param end_date: the latest date to get logs for
    :return: logs in html format
548194
def retrieve_logs(room, start_date=None, end_date=None):
    
    from indico_chat.plugin import ChatPlugin

    base_url = ChatPlugin.settings.get('log_url')
    if not base_url or room.custom_server:
        return None

    params = {'cr': room.jid}
    if start_date:
        params['sdate'] = start_date.strftime('%Y-%m-%d')
    if end_date:
        params['edate'] = end_date.strftime('%Y-%m-%d')

    try:
        response = requests.get(base_url, params=params)
    except RequestException:
        current_plugin.logger.exception('Could not retrieve logs for %s', room.jid)
        return None
    if response.headers.get('content-type') == 'application/json':
        current_plugin.logger.warning('Could not retrieve logs for %s: %s', room.jid, response.json().get('error'))
        return None
    return response.text
145994
def time_entries(self, start_date=None, end_date=None):
        ''''''
        if self.cache['time_entries']: return self.cache['time_entries']
        if not start_date:
            start_date = datetime.date(1900, 1, 1)
        if not end_date:
            end_date = datetime.date.today()
        time_entry_xml = self.bc.list_time_entries(self.id, start_date, end_date)
        time_entries = []
        for entry in ET.fromstring(time_entry_xml).findall("time-entry"):
            time_entries.append(TimeEntry(entry))
        self.cache['time_entries'] = time_entries
        return self.cache['time_entries']
1262678
def fetch_messages(self):
        
        if self._fetched:
            return

        start = time.time()

        loaded_messages = self.queue.lease_tasks_by_tag(
            self.duration, self.size, tag=self.tag, deadline=self.deadline)

        # If we are within 0.1 sec of our deadline and no messages were
        # returned, then we are hitting queue contention issues and this
        # should be a DeadlineExceederError.
        # TODO: investigate other ways around this, perhaps async leases, etc.
        if (not loaded_messages and
                round(time.time() - start, 1) >= self.deadline - 0.1):
            raise DeadlineExceededError()

        self._messages.extend(loaded_messages)

        self._fetched = True

        logging.debug("Calling fetch messages with %s:%s:%s:%s:%s:%s" % (
            len(self._messages), len(loaded_messages),
            len(self._processed_messages), self.duration, self.size, self.tag))
1353857
def get_last_live_chat(self):
        
        now = datetime.now()

        lcqs = self.get_query_set()
        lcqs = lcqs.filter(
            chat_ends_at__lte=now,
            ).order_by('-chat_ends_at')
        for itm in lcqs:
            if itm.chat_ends_at + timedelta(days=3) > now:
                return itm
        return None
495448
def entries(self, start = None, end = None):
        ''''''
        if not start:
            start = self.earliest_record
        if not end:
            end = self.latest_record
        fr = start.strftime('%Y%m%d')
        to = end.strftime('%Y%m%d')
        url = str.format(
            'projects/{}/entries?from={}&to={}',
            self.id,
            fr,
            to,
        )
        response = self.hv.get_request(url)
        return [Entry(self.hv, ej['day_entry']) for ej in response]
1346940
def mission_start_date_as_string(self) -> str:
        
        return self._start_date_as_string(self.day, self.month, self.year)
1370943
public List<UserCumulative> getUserCumulative(Date start, Date end) {
        if(diffThan6Days(start, end)) {
            throw new IllegalArgumentException("start和end相差不能超过6天以上");
        }

        String url = WxEndpoint.get("url.stats.user.cumulative");
        String json = "{\"begin_date\":\"%s\",\"end_date\":\"%s\"}";

        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        String body = String.format(json, dateFormat.format(start), dateFormat.format(end));
        logger.debug("stats: get user summary: {}", body);
        String response = wxClient.post(url, body);
        UserCumulativeWrapper userCumulativeWrapper = JsonMapper.defaultMapper().fromJson(response, UserCumulativeWrapper.class);
        return userCumulativeWrapper.getList();
    }
830254
def get_events(self, login=None, start_date=None, end_date=None, **kwargs):
        

        _login = kwargs.get(
            'login',
            login
        )
        log_events_url = EVENTS_URL.format(
            login=_login,
            start_date=start_date,
            end_date=end_date,
        )
        return self._request_api(url=log_events_url).json()
577557
def today_transcript(&callback)
      connection.http(:get, "/room/#{id}/transcript.json") do |data, http|
        callback.call(data[:messages].map { |msg| Firering::Message.instantiate(connection, msg) }) if callback
      end
    end
315943
public function get_rooms_history($room_id, $date = 'recent') {
     $response = $this->make_request('rooms/history', array(
      'room_id' => $room_id,
      'date' => $date
     ));
     return $response->messages;
   }
1262794
public List<SessionLog> listSessionLogs(Date start, Date end, int index, int size) {
        String url = WxEndpoint.get("url.care.session.logs");
        Map<String, Object> request = new HashMap<>();
        request.put("starttime", start.getTime() / 1000);
        request.put("endtime", end.getTime() / 1000);
        request.put("pageindex", index);
        request.put("pagesize", size);

        String json = JsonMapper.nonEmptyMapper().toJson(request);
        logger.debug("get session logs: {}", json);
        String response = wxClient.post(url, json);
        SessionLogList sessionLogList = JsonMapper.defaultMapper().fromJson(response, SessionLogList.class);
        return sessionLogList.getLogs();
    }
1219806
function (startTime, endTime, callback) {
    var self = this;

    self._request({
      path: urlJoin(_urlPrefix, 'usage'),
      qs: {
        startTime: typeof startTime === 'Date' ? startTime.toISOString() : startTime,
        endTime: typeof endTime === 'Date' ? endTime.toISOString() : endTime
      }
    }, function (err, body) {
      return callback(err, body);
    });
  }
500726
def fill_date_range(start_date, end_date, date_format=None):
    

    if date_format:
        start_date = datetime.strptime(start_date, date_format).date()
        end_date = datetime.strptime(end_date, date_format).date()
    date_list = []
    while start_date <= end_date:
        date_list.append(start_date)
        start_date = start_date + timedelta(days=1)
    return date_list
45758
def _metrics_get_endpoints(options):
    
    if bool(options.start) ^ bool(options.end):
        log.error('--start and --end must be specified together')
        sys.exit(1)

    if options.start and options.end:
        start = options.start
        end = options.end
    else:
        end = datetime.utcnow()
        start = end - timedelta(options.days)

    return start, end
861959
def dates_in_range(start_date, end_date):
    
    return [
        start_date + timedelta(n)
        for n in range(int((end_date - start_date).days))
    ]
772193
def on_chat(self, data):
        '''  '''
        # XXX: we cannot use on_message as it's 'official' one already used
        # by sockjsroom to create multiple on_* elements (like on_chat),
        # so we use on_chat instead of on_message

        # data => message
        if self.roomId != '-1':
            self.publishToRoom(self.roomId, 'chat', {
                'username': self.username,
                'time': datetime.now(),
                'message': str(data['message'])
            })
860371
def daterange(start_date, end_date):
    
    for n in range(int((end_date - start_date).days)):
        yield start_date + timedelta(n)