<commit_before>import * as functions from 'firebase-functions';
import * as admin from 'firebase-admin'
import * as algoliasearch from 'algoliasearch'

admin.initializeApp();
const env = functions.config();

const client = algoliasearch(env.algolia.appid, env.algolia.apikey);
const index = client.initIndex("user_search");

exports.indexUser = functions.firestore.document('users/{userId}').onCreate((snap, context) => {
    const user = snap.data();
    user.objectID = context.params.userId;
    return index.saveObject(user);
});

exports.updateUser = functions.firestore.document('users/{userId}').onUpdate((snap, context) => {
    const user = snap.after.data();<commit_msg>fix error in firebase functions<commit_after>import * as functions from 'firebase-functions';
import * as admin from 'firebase-admin'
import algoliasearch from 'algoliasearch'

admin.initializeApp();
const env = functions.config();

const client = algoliasearch(env.algolia.appid, env.algolia.apikey);
const index = client.initIndex("user_search");

exports.indexUser = functions.firestore.document('users/{userId}').onCreate((snap, context) => {
    const user = snap.data();
    user.objectID = context.params.userId;
    return index.saveObject(user);
});

exports.updateUser = functions.firestore.document('users/{userId}').onUpdate((snap, context) => {
    const user = snap.after.data();
{'fraction_non_alphanumeric': 0.14639475600874, 'fraction_numerical': 0.0, 'mean_word_length': 5.574162679425838, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '2956795', 'n_tokens_mistral': 406, 'n_tokens_neox': 411, 'n_words': 86}