Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

permissions:
contents: read

concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
check:
runs-on: ubuntu-latest
timeout-minutes: 15

steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: 20

- name: Install pnpm
run: npm install --global pnpm@9.15.9

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Build and smoke test
run: pnpm check
9 changes: 5 additions & 4 deletions src/core/orders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,17 +123,18 @@ export async function estimatedPickupWaitMinutes(merchantId: string, item: Catal
const activeAhead = (await activePickupOrders(merchantId, productionClass)).length;
const capacity = CAPACITY_BY_PRODUCTION_CLASS[productionClass];
const prepMinutes = Math.max(item.prepMinutes || 5, 1);
const baseWait = prepMinutes + Math.floor(activeAhead / capacity) * CAPACITY_WINDOW_MINUTES;
const queueWait = prepMinutes + Math.floor(activeAhead / capacity) * CAPACITY_WINDOW_MINUTES;
const now = new Date();
const desiredReadyAt = addMinutes(now, baseWait);
const desiredReadyAt = addMinutes(now, prepMinutes);
for (let offset = 0; offset < 32; offset += 1) {
const probeAt = addMinutes(desiredReadyAt, offset * CAPACITY_WINDOW_MINUTES);
const window = await capacityWindowAt(merchantId, productionClass, probeAt);
if (window.available >= quantity) {
return baseWait + offset * CAPACITY_WINDOW_MINUTES;
const capacityWait = prepMinutes + offset * CAPACITY_WINDOW_MINUTES;
return Math.max(queueWait, capacityWait);
}
}
return baseWait + 32 * CAPACITY_WINDOW_MINUTES;
return Math.max(queueWait, prepMinutes + 32 * CAPACITY_WINDOW_MINUTES);
}

async function pickupPromise(merchant: MerchantProfile, item: CatalogItem, input: OrderRequest, now: Date, quantity: number): Promise<SellerOrder["promise"]> {
Expand Down
Loading