<commit_before>import embed from 'particle'
import _ from 'underscore'
import moment from 'moment'
import Article from '../../models/article'
import { crop } from '../../components/resizer'

import { SAILTHRU_KEY, SAILTHRU_SECRET, SAILTHRU_MASTER_LIST } from '../../config.coffee'
const sailThruClient = require('sailthru-client').createSailthruClient(SAILTHRU_KEY,SAILTHRU_SECRET)

export const article = async (req, res, next) => {
  const article = new Article({id: req.params.id})
  await article.fetchWithRelated({
    accessToken: req.user && req.user.get('accessToken')
  })
  res.locals.sd.ARTICLE = article.toJSON()
  res.render('article', { embed, crop, article, lushSignup: true })
}

export const personalize = async (req, res) => {
  if (req.user != null) {
    const response = await req.user.fetch()
    res.locals.sd.CURRENT_USER = _.extend(response, res.locals.sd.CURRENT_USER)
  }
  res.render('personalize')
}

export const setSailthruData = async (req, res) => {
  sailThruClient.apiPost('user', {
    id: req.user.get('email'), 
    lists: {
      [SAILTHRU_MASTER_LIST]: 1
    },
    vars: {
      artsy_primer: true,
      artsy_primer_sign_up_date: moment().format('X')
    }  
  }, (err, response) => {
    if (response.ok) {<commit_msg>Rename field to end in _time<commit_after>import embed from 'particle'
import _ from 'underscore'
import moment from 'moment'
import Article from '../../models/article'
import { crop } from '../../components/resizer'

import { SAILTHRU_KEY, SAILTHRU_SECRET, SAILTHRU_MASTER_LIST } from '../../config.coffee'
const sailThruClient = require('sailthru-client').createSailthruClient(SAILTHRU_KEY,SAILTHRU_SECRET)

export const article = async (req, res, next) => {
  const article = new Article({id: req.params.id})
  await article.fetchWithRelated({
    accessToken: req.user && req.user.get('accessToken')
  })
  res.locals.sd.ARTICLE = article.toJSON()
  res.render('article', { embed, crop, article, lushSignup: true })
}

export const personalize = async (req, res) => {
  if (req.user != null) {
    const response = await req.user.fetch()
    res.locals.sd.CURRENT_USER = _.extend(response, res.locals.sd.CURRENT_USER)
  }
  res.render('personalize')
}

export const setSailthruData = async (req, res) => {
  sailThruClient.apiPost('user', {
    id: req.user.get('email'), 
    lists: {
      [SAILTHRU_MASTER_LIST]: 1
    },
    vars: {
      artsy_primer: true,
      artsy_primer_sign_up_time: moment().format('X')
    }  
  }, (err, response) => {
    if (response.ok) {
{'fraction_non_alphanumeric': 0.15124064592359196, 'fraction_numerical': 0.0007877116975187081, 'mean_word_length': 3.8659003831417627, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '4650853', 'n_tokens_mistral': 902, 'n_tokens_neox': 885, 'n_words': 187}