More bugfixes
This commit is contained in:
@@ -25,8 +25,10 @@ const StandardsController = new Elysia({ prefix: "/standards" })
|
||||
params: t.Object({ id: BigIntIdSchema })
|
||||
})
|
||||
.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();
|
||||
if (activeConfig.id === id) throw new ConflictError("Cannot edit the active standards config");
|
||||
|
||||
const updated = await s.Standards.Configs.update(id, name, datasetId, parameters);
|
||||
if (!updated) throw new NotFoundError("Standards config not found");
|
||||
}, {
|
||||
|
||||
@@ -56,6 +56,9 @@ export const app = new Elysia()
|
||||
switch (code) {
|
||||
case "HttpError":
|
||||
break;
|
||||
case "CalculatorUnavailableError":
|
||||
log.error({ err: error.cause }, error.message);
|
||||
break;
|
||||
case "PrintfulError":
|
||||
case "WebflowError":
|
||||
log.error({ upstreamStatus: error.upstreamStatus, payload: error.payload }, error.message);
|
||||
|
||||
@@ -65,7 +65,7 @@ class ApparelOrdersService {
|
||||
shippingAddress: t.Object({
|
||||
addressee: t.String(),
|
||||
line1: t.String(),
|
||||
line2: t.String(),
|
||||
line2: t.Optional(t.Union([t.String(), t.Null()])),
|
||||
city: t.String(),
|
||||
country: t.String(),
|
||||
postalCode: t.String(),
|
||||
@@ -82,6 +82,12 @@ class ApparelOrdersService {
|
||||
processor: async (payload) => {
|
||||
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(
|
||||
wOrder.shippingAddress.postalCode.split("-")[0] ?? "",
|
||||
).stateCode;
|
||||
@@ -95,7 +101,7 @@ class ApparelOrdersService {
|
||||
recipient: {
|
||||
name: wOrder.shippingAddress.addressee,
|
||||
address1: wOrder.shippingAddress.line1,
|
||||
address2: wOrder.shippingAddress.line2,
|
||||
address2: wOrder.shippingAddress.line2 ?? "",
|
||||
city: wOrder.shippingAddress.city,
|
||||
state_code: stateCode,
|
||||
country_code: wOrder.shippingAddress.country,
|
||||
|
||||
@@ -120,7 +120,7 @@ export class EventsService {
|
||||
|
||||
async resolve(id: string, trx?: Transaction<DB>): Promise<void> {
|
||||
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)
|
||||
.execute();
|
||||
}
|
||||
@@ -132,6 +132,8 @@ export class EventsService {
|
||||
started_at: null,
|
||||
ended_at: null,
|
||||
has_failed: false,
|
||||
errors: 0,
|
||||
rate_limits: 0,
|
||||
available_at: new Date(),
|
||||
})
|
||||
.where("id", "=", id)
|
||||
|
||||
Reference in New Issue
Block a user