More service naming consistency cleanup
This commit is contained in:
@@ -73,10 +73,10 @@ const metricPriority = (m: NumberMetric) => {
|
||||
export const DEFAULT_STANDARDS_DATASET = defaultStandardsDataset as StandardsDataset;
|
||||
|
||||
export class LevelCalculator {
|
||||
standards: Standards;
|
||||
Standards: Standards;
|
||||
|
||||
public constructor(standards: Standards) {
|
||||
this.standards = standards;
|
||||
this.Standards = standards;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
@@ -138,7 +138,7 @@ export class LevelCalculator {
|
||||
(Object.values(Attribute) as Attribute[]).forEach((attribute) => {
|
||||
const attrActivityPerformances = activityPerformances.filter(
|
||||
(p) =>
|
||||
this.standards.byActivity(p.activity).getMetadata()
|
||||
this.Standards.byActivity(p.activity).getMetadata()
|
||||
.attribute === attribute,
|
||||
);
|
||||
attrLevels[attribute] = this.calculateAttributeLevel(
|
||||
@@ -160,7 +160,7 @@ export class LevelCalculator {
|
||||
if (
|
||||
activityPerformances.some(
|
||||
(p) =>
|
||||
this.standards.byActivity(p.activity).getMetadata()
|
||||
this.Standards.byActivity(p.activity).getMetadata()
|
||||
.attribute !== attribute,
|
||||
)
|
||||
) {
|
||||
@@ -168,7 +168,7 @@ export class LevelCalculator {
|
||||
}
|
||||
|
||||
// must perform all of an attributes activities
|
||||
for (const activity of this.standards.getAttributeActivities(
|
||||
for (const activity of this.Standards.getAttributeActivities(
|
||||
attribute,
|
||||
)) {
|
||||
const filteredActivites = activityPerformances.map(
|
||||
@@ -183,7 +183,7 @@ export class LevelCalculator {
|
||||
}
|
||||
|
||||
const activityLevels = activityPerformances.map((p) => {
|
||||
const interpolatedStandard = this.standards
|
||||
const interpolatedStandard = this.Standards
|
||||
.byActivity(p.activity)
|
||||
.byMetrics(player.metrics)
|
||||
.getOneInterpolated();
|
||||
|
||||
@@ -30,14 +30,14 @@ export class ProductSyncer {
|
||||
private log: pino.Logger;
|
||||
|
||||
constructor(
|
||||
private printful: PrintfulClient,
|
||||
private webflow: WebflowClient,
|
||||
private Printful: PrintfulClient,
|
||||
private Webflow: WebflowClient,
|
||||
log?: pino.Logger,
|
||||
) {
|
||||
this.log = (log ?? pino({ level: "silent" })).child({ component: "ProductSyncer" });
|
||||
}
|
||||
|
||||
async sync(opt: ProductSyncerOptions = {}) {
|
||||
async run(opt: ProductSyncerOptions = {}) {
|
||||
const startDate = new Date();
|
||||
await opt.onStart?.(startDate);
|
||||
|
||||
@@ -47,10 +47,10 @@ export class ProductSyncer {
|
||||
this.log.info("sync started (all)");
|
||||
|
||||
this.log.debug("retrieving webflow products");
|
||||
const allWebflowProducts = await this.webflow.Products.list({ forceAll: true });
|
||||
const allWebflowProducts = await this.Webflow.Products.list({ forceAll: true });
|
||||
|
||||
this.log.debug("retrieving printful products");
|
||||
const allPrintfulProducts = await this.printful.Products.list({ forceAll: true });
|
||||
const allPrintfulProducts = await this.Printful.Products.list({ forceAll: true });
|
||||
|
||||
this.log.info({ printfulProductCount: allPrintfulProducts.length, filter: opt.filter ?? "N/A" }, "generating meta printful products");
|
||||
const metaPrintfulProducts = await this.generateMetaPrintfulProducts(allWebflowProducts, allPrintfulProducts, opt);
|
||||
@@ -120,7 +120,7 @@ export class ProductSyncer {
|
||||
this.log.warn({ webflowSku: newWebflowSkus[0] }, "could not find existing webflow SKU that matches");
|
||||
}
|
||||
|
||||
await this.webflow.Products.update(webflowProduct.product.id, {
|
||||
await this.Webflow.Products.update(webflowProduct.product.id, {
|
||||
product: { fieldData: webflowProductFieldData },
|
||||
sku: newWebflowSkus[0],
|
||||
});
|
||||
@@ -133,13 +133,13 @@ export class ProductSyncer {
|
||||
newWebflowSku.id,
|
||||
);
|
||||
if (existingWebflowSku) {
|
||||
await this.webflow.Products.Skus.update(
|
||||
await this.Webflow.Products.Skus.update(
|
||||
metaPrintfulProduct.webflowProductId,
|
||||
existingWebflowSku.id,
|
||||
newWebflowSku,
|
||||
);
|
||||
} else {
|
||||
await this.webflow.Products.Skus.create(
|
||||
await this.Webflow.Products.Skus.create(
|
||||
metaPrintfulProduct.webflowProductId,
|
||||
[newWebflowSku],
|
||||
);
|
||||
@@ -148,18 +148,18 @@ export class ProductSyncer {
|
||||
} else {
|
||||
this.log.info("existing webflow product not found, creating it");
|
||||
|
||||
const webflowProductId = await this.webflow.Products.create({
|
||||
const webflowProductId = await this.Webflow.Products.create({
|
||||
product: { fieldData: webflowProductFieldData },
|
||||
sku: newWebflowSkus[0],
|
||||
});
|
||||
metaPrintfulProduct.webflowProductId = webflowProductId;
|
||||
|
||||
if (newWebflowSkus.length > 1)
|
||||
await this.webflow.Products.Skus.create(webflowProductId, newWebflowSkus.slice(1));
|
||||
await this.Webflow.Products.Skus.create(webflowProductId, newWebflowSkus.slice(1));
|
||||
}
|
||||
|
||||
// Re-fetch after SKU mutations so newly created SKUs have their real IDs.
|
||||
const freshWebflowProduct = await this.webflow.Products.get(metaPrintfulProduct.webflowProductId);
|
||||
const freshWebflowProduct = await this.Webflow.Products.get(metaPrintfulProduct.webflowProductId);
|
||||
if (!freshWebflowProduct) throw new Error("webflow product missing");
|
||||
|
||||
// Update printful external IDs
|
||||
@@ -186,7 +186,7 @@ export class ProductSyncer {
|
||||
|
||||
await sleep(10000);
|
||||
this.log.info({ printfulProduct: printfulProduct.sync_product.id, externalId: expectedExternalId }, "updating printful product's external ID");
|
||||
await this.printful.Products.update(printfulProduct.sync_product.id, {
|
||||
await this.Printful.Products.update(printfulProduct.sync_product.id, {
|
||||
sync_product: {
|
||||
id: printfulProduct.sync_product.id,
|
||||
external_id: expectedExternalId,
|
||||
@@ -286,7 +286,7 @@ export class ProductSyncer {
|
||||
metaPrintfulProduct.webflowProductId = webflowProductId;
|
||||
}
|
||||
|
||||
const fullPrintfulProduct = await this.printful.Products.get(printfulProduct.id);
|
||||
const fullPrintfulProduct = await this.Printful.Products.get(printfulProduct.id);
|
||||
if (!fullPrintfulProduct) throw new Error(`Printful product ${printfulProduct.id} not found`);
|
||||
|
||||
const isDuplicate = allPrintfulProducts.some((p) => p.id !== printfulProduct.id && p.name === printfulProduct.name);
|
||||
|
||||
Reference in New Issue
Block a user