1
1
import { Firestore } from '@google-cloud/firestore'
2
2
import { 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
- }
13
3
14
4
export class FirestoreBatch {
15
5
constructor ( ) {
@@ -26,8 +16,7 @@ export class FirestoreBatch {
26
16
if ( operation === 'delete' ) {
27
17
batch . delete ( doc . ref )
28
18
} 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 ( )
31
20
batch . set ( docRef , doc )
32
21
} else {
33
22
throw new Error ( 'Invalid operation' )
@@ -144,10 +133,7 @@ export class FirestoreBatch {
144
133
databaseId : 'tech-report-apis-' + exportConfig . environment
145
134
} )
146
135
147
- // Delete all the documents before writing the new ones
148
- if ( exportConfig . truncate !== 'false' ) {
149
- await this . batchDelete ( )
150
- }
136
+ await this . batchDelete ( )
151
137
152
138
const rowStream = await this . bigquery . queryResultsStream ( query )
153
139
await this . streamFromBigQuery ( rowStream )
0 commit comments