예제 #1
0
 def _convert_group_to_author(self):
     """
     Method takes given group_id from config.ini and creates Author object for it.
     """
     author = Author()
     author.name = self.get_group_name()
     author.author_osn_id = self._group_id
     author.author_guid = commons.compute_author_guid_by_osn_id(
         author.author_osn_id)
     author.domain = self._domain
     author.author_type = "Group"
     author.followers_count = self.get_group_number_of_members()
     author.author_sub_type = self.get_group_level_of_activity()
     return author
    def setUp(self):
        self._db = DB()
        self._db.setUp()
        self.author_guid = u"author_guid"

        author = Author()
        author.author_guid = self.author_guid
        author.author_full_name = u'author'
        author.name = u'author_name'
        author.author_screen_name = u'author_screen_name'
        author.domain = u'Microblog'
        author.statuses_count = 10
        author.friends_count = 5
        author.followers_count = 6
        author.favourites_count = 8
        author.author_sub_type = u"bot"
        author.author_type = u"bad"
        author.created_at = u"2017-06-17 05:00:00"
        author.default_profile = True
        author.default_profile_image = True
        author.verified = True
        self._db.add_author(author)

        post = Post()
        post.author = self.author_guid
        post.author_guid = self.author_guid
        post.content = u"content"
        post.title = u"title"
        post.domain = u"domain"
        post.post_id = u"post_id"
        post.guid = post.post_id
        post.date = convert_str_to_unicode_datetime("2017-06-14 05:00:00")
        post.created_at = post.date
        self._db.addPost(post)

        self._db.session.commit()
        self.feature_prefix = u"AccountPropertiesFeatureGenerator_"
        self.account_properties_feature_generator = AccountPropertiesFeatureGenerator(
            self._db, **{
                'authors': [author],
                'posts': {
                    self.author_guid: [post]
                }
            })
        self.account_properties_feature_generator.execute()
 def updateAuthorsData(self):
     list_to_add = []
     for dic in self._author_prop_dict:
         try:
             author = Author()
             author.name = dic['author']
             author.domain = unicode('Microblog')
             author.author_osn_id = dic['author_osn_id']
             author.author_guid = dic['author_guid']
             author.followers_count = dic['followers_count']
             author.location = dic['location']
             author.favourites_count = dic['favorite']
             author.description = dic['description']
             author.url = dic['url']
             list_to_add.append(author)
         except (ValueError, TypeError, KeyError) as e:
             logging.warn("Failed to add author: {0} - {1}".format(author.name, e))
     self._db.update_authors(list_to_add)