Skip to content

Commit

Permalink
Clean up cloud functions a bit:
Browse files Browse the repository at this point in the history
* Remove 'customersToPluralCategories' migration
* Remove 'customersToPluralCategories' and 'migrateCategoriesToExplicitMinors' from cloud functions emun (as they no longer exist)
  • Loading branch information
ikusteu committed Jul 8, 2023
1 parent f39ca36 commit 484011c
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 58 deletions.
22 changes: 0 additions & 22 deletions packages/client/src/pages/debug/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,28 +128,6 @@ const DebugPage: React.FC = () => {
</DebugPageButton>
</div>

<div className="p-2">
<DebugPageButton
onClick={createFunctionCaller(
functions,
CloudFunction.MigrateCategoriesToExplicitMinors
)}
color={ButtonColor.Primary}
>
Migrate categories to explicit minors
</DebugPageButton>
</div>
<div className="p-2">
<DebugPageButton
onClick={createFunctionCaller(
functions,
CloudFunction.CustomersToPluralCategories
)}
color={ButtonColor.Primary}
>
Migrate categories to array
</DebugPageButton>
</div>
<div className="p-2">
<DebugPageButton
onClick={createFunctionCaller(
Expand Down
34 changes: 0 additions & 34 deletions packages/functions/src/migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,40 +112,6 @@ export const deleteOrphanedBookings = functions
return { success: true };
});

export const customersToPluralCategories = functions
.region(__functionsZone__)
.https.onCall(async ({ organization }, { auth }) => {
if (!(await checkUser(organization, auth))) throwUnauth();

const batch = admin.firestore().batch();

const orgRef = admin
.firestore()
.collection(Collection.Organizations)
.doc(organization);
const customersRef = orgRef.collection(OrgSubCollection.Customers);

const allCustomers = await customersRef.get();

allCustomers.forEach((customer) => {
const data = customer.data();

if (!data.category) return;
const { category, ...noCategoryData } = data;
if (!Array.isArray(category)) {
functions.logger.info(`Converted customer: ${data.id}`);

batch.set(customer.ref, { ...noCategoryData, categories: [category] });
} else {
batch.set(customer.ref, { ...noCategoryData, categories: category });
}
});

await batch.commit();

return { success: true };
});

export const populateDefaultEmailTemplates = functions
.region(__functionsZone__)
.https.onCall(async ({ organization }, { auth }) => {
Expand Down
2 changes: 0 additions & 2 deletions packages/shared/src/ui/enums/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ export enum CloudFunction {

PruneSlotsByDay = "pruneSlotsByDay",
DeleteOrphanedBookings = "deleteOrphanedBookings",
MigrateCategoriesToExplicitMinors = "migrateCategoriesToExplicitMinors",
CustomersToPluralCategories = "customersToPluralCategories",
PopulateDefaultEmailTemplates = "populateDefaultEmailTemplates",
RemoveInvalidCustomerPhones = "removeInvalidCustomerPhones",
}

0 comments on commit 484011c

Please sign in to comment.