Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import * as admin from "firebase-admin";
admin.initializeApp({
credential: admin.credential.cert('./prod-account.json'),
databaseURL: 'https://this-is-in-firebase-console.firebaseio.com'
});
const sequence = async (items, action) => {
for(let i = 0; i < items.length; i++) {
await action(items[i], i);
}
}
const thottleWait = async () => await new Promise(async (r) => setTimeout(r, Math.ceil((60 * 60 * 1000) / 200)));
new Promise(async (resolve, reject) => {
try {
const hashTag = "india";
const tagDocRef = await admin.firestore().collection('hashTags').add({tag: hashTag, removeRetweets: true});
const apiResults = [{
allFieldsInCsv: 'allFieldsInCsv'
}];
await sequence(apiResults, async (tweet, i) => {
await tagDocRef.collection("tweets").add(tweet);
await thottleWait();
});
} catch (err) {
console.error('err: ', err);
}
resolve('done');
console.log('done');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.