<commit_before><?php
/**
 * Class Comment
 * @Author Lich
 * 评论model
 * TODO:获取评论应该有更好的方法
 */
class Comment extends Eloquent {

	
	protected $table = 'comment';
	protected $fillable = array('work_id', 'type_id', 'content', 'from', 'to', 'praise', 'father_id', 'love_num','read_status', 'created_at', 'updated_at', 'status');
    private   $rules;

    //获取用户名
    public function user(){
        return $this->hasOne('User', 'id', 'from');
    }

	//获取评论 TODO:users表中id为该应用的uid, users表里的uid为学号
	public static function findComment($type_id, $work_id, $page){
		$skip = 2*($page-1);
		$data['cz'] = Comment::where('comment.type_id', '=', $type_id)
				->where('comment.work_id', '=', $work_id)
                ->where('comment.father_id', '=', 0)
				->where('comment.status', '=', '1')
				->join('users', 'comment.from', '=', 'users.id')
				->skip($skip)
				->limit(10)
				->select('username', 'content', 'users.id as uid', 'head as head_pic', 'comment.created_at as time', 'love_num as praise', 'comment.id')
				->get();
		foreach($data['cz'] as $v){
			$data['lzl'][] = Comment::where('father_id','=', $v['id'])
				->join('users as from_user', 'comment.from', '=', 'from_user.id')
				->join('users as to_user', 'comment.to', '=', 'to_user.id')
				->where('comment.status', '=', '1')<commit_msg>offset<commit_after><?php
/**
 * Class Comment
 * @Author Lich
 * 评论model
 * TODO:获取评论应该有更好的方法
 */
class Comment extends Eloquent {

	
	protected $table = 'comment';
	protected $fillable = array('work_id', 'type_id', 'content', 'from', 'to', 'praise', 'father_id', 'love_num','read_status', 'created_at', 'updated_at', 'status');
    private   $rules;

    //获取用户名
    public function user(){
        return $this->hasOne('User', 'id', 'from');
    }

	//获取评论 TODO:users表中id为该应用的uid, users表里的uid为学号
	public static function findComment($type_id, $work_id, $page){
		$skip = 10 *($page-1);
		$data['cz'] = Comment::where('comment.type_id', '=', $type_id)
				->where('comment.work_id', '=', $work_id)
                ->where('comment.father_id', '=', 0)
				->where('comment.status', '=', '1')
				->join('users', 'comment.from', '=', 'users.id')
				->skip($skip)
				->limit(10)
				->select('username', 'content', 'users.id as uid', 'head as head_pic', 'comment.created_at as time', 'love_num as praise', 'comment.id')
				->get();
		foreach($data['cz'] as $v){
			$data['lzl'][] = Comment::where('father_id','=', $v['id'])
				->join('users as from_user', 'comment.from', '=', 'from_user.id')
				->join('users as to_user', 'comment.to', '=', 'to_user.id')
				->where('comment.status', '=', '1')
{'fraction_non_alphanumeric': 0.23375624759707805, 'fraction_numerical': 0.0057670126874279125, 'mean_word_length': 4.101960784313725, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1421287', 'n_tokens_mistral': 1058, 'n_tokens_neox': 996, 'n_words': 192}