Retrieve recently changed / added docs


    Args:

    include_docs <bools> if true full document data will be retrieved
    limit <int> if != None and > 0 limit the result set to this amount of rows

    Returns a view result to be iterated through
774546
def recent_docs(self, include_docs=True, limit=None):

    

    try:
      return self.bucket.view("_changed", include_docs=include_docs, limit=limit)
    except:
      raise
101293
function getDoc (docName, qs0, callback0) {
      const { opts, callback } = getCallback(qs0, callback0)

      if (!docName) {
        if (callback) { callback(new Error('Invalid doc id'), null) }
      } else {
        return relax({ db: dbName, doc: docName, qs: opts }, callback)
      }
    }
830820
def get_new_timesheets_contents(self):
        
        popular_aliases = self.get_popular_aliases()
        template = ['# Recently used aliases:']

        if popular_aliases:
            contents = '\n'.join(template + ['# ' + entry for entry, usage in popular_aliases])
        else:
            contents = ''

        return contents
842449
def search_result_document(search_params)
        _, document_list = search_results(search_params)
        return document_list.first unless document_list.empty?
        document_not_found!
      end
139939
def get(self, doc_id):
        """"""
        resp_dict = self._get_query(q='id:{}'.format(doc_id))
        if resp_dict['response']['numFound'] > 0:
            return resp_dict['response']['docs'][0]
1369778
def find_include_doc(self, d, name):
        
        from metatab import parse_app_url

        include_ref = name.strip('/')

        if include_ref.startswith('http'):
            path = include_ref
        else:
            if not d:
                raise IncludeError("Can't include '{}' because don't know current path "
                                   .format(name))

            path = join(d, include_ref)

        return parse_app_url(path)
498833
def get_last_doc(self):
        
        #search everything, sort by descending timestamp, return 1 row
        try:
            result = self.solr.search('*:*', sort='_ts desc', rows=1)
        except ValueError:
            return None

        for r in result:
            r['_id'] = r.pop(self.unique_key)
            return r
1078862
def open_doc(self, doc_id):
        '''
        '''
        d = defer.Deferred()
        self.increase_stat('open_doc')
        try:
            doc = self._get_doc(doc_id)
            doc = copy.deepcopy(doc)
            if doc.get('_deleted', None):
                raise NotFoundError('%s deleted' % doc_id)
            d.callback(Response(doc))
        except NotFoundError as e:
            d.errback(e)

        return d
696271
def documents(self, full=False):
        ''''''
        url = self.base_url + self.DOCUMENTS_PAGE
        class_ = Document
        results = self._retrieve_resources(url, class_, full)
        return results
194646
def __get_document(self, content):
        

        document = QTextDocument(QString(content))
        document.clearUndoRedoStacks()
        document.setModified(False)
        return document
1338395
def views(self):
        
        if self._views:
            return self._views
        elif not self.abstract:
            return self.read_meta()._views

        raise EmptyDocumentException()
212247
def _update_docstrings(self):
        
        ops = self._details.resource_data['operations']

        for method_name in ops.keys():
            meth = getattr(self.__class__, method_name, None)

            if not meth:
                continue

            if meth.__doc__ != DEFAULT_DOCSTRING:
                # It already has a custom docstring. Leave it alone.
                continue

            # Needs updating. So there's at least *something* vaguely useful
            # there, use the docstring from the underlying ``Connection``
            # method.
            # FIXME: We need to figure out a way to make this more useful, if
            #        possible.
            api_name = ops[method_name]['api_name']
            conn_meth = getattr(self._connection, to_snake_case(api_name))

            # We need to do detection here, because Py2 treats ``.__doc__``
            # as a special read-only attribute. :/
            if six.PY3:
                meth.__doc__ = conn_meth.__doc__
            else:
                meth.__func__.__doc__ = conn_meth.__doc__
1108852
def setDoc(self, docs):
        
        # sort stim by start time
        docs = sorted(docs, key=lambda k: k['start_s'])

        for doc in docs:
            stim_type = doc['stim_type']
            if not stim_type in self.displayTable:
                continue
            if not stim_type in self.displayTable[stim_type]:
                continue
            display_attributes = self.displayTable.get(stim_type, self.defaultAttributes)
            
            self.lyt.addWidget(ComponentDetailFrame(doc, display_attributes))
207128
def _doCleanup(self):
        
        # pass on this if we're not configured yet
        if not self.configured_url:
            return

        d = self.changes.pruneChanges(self.master.config.changeHorizon)
        d.addErrback(log.err, 'while pruning changes')
        return d
855287
def collect(since, to, top=DEFAULT_TOP):
    
    summary = CspReportSummary(since, to, top=top)
    queryset = CSPReport.objects.filter(created__range=(since, to))
    valid_queryset = queryset.filter(is_valid=True)
    invalid_queryset = queryset.filter(is_valid=False)

    summary.total_count = queryset.count()
    summary.valid_count = valid_queryset.count()

    # Collect sources
    sources = {}
    for report in valid_queryset:
        root_uri = get_root_uri(report.document_uri)
        info = sources.setdefault(root_uri, ViolationInfo(root_uri))
        info.append(report)
    summary.sources = sorted(sources.values(), key=attrgetter('count'), reverse=True)[:top]

    # Collect blocks
    blocks = {}
    for report in valid_queryset:
        root_uri = get_root_uri(report.blocked_uri)
        info = blocks.setdefault(root_uri, ViolationInfo(root_uri))
        info.append(report)
    summary.blocks = sorted(blocks.values(), key=attrgetter('count'), reverse=True)[:top]

    # Collect invalid reports
    summary.invalid_count = invalid_queryset.count()
    summary.invalid_reports = tuple(invalid_queryset[:top])

    return summary
599707
def get_last_doc(self):
        
        try:
            result = self.elastic.search(
                index=self.meta_index_name,
                body={
                    "query": {"match_all": {}},
                    "sort": [{"_ts": "desc"}],
                },
                size=1
            )["hits"]["hits"]
            for r in result:
                r['_source']['_id'] = r['_id']
                return r['_source']
        except es_exceptions.RequestError:
            # no documents so ES returns 400 because of undefined _ts mapping
            return None
844036
def read(self, include_deleted=False):
        """"""
        if is_soft_delete() and not include_deleted:
            return self.filter(unread=False, deleted=False)

        # When SOFT_DELETE=False, developers are supposed NOT to touch 'deleted' field.
        # In this case, to improve query performance, don't filter by 'deleted' field
        return self.filter(unread=False)