Skip to content

Commit 4951df1

Browse files
committed
ADD - min 1h to ship
1 parent 78b7dc3 commit 4951df1

2 files changed

Lines changed: 45 additions & 13 deletions

File tree

client/src/components/ProjectsPage.jsx

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,14 +193,35 @@ function formatReviewRecordMeta(record) {
193193
return `${timestamp} · ${formatHours(hours)} h ship`;
194194
}
195195

196+
const MIN_SHIP_LOGGED_HOURS = 1;
197+
198+
function isReshipEligibleProject(project) {
199+
return (
200+
(project.status === "approved" && project.reviewed) ||
201+
project.status === "reship-rejected"
202+
);
203+
}
204+
205+
function hoursRequiredToShip(project) {
206+
if (isReshipEligibleProject(project)) {
207+
return getUnshippedHours(project);
208+
}
209+
return getLoggedHours(project);
210+
}
211+
196212
function getShipLockReason(project) {
197213
if (project.status === "in-review") return "Project is currently in review.";
198214
const missing = [];
199215
if (!project.playableUrl) missing.push("playable URL missing");
200216
if (!project.codeUrl) missing.push("code URL missing");
201217
if (!project.imageUrl) missing.push("project image missing");
202-
const hours = Number(project.combinedHours ?? project.totalHours ?? project.journalHours ?? 0);
203-
if (hours <= 0) missing.push("hours logged missing");
218+
if (hoursRequiredToShip(project) < MIN_SHIP_LOGGED_HOURS) {
219+
missing.push(
220+
isReshipEligibleProject(project)
221+
? "at least 1 new hour must be logged before re-shipping"
222+
: "at least 1 hour of work must be logged before shipping"
223+
);
224+
}
204225
return missing.length ? `Locked: ${missing.join(", ")}.` : "";
205226
}
206227

server/projects.js

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ function journalEntryAfterLaunchWhere() {
2424
}
2525

2626
export const BRICKS_PER_APPROVED_HOUR = 20;
27+
export const MIN_SHIP_LOGGED_HOURS = 1;
2728

2829
export async function ensureProjectsTable() {
2930
if (!pool) {
@@ -453,15 +454,7 @@ export async function shipProjectForUser(userId, projectId) {
453454
throw new Error(`Cannot ship yet: ${missing.join(", ")}.`);
454455
}
455456

456-
const isReship =
457-
(project.status === "approved" && project.reviewed) ||
458-
project.status === "reship-rejected";
459-
if (isReship) {
460-
const newHours = pendingReviewHours(project);
461-
if (newHours <= 0) {
462-
throw new Error("No new hours to ship. Add more hours before re-shipping.");
463-
}
464-
}
457+
const isReship = isReshipEligibleProject(project);
465458

466459
const result = await pool.query(
467460
`
@@ -1389,6 +1382,18 @@ function pendingReviewHours(row) {
13891382
return Math.max(0, roundedHours(loggedHours(row) - previouslyShippedHours(row)));
13901383
}
13911384

1385+
function isReshipEligibleProject(project) {
1386+
const status = String(project.status || "");
1387+
return (status === "approved" && project.reviewed) || status === "reship-rejected";
1388+
}
1389+
1390+
function hoursRequiredToShip(project) {
1391+
if (isReshipEligibleProject(project)) {
1392+
return pendingReviewHours(project);
1393+
}
1394+
return loggedHours(project);
1395+
}
1396+
13921397
async function getProjectRowForAirtableSync(projectId) {
13931398
if (!pool) return null;
13941399

@@ -1576,8 +1581,14 @@ function getShipMissingRequirements(project) {
15761581
if (!textOrNull(project.playable_url)) missing.push("playable URL missing");
15771582
if (!textOrNull(project.code_url)) missing.push("code URL missing");
15781583
if (!textOrNull(project.image_url)) missing.push("project image missing");
1579-
const combinedHours = loggedHours(project);
1580-
if (combinedHours <= 0) missing.push("hours logged missing");
1584+
const shipHours = hoursRequiredToShip(project);
1585+
if (shipHours < MIN_SHIP_LOGGED_HOURS) {
1586+
missing.push(
1587+
isReshipEligibleProject(project)
1588+
? "at least 1 new hour must be logged before re-shipping"
1589+
: "at least 1 hour of work must be logged before shipping"
1590+
);
1591+
}
15811592
return missing;
15821593
}
15831594

0 commit comments

Comments
 (0)