Project#loadProfile#

Reads per-bucket load and capacity of resources on the solved baseline of a Project. Needs a solved project: after apply, call solve(null) or level first. To get the load of hypothetical dates, use preview with its profile option instead.

Signature#

loadProfile(options: LoadProfileOptions): LoadProfile

Synchronous. Never changes the project.

Parameters#

Name Type Description
options LoadProfileOptions Required. Range, resources, bucket size, task lists and an optional baseline check.

LoadProfileOptions#

What the profile covers, plus an optional expected baseline.

Field Type Default Description
from DateValue required Start of the range, inclusive. The profile holds every bucket whose start lies in [from, to).
to DateValue required End of the range, exclusive. Must be later than from; the range can hold at most 100 000 buckets per resource.
resources Id[] every resource Resources to include, in the order the profile lists them. Each id must name an existing resource.
basis "hour" | "day" derived from config.duration_unit Bucket size. The profile reports the basis it used in basis.
tasks "none" | "overallocated" | "all" "none" Which buckets list their booked task ids in tasks: none, only buckets where load exceeds capacity, or all.
baselineId string none Expected baseline token, taken from the latest result's baselineId. A mismatch throws ProjectError("stale-baseline"). Absent skips the check.
Note

Pass the query fields (from, to, ...) directly in the options object, next to baselineId.

Returns#

A LoadProfile: a fresh object that shares nothing with the project. Bucket start dates are strings, or local Date objects on a project created with dates: "date".

Errors#

Error When
ProjectError "no-baseline" The project is unsolved, including after apply
ProjectError "stale-baseline" options.baselineId doesn't name the current baseline
InputError "validation" to <= from, or more than 100 000 buckets per resource (path "to"); an unknown resource id (path "resources"); a tasks value other than the three listed
InputError "parse" options is missing, lacks from or to, or has an unknown key
Error("Project has been disposed") The project was disposed

Example#

Print the overloaded days of a resource that works on two tasks at once.

import { Project } from "plen-js";

const project = new Project();
const solved = project.solve({
  config: { use_calendars: false },
  tasks: [
    { id: "a", start_date: "2026-01-01", duration: 2 },
    { id: "b", start_date: "2026-01-02", duration: 2 },
  ],
  resources: [{ id: "dev" }],
  assignments: [
    { task: "a", resource: "dev", value: 1 },
    { task: "b", resource: "dev", value: 1 },
  ],
});

const profile = project.loadProfile({
  from: "2026-01-01",
  to: "2026-01-05",
  tasks: "overallocated",
  baselineId: solved.baselineId,
});

for (const resource of profile.resources) {
  for (const bucket of resource.buckets) {
    if (bucket.load > bucket.capacity) {
      console.log(`${resource.resource} at ${bucket.start}: ${bucket.load} of ${bucket.capacity} (${bucket.tasks.join(", ")})`);
    }
  }
}
// dev at 2026-01-02 00:00: 2 of 1 (a, b)