Example #1
0
def upsert_author(info):
    with db_session:
        a = Author.get(author_id=info['author_id'])
        if a:
            logger.debug('author has existed, author_id=%s', info['author_id'])
            return
        # logger.debug(info)
        author = Author(author_id=info['author_id'])
        author.name = info['name'] if info['name'] else ''
        author.image_url = info['image_url'] if info['image_url'] else ''
        author.organization = info['organization'] if info[
            'organization'] else ''
        author.home_page = info['home_page'] if info['home_page'] else ''
        author.paper_count = info['paper_count']
        author.citied_count = info['cited_count']

        for d in info['domains']:
            if d['id'] == '':
                continue
            ds = Domain.get(domain_id=d['id'])
            if ds:
                author.domains.add(ds)
            else:
                domain = Domain(domain_id=d['id'])
                domain.name = d['name']
                author.domains.add(domain)
Example #2
0
    def test_get(self):
        with db_session:
            a = Author.get(author_id='ded2d8cd-73c6-41c0-bcf7-db2983805231')
            logger.debug(a.organization)
            self.assertEqual(a.name, 'Abraham Silberschatz')

            d = Domain.get(domain_id='1.1')
            logger.debug(d.name)
            self.assertEqual(d.name, '算法与理论')