Don't filter for group contract ids

This commit is contained in:
Ian Philips 2022-07-22 16:44:03 -06:00
parent abde013ab6
commit 56a579ff91

View File

@ -14,18 +14,11 @@ const addGroupIdToContracts = async () => {
const groups = await getValues<Group>(adminFirestore.collection('groups')) const groups = await getValues<Group>(adminFirestore.collection('groups'))
for (const group of groups) { for (const group of groups) {
const contracts = await getValues<Contract>( const groupContracts = await getValues<Contract>(
adminFirestore adminFirestore
.collection('contracts') .collection('contracts')
.where('groupSlugs', 'array-contains', group.slug) .where('groupSlugs', 'array-contains', group.slug)
) )
const groupContracts = contracts.filter((contract) =>
group.contractIds.includes(contract.id)
)
if (groupContracts.length !== contracts.length)
console.log(
`Found ${groupContracts.length} contracts for group ${group.slug}`
)
for (const contract of groupContracts) { for (const contract of groupContracts) {
const oldGroupLinks = contract.groupLinks?.filter( const oldGroupLinks = contract.groupLinks?.filter(