@@ -24,6 +24,7 @@ function journalEntryAfterLaunchWhere() {
2424}
2525
2626export const BRICKS_PER_APPROVED_HOUR = 20 ;
27+ export const MIN_SHIP_LOGGED_HOURS = 1 ;
2728
2829export 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+
13921397async 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