Update the commentable cache counter columns

 Look for a `<role>_comments_count` and a `comments_count` column
 in the commentable model and the commenter model and update their value with the count.
194573
def update_cache_counters
      commenter_has_comments = commenter.respond_to?(:comments)

      # Role-specific counter
      role_method = :"#{self.role}_comments_count="
      commentable.send role_method, commentable.comments.where(role: self.role).count if commentable.respond_to?(role_method)
      commenter.send role_method, commenter.comments.where(role: self.role).count if commenter_has_comments && commenter.respond_to?(role_method)

      # Global counter
      total_method = :comments_count=
      commentable.send total_method, commentable.comments.count if commentable.respond_to?(total_method)
      commenter.send total_method, commenter.comments.count if commenter_has_comments && commenter.respond_to?(total_method)

      commentable.save(validate: false)
      commenter.save(validate: false)
    end
1264551
def update(self, *args, **kwargs):
        
        if args:
            self.database.hmset(self.key, *args)
        else:
            self.database.hmset(self.key, kwargs)
1197309
public function setCommentscount($v)
    {
        if ($v !== null) {
            $v = (int) $v;
        }

        if ($this->commentscount !== $v) {
            $this->commentscount = $v;
            $this->modifiedColumns[MxmapTableMap::COL_COMMENTSCOUNT] = true;
        }

        return $this;
    }
786870
public function UpdateCommentCount($Discussion) {
      // Get the discussion.
      if (is_numeric($Discussion))
         $Discussion = $this->SQL->GetWhere('Discussion', array('DiscussionID' => $Discussion))->FirstRow(DATASET_TYPE_ARRAY);
      $DiscussionID = $Discussion['DiscussionID'];

      $this->FireEvent('BeforeUpdateCommentCountQuery');
      
      $Data = $this->SQL
         ->Select('c.CommentID', 'min', 'FirstCommentID')
         ->Select('c.CommentID', 'max', 'LastCommentID')
         ->Select('c.DateInserted', 'max', 'DateLastComment')
         ->Select('c.CommentID', 'count', 'CountComments')
         ->From('Comment c')
         ->Where('c.DiscussionID', $DiscussionID)
         ->Get()->FirstRow(DATASET_TYPE_ARRAY);

      $this->EventArguments['Discussion'] =& $Discussion;
      $this->EventArguments['Counts'] =& $Data;
      $this->FireEvent('BeforeUpdateCommentCount');
      
      if ($Discussion) {
         if ($Data) {
            $this->SQL->Update('Discussion');
            if (!$Discussion['Sink'] && $Data['DateLastComment'])
               $this->SQL->Set('DateLastComment', $Data['DateLastComment']);
            elseif (!$Data['DateLastComment'])
               $this->SQL->Set('DateLastComment', $Discussion['DateInserted']);

            $this->SQL
               ->Set('FirstCommentID', $Data['FirstCommentID'])
               ->Set('LastCommentID', $Data['LastCommentID'])
               ->Set('CountComments', $Data['CountComments'])
               ->Where('DiscussionID', $DiscussionID)
               ->Put();

            // Update the last comment's user ID.
            $this->SQL
               ->Update('Discussion d')
               ->Update('Comment c')
               ->Set('d.LastCommentUserID', 'c.InsertUserID', FALSE)
               ->Where('d.DiscussionID', $DiscussionID)
               ->Where('c.CommentID', 'd.LastCommentID', FALSE, FALSE)
               ->Put();
         } else {
            // Update the discussion with null counts.
            $this->SQL
               ->Update('Discussion')
               ->Set('CountComments', 0)
               ->Set('FirstCommentID', NULL)
               ->Set('LastCommentID', NULL)
               ->Set('DateLastComment', 'DateInserted', FALSE, FALSE)
               ->Set('LastCommentUserID', NULL)
               ->Where('DiscussionID', $DiscussionID);
         }
      }
   }
703456
def set_column_comment(table_name, column_name, comment_text)
      execute comment_sql(CommentDefinition.new(table_name, column_name, comment_text))
    end
420633
def _UpdateCounters(self, event):
    
    self._session.parsers_counter['total'] += 1

    # Here we want the name of the parser or plugin not the parser chain.
    parser_name = getattr(event, 'parser', '')
    _, _, parser_name = parser_name.rpartition('/')
    if not parser_name:
      parser_name = 'N/A'
    self._session.parsers_counter[parser_name] += 1
1331057
function updateColsCount()
	{
		$this->_colsCount = sizeof($this->flds);
		foreach($this->_belongsTo as $foreignTable)
			$this->_colsCount += sizeof($foreignTable->TableInfo()->flds);
		foreach($this->_hasMany as $foreignTable)
			$this->_colsCount += sizeof($foreignTable->TableInfo()->flds);
	}
1238783
def add_comments(self, comments):
        
        for comment in comments:
            if comment not in self.comments and len(comment) > 0:
                self.comments.append(comment)
            if len(self.comments[0]) == 0:
                self.comments.pop(0)
155957
def update(self, columns=(), by=(), where=(), **kwds):
        
        return self._seu('update', columns, by, where, kwds)
176011
public function UpdateProductViewCount()
    {
        if (CMS_SHOP_TRACK_ARTICLE_DETAIL_VIEWS && !is_null($this->id)) {
            $this->getProductStatsService()->add($this->id, ProductStatisticsServiceInterface::TYPE_DETAIL_VIEWS, 1);
        }
    }
452406
def update(postid, userid, rating):
        '''
        
        '''
        rating_recs = TabRating.select().where(
            (TabRating.post_id == postid) & (TabRating.user_id == userid)
        )
        if rating_recs.count() > 0:
            MRating.__update_rating(rating_recs.get().uid, rating)
        else:
            MRating.__insert_data(postid, userid, rating)
447131
def update_credit_note_comment(self, credit_note_comment_id, credit_note_comment_dict):
        
        return self._create_put_request(
            resource=CREDIT_NOTE_COMMENTS,
            billomat_id=credit_note_comment_id,
            send_data=credit_note_comment_dict
        )
348368
def update(self, response, **kwargs):
        '''
        
        '''
        response_cls = self._get_instance(**kwargs)
        if response_cls:
            setattr(response_cls, self.column, self.accessor(response))
            _action_and_commit(response_cls, session.add)
        else:
            self.get_or_create_from_legacy_response(response, **kwargs)
815766
def update_counts(self):
        ""
        # Properties.attrib['TotalCountOfFields']
        fields = str(len(self.fields))
        self.properties.attrib['TotalCountOfFields'] = fields

        # Properties.CountOfWellsX/Y
        wx, wy = (str(x) for x in self.count_of_wells)

        self.properties.CountOfWellsX = wx
        self.properties.CountOfWellsY = wy

        # Properties.attrib['TotalCountOfWells']
        wells = str(len(self.wells))
        self.properties.attrib['TotalCountOfWells'] = wells

        # Properties.attrib['TotalAssignedJobs']
        self.properties.attrib['TotalAssignedJobs'] = str(self.count_of_assigned_jobs)
758493
def update_count(self):
        
        node_rating_count = self.node.rating_count
        node_rating_count.comment_count = self.node.comment_set.count()
        node_rating_count.save()
533894
private function commentColumn($table, $column, $comment)
    {
        $table  = $this->wrapValue($table);
        $table  = $this->connection->getTablePrefix() . $table;
        $column = $this->wrapValue($column);

        $this->connection->statement("comment on column {$table}.{$column} is '{$comment}'");
    }
644679
def comment_count(obj):
    
    model_object = type(obj).objects.get(id=obj.id)
    return model_object.comments.all().count()