<commit_before>import { ValidatedMethod } from 'meteor/mdg:validated-method';
import { HTTP } from 'meteor/http';
import { Meteor } from 'meteor/meteor';
import { Base64 } from 'meteor/base64';

function basicAuthHeader() {
  const { user, pass } = Meteor.settings.private.cms.auth;
  const authString = `${user}:${pass}`;
  return `Basic ${Base64.encode(authString)}`;
}

export const synchDocWithCms = new ValidatedMethod({
  name: 'hooks.synchDocWithCms',
  validate: null,
  run({ action, file }) {
    if (this.userId && action && file && !this.isSimulation) {
      if (action === 'update') {
        const doc = {
          uid: file.uid,
          title: file.title || null,
          filename: file.filename,
          path: file.path,
          contentFormat: file.contentFormat || null,
          description: file.description || null,
          year: file.year || null,
          eventType: file.eventType || null,
          event: file.event || null,
          source: file.source || null,
          topics: file.topics || null,
        };

        if (file.companiesOrganizations) {
          doc.companiesOrganizations = file.companiesOrganizations.join('; ');
        }<commit_msg>Add extra details needed for homepage feature<commit_after>import { ValidatedMethod } from 'meteor/mdg:validated-method';
import { HTTP } from 'meteor/http';
import { Meteor } from 'meteor/meteor';
import { Base64 } from 'meteor/base64';

function basicAuthHeader() {
  const { user, pass } = Meteor.settings.private.cms.auth;
  const authString = `${user}:${pass}`;
  return `Basic ${Base64.encode(authString)}`;
}

export const synchDocWithCms = new ValidatedMethod({
  name: 'hooks.synchDocWithCms',
  validate: null,
  run({ action, file }) {
    if (this.userId && action && file && !this.isSimulation) {
      if (action === 'update') {
        const doc = {
          uid: file.uid,
          title: file.title || null,
          filename: file.filename,
          path: file.path,
          contentFormat: file.contentFormat || null,
          description: file.description || null,
          year: file.year || null,
          eventType: file.eventType || null,
          event: file.event || null,
          source: file.source || null,
          topics: file.topics || null,
          promoImageUrl: file.promoImageUrl || null,
          featuredSummary: file.featuredSummary || null,
          featuredOrder: file.featuredOrder || 0,
        };

        if (file.companiesOrganizations) {
          doc.companiesOrganizations = file.companiesOrganizations.join('; ');
        }
{'fraction_non_alphanumeric': 0.13418406805877803, 'fraction_numerical': 0.005027068832173241, 'mean_word_length': 2.674715909090909, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3368793', 'n_tokens_mistral': 791, 'n_tokens_neox': 769, 'n_words': 183}