-
-
Notifications
You must be signed in to change notification settings - Fork 158
Expand file tree
/
Copy pathgenerateBill.ts
More file actions
55 lines (50 loc) · 1.38 KB
/
generateBill.ts
File metadata and controls
55 lines (50 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// import { Timestamp } from "firebase/firestore"
import { Timestamp } from "../../functions/src/firebase"
import { Record, String, Number } from "runtypes"
import { Script } from "./types"
import { Bill, BillContent } from "../../functions/src/bills/types"
const Args = Record({
court: Number,
bills: String
})
export const script: Script = async ({ db, args }) => {
const a = Args.check(args)
const bills = a.bills.split(" ")
const court = a.court
let batch = db.batch()
let opsCounter = 0
for (const id of bills) {
const newBillContent: BillContent = {
Pinslip: "",
Title: "",
PrimarySponsor: null,
DocumentText: "",
Cosponsors: [],
BillNumber: "",
DocketNumber: "",
GeneralCourtNumber: 0,
LegislationTypeName: ""
}
const newBill: Bill = {
id: id,
court: court,
content: newBillContent,
cosponsorCount: 0,
testimonyCount: 0,
endorseCount: 0,
opposeCount: 0,
neutralCount: 0,
fetchedAt: Timestamp.now(),
history: [],
similar: [],
topics: [],
summary: "This is the summary"
}
console.log(`/generalCourts/${court}/bills/${id}`)
const billRef = db.collection(`/generalCourts/${court}/bills`).doc(`${id}`)
batch.set(billRef, newBill)
opsCounter++
}
await batch.commit()
console.log(`Batch of ${opsCounter} bills added.`)
}