Skip to content

Instantly share code, notes, and snippets.

@stopdrake
Created December 14, 2021 18:13
Show Gist options
  • Save stopdrake/2039959c9d10d79e2f964d5cf24479f9 to your computer and use it in GitHub Desktop.
Save stopdrake/2039959c9d10d79e2f964d5cf24479f9 to your computer and use it in GitHub Desktop.
const schemaParams = {
city_key: 'city_key',
category_key: 'category_key',
request_id: 'request_id',
lead_id: 'lead_id',
provider_id: 'provider_id',
customer_id: 'customer_id',
event_type: 'event_type',
event_name: 'event_name',
event_page: 'event_page',
event_section: 'event_section',
event_action: 'event_action',
event_key_1: 'event_key_1',
event_key_2: 'event_key_2',
event_key_3: 'event_key_3',
event_value_1: 'event_value_1',
event_value_2: 'event_value_2',
event_value_3: 'event_value_3',
event_template_position: 'event_template_position',
event_item_position: 'event_item_position',
question_tag: 'question_tag',
answer_tag: 'answer_tag',
category_questions_id: 'category_questions_id',
latence_ms: 'latence_ms',
payload: 'payload',
url: 'url',
section: 'section',
};
const eventParams = {
event_template_position: 1,
event_item_position: 2,
event_value_1: 1234,
event_value_2: "yolo",
}
const t1 = new Date().valueOf();
for(let i=0; i< 5000; i++) {
const event = _.reduce(
Object.keys(schemaParams),
(event, key) => {
_.set(event, schemaParams[key], _.get(eventParams, key));
return event;
},
{}
);
_.omit(
event,
_.filter(Object.keys(event), (key) => {
return event[key] === undefined;
})
);
}
const t2 = new Date().valueOf();
result = t2-t1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment