예제 #1
0
    def collectTask(self,
                    request,
                    access_type,
                    page_name=None,
                    params=None,
                    **kwargs):
        """Task for collecting statistics that will be executed by Task Queue API.
    """

        logic = params['logic']
        link_id = kwargs['link_id']
        scope_path = kwargs['scope_path']

        statistic = self._getStatisticEntity(link_id, scope_path, logic)
        if statistic is None:
            raise task_responses.FatalTaskError

        statistic, completed = logic.collectDispatcher(statistic)

        self._updateCache(statistic, link_id, scope_path, logic)

        if completed:
            self._updateCacheList(statistic, scope_path, logic)
            statistic.put()
        else:
            task_responses.startTask(url=request.path, queue_name='statistic')

        return task_responses.terminateTask()
예제 #2
0
    def updateOrClearStats(self,
                           request,
                           access_type,
                           page_name=None,
                           params=None,
                           **kwargs):
        """Collects one batch of statistic or clears a statistic.
    """

        get_dict = request.GET

        logic = params['logic']
        link_id = kwargs['link_id']
        scope_path = kwargs['scope_path']

        statistic = None

        if 'update' in get_dict:
            statistic, _ = logic.collectDispatcher(
                self._getStatisticEntity(link_id, scope_path, logic))

        elif 'clear' in get_dict:
            statistic = logic.clearStatistic(
                self._getStatisticEntity(link_id, scope_path, logic))

        if statistic is not None:
            self._updateCacheList(statistic, scope_path, logic)
            self._updateCache(statistic, link_id, scope_path, logic)

        fields = {
            'url_name': params['url_name'],
            'scope_path': scope_path,
            'link_id': link_id
        }

        if 'show_after_operation' in get_dict:
            return http.HttpResponseRedirect(
                '/%(url_name)s/show/%(scope_path)s/%(link_id)s' % fields)

        return http.HttpResponseRedirect(
            '/%(url_name)s/manage_stats/%(scope_path)s' % fields)
예제 #3
0
  def updateOrClearStats(self, request, access_type, page_name=None,
                  params=None, **kwargs):
    """Collects one batch of statistic or clears a statistic.
    """

    get_dict = request.GET

    logic = params['logic']
    link_id = kwargs['link_id']
    scope_path = kwargs['scope_path']

    statistic = None

    if 'update' in get_dict:
      statistic, _ = logic.collectDispatcher(
          self._getStatisticEntity(link_id, scope_path, logic))

    elif 'clear' in get_dict:
      statistic = logic.clearStatistic(
          self._getStatisticEntity(link_id, scope_path, logic))

    if statistic is not None:
      self._updateCacheList(statistic, scope_path, logic)
      self._updateCache(statistic, link_id, scope_path, logic)

    fields = {
        'url_name': params['url_name'],
        'scope_path': scope_path,
        'link_id': link_id
        }

    if 'show_after_operation' in get_dict:
      return http.HttpResponseRedirect(
             '/%(url_name)s/show/%(scope_path)s/%(link_id)s' % fields)

    return http.HttpResponseRedirect(
           '/%(url_name)s/manage_stats/%(scope_path)s' % fields)
예제 #4
0
  def collectTask(self, request, access_type, page_name=None,
                      params=None, **kwargs):
    """Task for collecting statistics that will be executed by Task Queue API.
    """

    logic = params['logic']
    link_id = kwargs['link_id']
    scope_path = kwargs['scope_path']

    statistic = self._getStatisticEntity(link_id, scope_path, logic)
    if statistic is None:
      raise task_responses.FatalTaskError

    statistic, completed = logic.collectDispatcher(statistic)

    self._updateCache(statistic, link_id, scope_path, logic)

    if completed:
      self._updateCacheList(statistic, scope_path, logic)
      statistic.put()
    else:
      task_responses.startTask(url=request.path, queue_name='statistic')

    return task_responses.terminateTask()