Get the number of comments inserted since the given timestamp.

@since 1.0
@access public
13573
public function GetCommentCountSince($DiscussionID, $DateAllViewed) {
		// Only for members
		if(!Gdn::Session()->IsValid()) return;
		
		// Validate DiscussionID
		$DiscussionID = (int) $DiscussionID;
		if (!$DiscussionID)
			throw new Exception('A valid DiscussionID is required in GetCommentCountSince.');
		
		// Get new comment count
		return Gdn::Database()->SQL()
			->From('Comment c')
			->Where('DiscussionID', $DiscussionID)
			->Where('DateInserted >', Gdn_Format::ToDateTime($DateAllViewed))
			->GetCount();
	}
1281946
public function revisionAtTimestamp($timestamp)
    {
        $revision = $this->revisions()
                         ->where('created_at', '<=', Carbon::parse($timestamp))
                         ->first();

        return $this->wrapRevision($revision);
    }
1344859
public function commentExists()
    {
        $comments = (new CommentManager())
            ->filter('article = %i', array($this->getArticle()->getId()))
            ->filter("comment = '%s'", array($this->getComment()))
            ->filter("name = '%s'", array($this->fields['name']->getValue()));

        $count = $comments->count();
        return (boolean) $count;
    }
421680
public static function getCommentsSort() {
		$user_setting = elgg_get_plugin_user_setting('comments_order', 0, 'hypeInteractions');
		$setting = $user_setting ?: elgg_get_plugin_setting('comments_order', 'hypeInteractions');
		if ($setting == 'asc') {
			$setting = 'time_created::asc';
		} else if ($setting == 'desc') {
			$setting = 'time_created::desc';
		}
		return $setting;
	}
437756
public function getCount()
    {
        if ($this->_count !== null) {
            return $this->_count;
        }

        while ($this->_hasMore) {
            $this->fetchOutstanding();
        }

        return $this->_length;
    }
590455
def get_num_commenters(self, item):
        """"""

        commenters = [comment['user']['login'] for comment in item['comments_data']]
        return len(set(commenters))
675055
def count_comments_handler(sender, **kwargs):
    
    comment = kwargs['comment']
    if comment.is_public:
        entry = comment.content_object
        if isinstance(entry, Entry):
            entry.comment_count = F('comment_count') + 1
            entry.save(update_fields=['comment_count'])
395838
def obtain_comment_time(comment_id = nil, format = "%H:%M:%S")
      return nil if comment_id.blank?
      comment = Comment.find_by_id(comment_id)
      comment = comment.submitted_on.strftime(format) if !comment.blank?
      comment if !comment.blank?
    end
1288147
public function get_total_responses_count() {
        global $DB;
        if ($this->grandtotal === null) {
            $this->grandtotal = $DB->count_records_sql($this->countsql, $this->countparams);
        }
        return $this->grandtotal;
    }
1141929
public function atLeast($times = null)
    {
        // API compat with mockery - allows atLeast()->times(1)
        if ($times === null) {
            $this->atLeastWasCalled = true;
        } else {
            // normal operation
            $count = 0;
            $this->expectation->setPostPerformCallback(function() use (&$count, $times){
                $this->commentBuilder->incrementCallCount();
                $count++;
                if ($count >= $times) {
                    $this->expectation->setSatisfied(true);
                }
            });

            if ($times === 0) {
                $this->expectation->setSatisfied(true);
            }

            $this->commentBuilder->setTimes($times);
            $this->commentBuilder->setAtLeast(true);
        }
        
        return $this;
    }
293244
protected function _ago($timestamp, $current_time=null)
	{
		// Store the current time
		if (is_null($current_time))
		{
			// Get now
			$current_time = new self('now');
			$current_time = strtotime($current_time);
		}

		// Determine the difference, between the time now and the timestamp
		$difference = $current_time - $timestamp;

		// Set the periods of time
		$periods = array('second', 'minute', 'hour', 'day', 'week', 'month', 'year', 'decade');

		// Set the number of seconds per period
		$lengths = array(1, 60, 3600, 86400, 604800, 2630880, 31570560, 315705600);

		// Determine which period we should use, based on the number of seconds lapsed.
		// If the difference divided by the seconds is more than 1, we use that. Eg 1 year / 1 decade = 0.1, so we move on
		// Go from decades backwards to seconds
		for ($val = count($lengths) - 1; ($val >= 0) && (($number = $difference / $lengths[$val]) <= 1); $val--)
		{
			// Do nothing...
		}

		// Ensure the script has found a match
		if ($val < 0)
		{
			$val = 0;
		}

		// Determine the minor value, to recurse through
		$new_time = $current_time - ($difference % $lengths[$val]);

		// Set the current value to be floored
		$number = floor($number);

		// If required create a plural
		if ($number != 1)
		{
			$periods[$val] .= 's';
		}

		// Return text
		$text = sprintf("%d %s ", $number, $periods[$val]);

		// Ensure there is still something to recurse through, and we have not found 1 minute and 0 seconds.
		if (($val >= 1) && (($current_time - $new_time) > 0))
		{
			$text .= $this->_ago($new_time, $current_time);
		}

		return $text;
	}
785996
public function getCommentsCount()
    {
        //check whether workshett name is set or not
        if ($this->worksheetName == '')
            throw new Exception('Worksheet name not specified');
        $strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() .
            '/worksheets/' . $this->worksheetName . '/comments';
        $signedURI = Utils::sign($strURI);
        $responseStream = Utils::processCommand($signedURI, 'GET', '', '');
        $json = json_decode($responseStream);
        return count($json->Comments->CommentList);

    }
1204635
public static function calculateOffset($count, $limit, $comment = null) {

		$order = self::getCommentsSort();
		$style = self::getLoadStyle();

		if ($comment instanceof Comment) {
			$thread = new Thread($comment);
			$offset = $thread->getOffset($limit, $order);
		} else if (($order == 'time_created::asc' && $style == 'load_older') || ($order == 'time_created::desc' && $style == 'load_newer')) {
			// show last page
			$offset = $count - $limit;
			if ($offset < 0) {
				$offset = 0;
			}
		} else {
			// show first page
			$offset = 0;
		}

		return (int) $offset;
	}
87420
protected function parseTransactionEntryTimestamp()
    {
        $results = [];
        if (preg_match('/^:60F:[C|D]([\d]{6})/m', $this->getCurrentStatementData(), $results) && !empty($results[1])) {
            return $this->sanitizeTimestamp($results[1]);
        }

        return 0;
    }
1294815
public function getNumComments()
    {
        $count = (new CommentManager())
            ->filter("article = %i", array($this->getId()))
            ->filter("active = 1")
            ->filter("spam = 0 ");

        $count = $count->values();

        $num = 0;

        if ($count) {
            foreach ($count as $item) {
                if ($item->isAccessible()) {
                    $num++;
                }
            }
        }

        return $num;
    }
341790
public function getTimestampAttribute()
    {
        if (! array_key_exists('timestamp', $this->attributes)) {
            return Carbon::now();
        }

        return Carbon::parse($this->attributes['timestamp']);
    }
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);
         }
      }
   }