@gen.engine
  def _RepairMissingActivities(self, user_id, viewpoint, name, act_args, callback):
    timestamp = util.GetCurrentTimestamp()
    unique_id = yield gen.Task(Device.AllocateSystemObjectId, self._client)
    activity_id = Activity.ConstructActivityId(timestamp, Device.SYSTEM, unique_id)

    if name == 'add_followers':
      yield gen.Task(Activity.CreateAddFollowers, self._client, user_id, viewpoint.viewpoint_id,
                     activity_id, timestamp, update_seq=0, follower_ids=act_args)
    elif name == 'upload_episode':
      episode, photos = act_args
      ep_dict = {'episode_id': episode.episode_id}
      ph_dicts = [{'photo_id': photo.photo_id} for photo in photos]
      yield gen.Task(Activity.CreateUploadEpisode, self._client, user_id, viewpoint.viewpoint_id,
                     activity_id, timestamp, update_seq=0, ep_dict=ep_dict, ph_dicts=ph_dicts)
    elif name in ['save_photos']:
      episode, photos = act_args
      ep_dict = {'new_episode_id': episode.episode_id,
                 'photo_ids': [ph.photo_id for ph in photos]}
      yield gen.Task(Activity.CreateSavePhotos, self._client, user_id, viewpoint.viewpoint_id,
                     activity_id, timestamp, update_seq=0, ep_dicts=[ep_dict])
    elif name in ['share_new', 'share_existing']:
      episode, photos, follower_ids = act_args
      ep_dict = {'new_episode_id': episode.episode_id,
                 'photo_ids': [ph.photo_id for ph in photos]}
      if name == 'share_new':
        yield gen.Task(Activity.CreateShareNew, self._client, user_id, viewpoint.viewpoint_id,
                       activity_id, timestamp, update_seq=0, ep_dicts=[ep_dict],
                       follower_ids=follower_ids)
      else:
        yield gen.Task(Activity.CreateShareExisting, self._client, user_id, viewpoint.viewpoint_id,
                       activity_id, timestamp, update_seq=0, ep_dicts=[ep_dict])
    elif name == 'post_comment':
      yield gen.Task(Activity.CreatePostComment, self._client, user_id, viewpoint.viewpoint_id,
                     activity_id, timestamp, update_seq=0, cm_dict={'comment_id': act_args})

    logging.warning('  added activity: %s', (viewpoint.viewpoint_id, name))
    callback()
Adds a missing activity to the specified viewpoint.
dataset/ETHPy150Open viewfinderco/viewfinder/backend/db/tools/dbchk.py/DatabaseChecker._RepairMissingActivities