11import { Firestore } from '@google-cloud/firestore'
22import { BigQueryExport } from './bigquery.js'
3- import { technologyHashId } from './utils.js'
4-
5- const TECHNOLOGY_QUERY_ID_KEYS = {
6- adoption : [ 'date' , 'technology' , 'geo' , 'rank' ] ,
7- lighthouse : [ 'date' , 'technology' , 'geo' , 'rank' ] ,
8- core_web_vitals : [ 'date' , 'technology' , 'geo' , 'rank' ] ,
9- page_weight : [ 'date' , 'technology' , 'geo' , 'rank' ] ,
10- technologies : [ 'client' , 'technology' , 'category' ] ,
11- categories : [ 'category' ]
12- }
133
144export class FirestoreBatch {
155 constructor ( ) {
@@ -26,8 +16,7 @@ export class FirestoreBatch {
2616 if ( operation === 'delete' ) {
2717 batch . delete ( doc . ref )
2818 } else if ( operation === 'set' ) {
29- const docId = technologyHashId ( doc , this . collectionName , TECHNOLOGY_QUERY_ID_KEYS )
30- const docRef = this . firestore . collection ( this . collectionName ) . doc ( docId )
19+ const docRef = this . firestore . collection ( this . collectionName ) . doc ( )
3120 batch . set ( docRef , doc )
3221 } else {
3322 throw new Error ( 'Invalid operation' )
@@ -144,10 +133,7 @@ export class FirestoreBatch {
144133 databaseId : 'tech-report-apis-' + exportConfig . environment
145134 } )
146135
147- // Delete all the documents before writing the new ones
148- if ( exportConfig . truncate !== 'false' ) {
149- await this . batchDelete ( )
150- }
136+ await this . batchDelete ( )
151137
152138 const rowStream = await this . bigquery . queryResultsStream ( query )
153139 await this . streamFromBigQuery ( rowStream )
0 commit comments