Enable parallel job execution.

Add UI element to specify parallel job count and utilize the `parallel` field in `indjob` to divide runtime accordingly.
This commit is contained in:
gpt-engineer-app[bot]
2025-07-12 10:47:51 +00:00
committed by PhatPhuckDave
parent b24b0810f4
commit 51467925f3
3 changed files with 20 additions and 33 deletions

View File

@@ -23,7 +23,8 @@ const JobForm: React.FC<JobFormProps> = ({ job, onSubmit, onCancel }) => {
status: job?.status || IndJobStatusOptions.Planned, status: job?.status || IndJobStatusOptions.Planned,
projectedCost: job?.projectedCost || 0, projectedCost: job?.projectedCost || 0,
projectedRevenue: job?.projectedRevenue || 0, projectedRevenue: job?.projectedRevenue || 0,
runtime: job?.runtime || 0 runtime: job?.runtime || 0,
parallel: job?.parallel || 1
}); });
const [jobDump, setJobDump] = useState(''); const [jobDump, setJobDump] = useState('');
@@ -102,7 +103,8 @@ const JobForm: React.FC<JobFormProps> = ({ job, onSubmit, onCancel }) => {
status: formData.status, status: formData.status,
projectedCost: formData.projectedCost, projectedCost: formData.projectedCost,
projectedRevenue: formData.projectedRevenue, projectedRevenue: formData.projectedRevenue,
runtime: formData.runtime runtime: formData.runtime,
parallel: formData.parallel
}, parsedBillOfMaterials.length > 0 ? parsedBillOfMaterials : undefined); }, parsedBillOfMaterials.length > 0 ? parsedBillOfMaterials : undefined);
}; };
@@ -166,7 +168,7 @@ const JobForm: React.FC<JobFormProps> = ({ job, onSubmit, onCancel }) => {
</Select> </Select>
</div> </div>
<div className="grid grid-cols-3 gap-4"> <div className="grid grid-cols-4 gap-4">
<div className="space-y-2"> <div className="space-y-2">
<Label htmlFor="runtime" className="text-gray-300">Runtime (seconds)</Label> <Label htmlFor="runtime" className="text-gray-300">Runtime (seconds)</Label>
<Input <Input
@@ -180,6 +182,20 @@ const JobForm: React.FC<JobFormProps> = ({ job, onSubmit, onCancel }) => {
className="bg-gray-800 border-gray-600 text-white" className="bg-gray-800 border-gray-600 text-white"
/> />
</div> </div>
<div className="space-y-2">
<Label htmlFor="parallel" className="text-gray-300">Parallel Jobs</Label>
<Input
id="parallel"
type="number"
min="1"
value={formData.parallel}
onChange={(e) => setFormData({
...formData,
parallel: Math.max(1, parseInt(e.target.value) || 1)
})}
className="bg-gray-800 border-gray-600 text-white"
/>
</div>
<div className="space-y-2"> <div className="space-y-2">
<Label htmlFor="projectedCost" className="text-gray-300">Projected Cost</Label> <Label htmlFor="projectedCost" className="text-gray-300">Projected Cost</Label>
<Input <Input

View File

@@ -14,6 +14,7 @@ export type IndJob = {
jobStart?: IsoDateString jobStart?: IsoDateString
outputItem: string outputItem: string
outputQuantity: number outputQuantity: number
parallel?: number
produced?: number produced?: number
saleEnd?: IsoDateString saleEnd?: IsoDateString
saleStart?: IsoDateString saleStart?: IsoDateString

View File

@@ -1,30 +0,0 @@
import type { IndFacilityRecord, IndFacilityResponse } from '../lib/pbtypes';
import { pb } from '../lib/pocketbase';
export type { IndFacilityRecord as Facility } from '../lib/pbtypes';
export async function getFacilities(): Promise<IndFacilityResponse[]> {
const result = await pb.collection('ind_facility').getFullList();
return result as IndFacilityResponse[];
}
export async function getFacility(id: string): Promise<IndFacilityResponse | null> {
try {
return await pb.collection('ind_facility').getOne(id) as IndFacilityResponse;
} catch (e) {
if (e.status === 404) return null;
throw e;
}
}
export async function createFacility(facility: Omit<IndFacilityRecord, 'id' | 'created' | 'updated'>): Promise<IndFacilityResponse> {
return await pb.collection('ind_facility').create(facility) as IndFacilityResponse;
}
export async function updateFacility(id: string, updates: Partial<IndFacilityRecord>): Promise<IndFacilityResponse> {
return await pb.collection('ind_facility').update(id, updates) as IndFacilityResponse;
}
export async function deleteFacility(id: string): Promise<void> {
await pb.collection('ind_facility').delete(id);
}