/*
Public: Get dislikes
Get number of dislikes on comments by user
161180
public function getDislikes()
    {
        $app = App::getInstance();

        if (!$this->dislikes) {
            $sql = $app['safesql']->query(
                "SELECT
    SUM(dislikes)
    FROM `comment`
    WHERE user='%s'
    AND `active`=1
    AND deleted = 0",
                array(
                    $this->getUser(),
                ));
            $this->dislikes = $app['db']->get_var($sql);
        }
        return $this->dislikes;
    }
878425
public function get_comments( $count = null, $order = 'wp', $type = 'comment', $status = 'approve', $CommentClass = 'Timber\Comment' ) {
		return $this->comments($count, $order, $type, $status, $CommentClass);
	}
773398
function (filter) {
            if (!filter) {
                filter = null;
            }
            var comments = this.__comments;

            if (filter !== null) {
                comments = comments.filter(function (c) {
                    return c.context === filter;
                });
            }

            return comments;
        }
413567
public function getComments() {
        $comments = false;
        $table    = \MUtil_Html::create()->table(['class' => 'browser table', 'style' => 'width: auto']);

        $targetSurveyAnswers = $this->getNumberOfAnswers($this->targetSurveyId);
        if ($targetSurveyAnswers > 0) {
            $comments = true;
            $table
                    ->tr(['class' => 'warning'])
                    ->td(
                            sprintf(
                                    $this->_('Target survey already has %d answers. Is this expected?'),
                                    $targetSurveyAnswers
                            )
            );
        }

        if ($comments) {
            return $table;
        }

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

        $validation = BaseManager::build('FelixOnline\Core\EmailValidation', 'email_validation')
            ->filter("confirmed = 1");

        $count->join($validation, null, 'email', 'email');
        $num = 0;

        $count = $count->values();

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

        return $num;
    }
68750
function analyseComment(comment, callback) {
  var reg = /(@(require|async|require\.async)\s+)('[^']+'|"[^"]+"|[^\s;!@#%^&*()]+)/g;
  callback = callback || function(m, prefix, type, value) {
    type = type === 'require' ? type : 'async';

    return prefix + map[type].wrap(value);
  };

  return comment.replace(reg, callback).replace(/(?:@|#)\s+sourceMappingURL=([^\s]+)/g, function(_, value) {
    return '# sourceMappingURL=' + map.sourceMap.wrap(value);
  });
}
498486
def get_comments_by_userid(self, userid):
        
        userid = userid
        with get_guest_conn() as conn:
            res = conn.execute("SELECT comments FROM guests "
                               "WHERE userid=?", (userid,))

        result = res.fetchall()
        comments = {}
        if result[0][0]:
            comments = json.loads(result[0][0])
        return comments
1083024
def comment_count(self):
        
        # Get the comment model.
        comment_model = comments.get_model()

        modelbase_content_type = ContentType.objects.get(app_label="panya", model="modelbase")

        # Create a qs filtered for the ModelBase or content_type objects.
        qs = comment_model.objects.filter(
            content_type__in = [self.content_type, modelbase_content_type],
            object_pk    = smart_unicode(self.pk),
            site__pk     = settings.SITE_ID,
        )

        # The is_public and is_removed fields are implementation details of the
        # built-in comment model's spam filtering system, so they might not
        # be present on a custom comment model subclass. If they exist, we
        # should filter on them.
        field_names = [f.name for f in comment_model._meta.fields]
        if 'is_public' in field_names:
            qs = qs.filter(is_public=True)
        if getattr(settings, 'COMMENTS_HIDE_REMOVED', True) and 'is_removed' in field_names:
            qs = qs.filter(is_removed=False)

        # Return ammount of items in qs.
        return qs.count()
558764
public function postVote()
    {
        $vote = new Vote($this->di->get("db"));

        $user = $this->di->get("session")->get("user");

        $parentType = isset($_POST["parentType"]) ? $_POST["parentType"] : "";
        $downVote   = isset($_POST["downVote"])   ? $_POST["downVote"]   : null;
        $parentId   = isset($_POST["parentId"])   ? $_POST["parentId"]   : "";
        $upVote     = isset($_POST["upVote"])     ? $_POST["upVote"]     : null;

        if ($upVote != null) {
            return $vote->like($user, $parentId, $parentType);
        }
        if ($downVote != null) {
            return $vote->dislike($user, $parentId, $parentType);
        }
        return false;
    }
691894
def viewer_has_liked(self) -> Optional[bool]:
        """"""
        if not self._context.is_logged_in:
            return None
        if 'likes' in self._node and 'viewer_has_liked' in self._node['likes']:
            return self._node['likes']['viewer_has_liked']
        return self._field('viewer_has_liked')
928087
function removeComments(obj) {
    const keys = Object.keys(obj);
    const newObj = {};

    for (let i = 0, len = keys.length; i < len; i++) {
      if (!COMMENT_KEY.test(keys[i])) {
        newObj[keys[i]] = obj[keys[i]];
      }
    }

    return newObj;
  }
1175353
def obtain_comments(check = nil)

      if check.blank? && !@content.blank? && @content[0].blank?
        Comment.where(:post_id => @content.id, :comment_approved => 'Y')
      else
        Comment.where(:post_id => check, :comment_approved => 'Y')
      end

    end
975415
function getCommentCount($postId)
    {
        $params = array(1, $this->username, $this->password, $postId);

        return $this->sendRequest('wp.getCommentCount', $params);
    }
1117298
function get_comments($page) {
        global $DB;

        if ($page == 0) {
            $start = 0;
        } else {
            $start = $page * $this->perpage;
        }
        $comments = array();

        $usernamefields = get_all_user_name_fields(true, 'u');
        $sql = "SELECT c.id, c.contextid, c.itemid, c.component, c.commentarea, c.userid, c.content, $usernamefields, c.timecreated
                  FROM {comments} c
                  JOIN {user} u
                       ON u.id=c.userid
              ORDER BY c.timecreated ASC";
        $rs = $DB->get_recordset_sql($sql, null, $start, $this->perpage);
        $formatoptions = array('overflowdiv' => true, 'blanktarget' => true);
        foreach ($rs as $item) {
            // Set calculated fields
            $item->fullname = fullname($item);
            $item->time = userdate($item->timecreated);
            $item->content = format_text($item->content, FORMAT_MOODLE, $formatoptions);
            // Unset fields not related to the comment
            foreach (get_all_user_name_fields() as $namefield) {
                unset($item->$namefield);
            }
            unset($item->timecreated);
            // Record the comment
            $comments[] = $item;
        }
        $rs->close();

        return $comments;
    }
1272448
def _get_comments(session, group_or_user_id, wall_id):
        
        return session.fetch_items("wall.getComments", Comment.from_json, count=100, owner_id=group_or_user_id, post_id=wall_id, need_likes=1)
590455
def get_num_commenters(self, item):
        """"""

        commenters = [comment['user']['login'] for comment in item['comments_data']]
        return len(set(commenters))
1034843
public function comments($number = null, array $params = [])
    {
        if (empty($number)) {
            return $this->client->request('GET', $this->getCurrentTeamUrl('comments'), [
                'query' => $params,
            ]);
        }

        return $this->client->request('GET', $this->getCurrentTeamUrl("posts/{$number}/comments"), [
            'query' => $params,
        ]);
    }