<commit_before>'use strict';

import Base from './base.js';

var fs = require('fs');
//var path = require('path');

var xwords = require('./xwords');
var wxconst = require('./wxconst');

var ppArray = [];

export default class extends Base {


  /**
   * index action
   * @return {Promise} []
   */
  async detailAction() {
    let id = this.get('id');
    let data = await this.model('article').where({id: id}).find();
    this.assign({'data': data});
    this.display();
  }

  async getbyidAction() {
    let art_id = this.get('art_id');
    let list = await this.model('article').where({id: art_id}).find();
    if (!think.isEmpty(list)) {
        //console.log(list);
    }

    return this.success({
      questList: list
    });
  }

  async getbyuserAction() {
    let openid = this.get('openid');
    let list = await this.model('article').limit(30).select();
    if (!think.isEmpty(list)) {
      //console.log(list);
      for (var i = 0; i < list.length; i++) {
        await this.model('article').setMagazine(list[i]);
        await this.model('article').setLikeList(list[i], openid);
      }
    }
    return this.success({
      newsList: list
    });
  }

  async getuserlikesAction() {
    let openid = this.get('openid');
    var likeList = await this.model('comment').field('artid').where({openid: openid, up: 1}).limit(30).select();
    var aidList = [];
    if (!think.isEmpty(likeList)) {
        for (var i = 0; i < likeList.length; i++) {
            aidList.push(likeList[i].artid);
        }
    }
    let list = await this.model('article').where({'id': ["IN", aidList]}).select();
    if (!think.isEmpty(list)) {
      //console.log(list);
      for (var i = 0; i < list.length; i++) {
        await this.model('article').setMagazine(list[i]);
        await this.model('article').setLikeList(list[i], openid);
      }
    }
    return this.success({
      newsList: list
    });
  }

  async getrandomAction() {
    let count = this.get('count');
    let onlyself = this.get('onlyself');
    let openid = this.get('openid');
    let type = this.get('type');
    if (type == '' || type == undefined) {
      type = wxconst.QUIZ_CATEGORY_SELF;
    }

    let list = await this.model('article').getRandomList(count, type, openid, onlyself);
    return this.success({
      questList: list
    });
  }

}
<commit_msg>getbysource<commit_after>'use strict';

import Base from './base.js';

var fs = require('fs');
//var path = require('path');

var xwords = require('./xwords');
var wxconst = require('./wxconst');

var ppArray = [];

export default class extends Base {


  /**
   * index action
   * @return {Promise} []
   */
  async detailAction() {
    let id = this.get('id');
    let data = await this.model('article').where({id: id}).find();
    this.assign({'data': data});
    this.display();
  }

  async getbyidAction() {
    let art_id = this.get('art_id');
    let list = await this.model('article').where({id: art_id}).find();
    if (!think.isEmpty(list)) {
        //console.log(list);
    }

    return this.success({
      questList: list
    });
  }

  async getbyuserAction() {
    let openid = this.get('openid');
    let list = await this.model('article').limit(30).select();
    if (!think.isEmpty(list)) {
      //console.log(list);
      for (var i = 0; i < list.length; i++) {
        await this.model('article').setMagazine(list[i]);
        await this.model('article').setLikeList(list[i], openid);
      }
    }
    return this.success({
      newsList: list
    });
  }

  async getuserlikesAction() {
    let openid = this.get('openid');
    var likeList = await this.model('comment').field('artid').where({openid: openid, up: 1}).limit(30).select();
    var aidList = [];
    if (!think.isEmpty(likeList)) {
        for (var i = 0; i < likeList.length; i++) {
            aidList.push(likeList[i].artid);
        }
    }
    let list = await this.model('article').where({'id': ["IN", aidList]}).select();
    if (!think.isEmpty(list)) {
      //console.log(list);
      for (var i = 0; i < list.length; i++) {
        await this.model('article').setMagazine(list[i]);
        await this.model('article').setLikeList(list[i], openid);
      }
    }
    return this.success({
      newsList: list
    });
  }

  async getbysourceAction() {
    let openid = this.get('openid');
    let srcname = this.get('sourcename');
    let list = await this.model('article').where({'source_name': srcname}).limit(30).select();
    if (!think.isEmpty(list)) {
      //console.log(list);
      for (var i = 0; i < list.length; i++) {
        await this.model('article').setMagazine(list[i]);
        await this.model('article').setLikeList(list[i], openid);
      }
    }
    return this.success({
      newsList: list
    });
  }

  async getrandomAction() {
    let count = this.get('count');
    let onlyself = this.get('onlyself');
    let openid = this.get('openid');
    let type = this.get('type');
    if (type == '' || type == undefined) {
      type = wxconst.QUIZ_CATEGORY_SELF;
    }

    let list = await this.model('article').getRandomList(count, type, openid, onlyself);
    return this.success({
      questList: list
    });
  }

}

{'fraction_non_alphanumeric': 0.18739155581260844, 'fraction_numerical': 0.003663003663003663, 'mean_word_length': 2.7377521613832854, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 3, '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': '3687082', 'n_tokens_mistral': 1731, 'n_tokens_neox': 1705, 'n_words': 366}