コード例 #1
0
 def update_entry_updated_at(self, entry):
     mutation = self.__get_mutation()
     # to just update the updated_at field, set the same title again
     mutation.update_entry(id=entry.id,
                           data=EntryUpdateInput(title=entry.title))
     log.debug(mutation)
     self.http_endpoint(mutation)
コード例 #2
0
 def __determine_tags(self, rss_data):
     tag_list = list(map(lambda entry: self.__determine_entry_tag(entry), rss_data))
     if tag_list:
         tags = reduce(set.union, tag_list)
     else:
         tags = set()
     log.debug("Determined tags: " + ", ".join(tags))
     return tags
コード例 #3
0
    def create_tag_if_not_existent(self, tag_name, all_existing_tags=None):
        # get all existing tags first if they are not provided
        if not all_existing_tags:
            all_existing_tags = self.get_all_tags()

        # if tag is not present in db, create it
        if not (next(
            (x for x in all_existing_tags if x.name == tag_name), None)):
            self.create_tag(tag_name)
            log.debug("Created new tag entry: " + tag_name)
        else:
            log.debug("Tag " + tag_name +
                      " already exist. No need to add a new entry.")
コード例 #4
0
    def create_language_if_not_existent(self,
                                        lang_name,
                                        all_existing_languages=None):
        # get all existing languages first if they are not provided
        if not all_existing_languages:
            all_existing_languages = self.get_all_languages()

        # if language is not present in db, create it
        if not (next(
            (x for x in all_existing_languages if x.name == lang_name), None)):
            self.create_language(lang_name)
            log.debug("Created new language entry: " + lang_name)
        else:
            log.debug("Language " + lang_name +
                      " already exist. No need to add a new entry.")
コード例 #5
0
def sql_debug(response):
    queries = list(get_debug_queries())
    query_str = ''
    total_duration = 0.0
    for q in queries:
        total_duration += q.duration
        stmt = str(q.statement % q.parameters).replace('\n', '\n       ')
        query_str += 'Query: {0}\nDuration: {1}ms\n\n'.format(
            stmt, round(q.duration * 1000, 2))

    log.debug('=' * 80 + '\n')
    log.debug(' SQL Queries - {0} Queries Executed in {1}ms'.format(
        len(queries), round(total_duration * 1000, 2)))
    log.debug('=' * 80)
    log.debug(query_str.rstrip('\n'))
    log.debug('=' * 80 + '\n')

    return response
コード例 #6
0
 def __detect_lang(self, rss_data_list):
     languages = set(map(lambda feed_entry: self.__detect_entry_lang(feed_entry), rss_data_list))
     log.debug("Detected languages: " + ", ".join(languages))
     return languages
コード例 #7
0
 def get_all_sources(self):
     query = self.__get_query()
     query.all_sources()
     log.debug(query)
     data = self.http_endpoint(query)
     return (query + data).all_sources
コード例 #8
0
 def get_all_entries(self, updated_at_gte=None):
     query = self.__get_query()
     query.all_entries(where=EntryWhereInput(updated_at_gte=updated_at_gte))
     log.debug(query)
     data = self.http_endpoint(query)
     return (query + data).all_entries
コード例 #9
0
 def create_tag(self, tag_name):
     mutation = self.__get_mutation()
     mutation.create_tag(data=TagCreateInput(name=tag_name))
     log.debug(mutation)
     self.http_endpoint(mutation)
コード例 #10
0
 def create_language(self, lang_name):
     mutation = self.__get_mutation()
     mutation.create_language(data=LanguageCreateInput(name=lang_name))
     log.debug(mutation)
     self.http_endpoint(mutation)