<commit_before>import config from 'config';
import Users from '../../app/models/users';
import Resumes from '../../app/models/resumes';
import ShareAnalyse from '../../app/models/share-analyse';

import { getRedis } from '../../app/middlewares/cache_helper';

const redisUrl = config.get('redis');

const init = async () => {
  try {
    const cache = getRedis({
      url: redisUrl
    });
    const users = await Users.findAll();
    const resumes = await Resumes.findAll();
    const allAnalyse = await ShareAnalyse.findAll();

    console.log(`users: ${users.length}`);
    console.log(`resumes: ${resumes.length}`);

    await cache.incrby('users', users.length);
    await cache.hincrby('github', 'count', users.length);
    await cache.hincrby('resume', 'count', resumes.length);

    let githubPageview = 0;
    let resumePageview = 0;

    allAnalyse.forEach((analyse) => {
      const { login, pageViews } = analyse;
      const viewCount = pageViews.reduce((prev, current, index) => {
        if (index === 0) {
          return current.count;
        }
        return current.count + prev;
      }, '');<commit_msg>WHAT: Bugfixed for statistic initial script<commit_after>import config from 'config';
import Users from '../../app/models/users';
import Resumes from '../../app/models/resumes';
import ShareAnalyse from '../../app/models/share-analyse';

import { getRedis } from '../../app/middlewares/cache_helper';

const redisUrl = config.get('redis');

const init = async () => {
  try {
    const cache = getRedis({
      url: redisUrl
    });
    const users = await Users.findAll();
    const resumes = await Resumes.findAll();
    const allAnalyse = await ShareAnalyse.findAll();

    console.log(`users: ${users.length}`);
    console.log(`resumes: ${resumes.length}`);

    await cache.incrby('users', users.length);
    await cache.hincrby('github', 'count', users.length);
    await cache.hincrby('resume', 'count', resumes.length);

    let githubPageview = 0;
    let resumePageview = 0;

    allAnalyse.forEach((analyse) => {
      const { login, pageViews } = analyse;
      const viewCount = pageViews.reduce((prev, current, index) => {
        let count = parseInt(current.count, 10);
        if (isNaN(count)) count = 0;
        if (index === 0) {
          return count;
        }
        return count + prev;
      }, 0);
{'fraction_non_alphanumeric': 0.16107097322566935, 'fraction_numerical': 0.004249893752656183, 'mean_word_length': 2.96964586846543, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '3060891', 'n_tokens_mistral': 730, 'n_tokens_neox': 726, 'n_words': 180}