def post(self):
        """."""
        logging.info('tasks/upd_gplus')

        bad_posts = []
        gplus_id = self.request.get('gplus_id')
        logging.info(gplus_id)

        # build the service object for the gplus api
        API_KEY = get_server_api_key()
        gplus_service = build('plus', 'v1', developerKey=API_KEY)
        # get the activities for the gde
        activities = ActivityPost.query(ActivityPost.gplus_id == gplus_id)

        for activity in activities:
            if activity.deleted:
                continue

            # check if post belongs to deleted activity
            activity_record = ar.find(activity)
            if activity_record is not None:
                if activity_record.deleted:
                    continue

            logging.info(activity_record)

            # find out if the acticity post links to a YouTube video
            video_id = is_youtube_video(activity.links)
            if video_id is not False:
                logging.info('linked YT video found %s', video_id)

                # ensure a metadata entry exist for the video
                meta_found = False
                for meta in activity_record.metadata:
                    if meta.type == '#video' and meta.link == activity_record.activity_link:
                        logging.info('metadata record exist')
                        meta_found = True
                        break

                    if meta.type == '#video' and meta.link is None:
                        meta_found = True
                        logging.info('metadata record incomplete')
                        meta.activity_group = '#content'
                        meta.link = activity_record.activity_link
                        activity_record.put()
                        break

                if not meta_found:
                    logging.info('metadata record NOT found')
                    activity_record.metadata.insert(0, ActivityMetaData())
                    meta = activity_record.metadata[0]
                    meta.type = '#video'
                    meta.activity_group = '#content'
                    meta.link = activity_record.activity_link
                    activity_record.put()

            # get the activity from gplus
            fields = 'id,verb,actor/id,annotation,object(id,actor/id,plusoners/totalItems,replies/totalItems,resharers/totalItems,content)'
            try:
                plus_activity = gplus_service.activities().get(
                    activityId=activity.post_id,
                    fields=fields).execute()
            except:
                # try again
                logging.info('trying to get gplus activities again')
                try:
                    plus_activity = gplus_service.activities().get(
                        activityId=activity.post_id,
                        fields=fields).execute()
                except:
                    logging.info('failed again, giving up')
                    continue

            if not is_gde_post(plus_activity):
                # gde tag has been removed from post
                # This post and associated AR should be deleted
                # For now we just skip any further action on this post
                continue

            updated_activity = self.update_if_changed(activity, plus_activity)

            if updated_activity is not None:
                logging.info('updated gplus post id %s' %
                             updated_activity.post_id)
                activity_record = find_or_create_ar(
                    plus_activity, updated_activity)
                activity_record.add_post(updated_activity)
                updated_activity.put()

            # does the activity have the necessary hashtags? NOT -> bad_posts
            if len(activity.product_group) == 0 or len(activity.activity_type) == 0:
                # check associated AR as well
                really_bad = False
                activity_record = ar.find(activity)
                if activity_record is None:
                    really_bad = True
                elif len(activity_record.activity_types) == 0 or len(activity_record.product_groups) == 0:
                    really_bad = True

                if really_bad:
                    logging.info('bad post spotted')
                    bad_posts.append(activity.url)

        update_video_views(gplus_id)

        if len(bad_posts) > 0:
            self.send_update_mail(bad_posts, gplus_id)
dataset/ETHPy150Open GoogleDeveloperExperts/experts-app-backend/services/update_gplus.py/TaskUpdateGplus.post/original