More bugfixes

This commit is contained in:
Dominic Ferrando
2026-10-04 01:30:46 -04:00
parent daaf779562
commit 6e9ce94d46
4 changed files with 16 additions and 3 deletions
+2
View File
@@ -25,8 +25,10 @@ const StandardsController = new Elysia({ prefix: "/standards" })
params: t.Object({ id: BigIntIdSchema }) params: t.Object({ id: BigIntIdSchema })
}) })
.put("/", async ({ params: { id }, body: { name, datasetId, params: parameters } }) => { .put("/", async ({ params: { id }, body: { name, datasetId, params: parameters } }) => {
// Active config is not allowed to be edited
const activeConfig = await s.Calculator.Standards.Config.get(); const activeConfig = await s.Calculator.Standards.Config.get();
if (activeConfig.id === id) throw new ConflictError("Cannot edit the active standards config"); if (activeConfig.id === id) throw new ConflictError("Cannot edit the active standards config");
const updated = await s.Standards.Configs.update(id, name, datasetId, parameters); const updated = await s.Standards.Configs.update(id, name, datasetId, parameters);
if (!updated) throw new NotFoundError("Standards config not found"); if (!updated) throw new NotFoundError("Standards config not found");
}, { }, {
+3
View File
@@ -56,6 +56,9 @@ export const app = new Elysia()
switch (code) { switch (code) {
case "HttpError": case "HttpError":
break; break;
case "CalculatorUnavailableError":
log.error({ err: error.cause }, error.message);
break;
case "PrintfulError": case "PrintfulError":
case "WebflowError": case "WebflowError":
log.error({ upstreamStatus: error.upstreamStatus, payload: error.payload }, error.message); log.error({ upstreamStatus: error.upstreamStatus, payload: error.payload }, error.message);
+8 -2
View File
@@ -65,7 +65,7 @@ class ApparelOrdersService {
shippingAddress: t.Object({ shippingAddress: t.Object({
addressee: t.String(), addressee: t.String(),
line1: t.String(), line1: t.String(),
line2: t.String(), line2: t.Optional(t.Union([t.String(), t.Null()])),
city: t.String(), city: t.String(),
country: t.String(), country: t.String(),
postalCode: t.String(), postalCode: t.String(),
@@ -82,6 +82,12 @@ class ApparelOrdersService {
processor: async (payload) => { processor: async (payload) => {
const wOrder = payload.wOrder; const wOrder = payload.wOrder;
// a previous attempt may have created the order before failing
if (await this.Printful.Orders.get(`@${wOrder.orderId}`)) {
log.info({ wOrderId: wOrder.orderId }, "printful order already exists, skipping creation");
return;
}
const stateCode = zipcodesUs.find( const stateCode = zipcodesUs.find(
wOrder.shippingAddress.postalCode.split("-")[0] ?? "", wOrder.shippingAddress.postalCode.split("-")[0] ?? "",
).stateCode; ).stateCode;
@@ -95,7 +101,7 @@ class ApparelOrdersService {
recipient: { recipient: {
name: wOrder.shippingAddress.addressee, name: wOrder.shippingAddress.addressee,
address1: wOrder.shippingAddress.line1, address1: wOrder.shippingAddress.line1,
address2: wOrder.shippingAddress.line2, address2: wOrder.shippingAddress.line2 ?? "",
city: wOrder.shippingAddress.city, city: wOrder.shippingAddress.city,
state_code: stateCode, state_code: stateCode,
country_code: wOrder.shippingAddress.country, country_code: wOrder.shippingAddress.country,
+3 -1
View File
@@ -120,7 +120,7 @@ export class EventsService {
async resolve(id: string, trx?: Transaction<DB>): Promise<void> { async resolve(id: string, trx?: Transaction<DB>): Promise<void> {
await (trx ?? db).updateTable("events") await (trx ?? db).updateTable("events")
.set({ state: null, ended_at: new Date(), last_error: null }) .set({ state: null, ended_at: new Date(), has_failed: false, last_error: null })
.where("id", "=", id) .where("id", "=", id)
.execute(); .execute();
} }
@@ -132,6 +132,8 @@ export class EventsService {
started_at: null, started_at: null,
ended_at: null, ended_at: null,
has_failed: false, has_failed: false,
errors: 0,
rate_limits: 0,
available_at: new Date(), available_at: new Date(),
}) })
.where("id", "=", id) .where("id", "=", id)