Update stats with a new submission
508628
def update_user_stats(self, username, task, submission, result_str, grade, state, newsub):
        
        self.user_saw_task(username, submission["courseid"], submission["taskid"])

        if newsub:
            old_submission = self._database.user_tasks.find_one_and_update(
                {"username": username, "courseid": submission["courseid"], "taskid": submission["taskid"]}, {"$inc": {"tried": 1, "tokens.amount": 1}})

            # Check if the submission is the default download
            set_default = task.get_evaluate() == 'last' or \
                          (task.get_evaluate() == 'student' and old_submission is None) or \
                          (task.get_evaluate() == 'best' and old_submission.get('grade', 0.0) <= grade)

            if set_default:
                self._database.user_tasks.find_one_and_update(
                    {"username": username, "courseid": submission["courseid"], "taskid": submission["taskid"]},
                    {"$set": {"succeeded": result_str == "success", "grade": grade, "state": state, "submissionid": submission['_id']}})
        else:
            old_submission = self._database.user_tasks.find_one(
                {"username": username, "courseid": submission["courseid"], "taskid": submission["taskid"]})

            if task.get_evaluate() == 'best':  # if best, update cache consequently (with best submission)
                def_sub = list(self._database.submissions.find({
                    "username": username, "courseid": task.get_course_id(),
                    "taskid": task.get_id(), "status": "done"}
                ).sort([("grade", pymongo.DESCENDING), ("submitted_on", pymongo.DESCENDING)]).limit(1))

                if len(def_sub) > 0:
                    self._database.user_tasks.find_one_and_update(
                        {"username": username, "courseid": submission["courseid"], "taskid": submission["taskid"]},
                        {"$set": {
                            "succeeded": def_sub[0]["result"] == "success",
                            "grade": def_sub[0]["grade"],
                            "state": def_sub[0]["state"],
                            "submissionid": def_sub[0]['_id']
                        }})
            elif old_submission["submissionid"] == submission["_id"]:  # otherwise, update cache if needed
                self._database.user_tasks.find_one_and_update(
                    {"username": username, "courseid": submission["courseid"], "taskid": submission["taskid"]},
                    {"$set": {
                        "succeeded": submission["result"] == "success",
                        "grade": submission["grade"],
                        "state": submission["state"]
                    }})
260814
def update(self, stats):
        
        if not self.export_enable:
            return False

        # Get all the stats & limits
        all_stats = stats.getAllExportsAsDict(plugin_list=self.plugins_to_export())
        all_limits = stats.getAllLimitsAsDict(plugin_list=self.plugins_to_export())

        # Loop over plugins to export
        for plugin in self.plugins_to_export():
            if isinstance(all_stats[plugin], dict):
                all_stats[plugin].update(all_limits[plugin])
            elif isinstance(all_stats[plugin], list):
                # TypeError: string indices must be integers (Network plugin) #1054
                for i in all_stats[plugin]:
                    i.update(all_limits[plugin])
            else:
                continue
            export_names, export_values = self.__build_export(all_stats[plugin])
            self.export(plugin, export_names, export_values)

        return True
630077
def update_data_request(data_request_id, update_submission_data_request_data, opts = {})
      data, _status_code, _headers = update_data_request_with_http_info(data_request_id, update_submission_data_request_data, opts)
      data
    end
312104
def _update(self, resource, update_dict=None, params=None, **kwargs):
        """"""
        url = self._client._build_url(resource, **kwargs)
        response = self._client._request('PUT', url, json=update_dict, params=params)

        if response.status_code != requests.codes.ok:  # pragma: no cover
            raise APIError("Could not update {} ({})".format(self.__class__.__name__, response.json().get('results')))
        else:
            self.refresh()
272155
def update_stat(self, mode='open', infostr='', stat=''):
        
        self._update_stat[mode](mode, infostr, stat)
253490
def update(self, slug):
        '''
        
        '''

        post_data = self.get_post_data()

        post_data['user_name'] = self.userinfo.user_name

        pageinfo = MWiki.get_by_uid(slug)

        cnt_old = tornado.escape.xhtml_unescape(pageinfo.cnt_md).strip()
        cnt_new = post_data['cnt_md'].strip()
        if cnt_old == cnt_new:
            pass
        else:
            MWikiHist.create_wiki_history(MWiki.get_by_uid(slug))

        MWiki.update(slug, post_data)
        tornado.ioloop.IOLoop.instance().add_callback(self.cele_gen_whoosh)

        self.redirect('/page/{0}'.format(post_data['slug']))
1250721
public void addStats(long updateCount, long insertId, boolean moreResultAvailable) {
    if (cmdInformation == null) {
      if (batch) {
        cmdInformation = new CmdInformationBatch(expectedSize, autoIncrement);
      } else if (moreResultAvailable) {
        cmdInformation = new CmdInformationMultiple(expectedSize, autoIncrement);
      } else {
        cmdInformation = new CmdInformationSingle(insertId, updateCount, autoIncrement);
        return;
      }
    }
    cmdInformation.addSuccessStat(updateCount, insertId);
  }
322555
def update_post(self, postid):
        '''
        


        '''
        voted_recs = MRating.query_by_post(postid)
        if voted_recs.count() > 10:
            rating = MRating.query_average_rating(postid)
        else:
            rating = 5

        logger.info('Get post rating: {rating}'.format(rating=rating))
        # MPost.__update_rating(postid, rating)
        MPost.update_misc(postid, rating=rating)
199643
def update(self):
        """"""
        # Init new stats
        stats = self.get_init_value()

        if import_error_tag:
            return self.stats

        if self.input_method == 'local':
            stats = get_smart_data()
        elif self.input_method == 'snmp':
            pass

        # Update the stats
        self.stats = stats

        return self.stats
1145172
def update(self, request, datum):
        """"""
        if getattr(self, 'action_present', False):
            self.verbose_name = self._get_action_name()
            self.verbose_name_plural = self._get_action_name('plural')
1180772
def stats(contents={}, &callback)
      send_request Request::Stats.new(contents) do |result|
        callback.call result

        if result[:status] == Errors::NO_ERROR && result[:key] != ''
          :proceed
        end
      end
    end
267774
def _update_submission(self, submission):
        """"""
        submission._comments_by_id[self.name] = self  # pylint: disable=W0212
        self._submission = submission
        if self._replies:
            for reply in self._replies:
                reply._update_submission(submission)
554729
def update(self):
        """"""
        # Init new stats
        stats = self.get_init_value()

        # Grab per-CPU stats using psutil's cpu_percent(percpu=True) and
        # cpu_times_percent(percpu=True) methods
        if self.input_method == 'local':
            stats = cpu_percent.get(percpu=True)
        else:
            # Update stats using SNMP
            pass

        # Update the stats
        self.stats = stats

        return self.stats
190086
def update(self):
        """"""
        # Init new stats
        stats = self.get_init_value()

        if import_error_tag:
            return self.stats

        if self.input_method == 'local':
            # Update stats using the PyMDstat lib (https://github.com/nicolargo/pymdstat)
            try:
                # Just for test
                # mds = MdStat(path='/home/nicolargo/dev/pymdstat/tests/mdstat.10')
                mds = MdStat()
                stats = mds.get_stats()['arrays']
            except Exception as e:
                logger.debug("Can not grab RAID stats (%s)" % e)
                return self.stats

        elif self.input_method == 'snmp':
            # Update stats using SNMP
            # No standard way for the moment...
            pass

        # Update the stats
        self.stats = stats

        return self.stats
467716
def update(self):
        
        # Init new stats
        stats = self.get_init_value()

        if self.input_method == 'local' and not import_error_tag:
            # Update stats using the netifaces lib
            try:
                default_gw = netifaces.gateways()['default'][netifaces.AF_INET]
            except (KeyError, AttributeError) as e:
                logger.debug("Cannot grab the default gateway ({})".format(e))
            else:
                try:
                    stats['address'] = netifaces.ifaddresses(default_gw[1])[netifaces.AF_INET][0]['addr']
                    stats['mask'] = netifaces.ifaddresses(default_gw[1])[netifaces.AF_INET][0]['netmask']
                    stats['mask_cidr'] = self.ip_to_cidr(stats['mask'])
                    stats['gateway'] = netifaces.gateways()['default'][netifaces.AF_INET][0]
                    stats['public_address'] = self.public_address
                except (KeyError, AttributeError) as e:
                    logger.debug("Cannot grab IP information: {}".format(e))
        elif self.input_method == 'snmp':
            # Not implemented yet
            pass

        # Update the stats
        self.stats = stats

        return self.stats
786051
def update(self):
        """"""
        # For standalone and server modes
        # For each plugins, call the update method
        for p in self._plugins:
            if self._plugins[p].is_disable():
                # If current plugin is disable
                # then continue to next plugin
                continue
            # Update the stats...
            self._plugins[p].update()
            # ... the history
            self._plugins[p].update_stats_history()
            # ... and the views
            self._plugins[p].update_views()
76534
@PrePersist
    @PreUpdate
    final void updateStats() {
        if (!this.modified || this.statisticalSummary == null) {
            return;
        }

        // Update statistic values
        this.count = (int) this.statisticalSummary.getN();
        this.sum = this.statisticalSummary.getSum();
        this.sumsq = this.statisticalSummary.getSumsq();
        this.mean = this.statisticalSummary.getMean();
        this.standardDeviation = this.statisticalSummary.getStandardDeviation();
        this.variance = this.statisticalSummary.getVariance();
        this.populationVariance = this.statisticalSummary.getPopulationVariance();
        this.max = this.statisticalSummary.getMax();
        this.min = this.statisticalSummary.getMin();
        this.geometricMean = this.statisticalSummary.getGeometricMean();
        this.sumOfLogs = this.statisticalSummary.getSumOfLogs();
        this.secondMoment = this.statisticalSummary.getSecondMoment();

        this.modified = false;
    }