All files / utils jobLogUtils.js

100% Statements 5/5
100% Branches 1/1
100% Functions 2/2
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30          8x     8x     8x       71x                       212x    
/**
 * How often, in seconds, an open job log asks the backend for the lines that
 * have been added since it last looked. This is the only place the interval
 * is defined.
 */
export const JOB_LOG_POLL_INTERVAL_SECONDS = 3;
 
/** The endpoint that answers one poll: a job's status and its new log lines. */
export const JOB_LOG_TAIL_URL = "/api/jobs/course/logs/tail";
 
// The statuses of a job that is over and will not write any more log lines
const FINISHED_JOB_STATUSES = ["complete", "error", "cancelled", "interrupted"];
 
/** Whether a job with this status is over, so that its log has stopped growing. */
export function isJobFinished(status) {
  return FINISHED_JOB_STATUSES.includes(status);
}
 
/**
 * The path of the page that shows a whole job log, for a job of a course.
 *
 * @param {number|string} courseId the course the job belongs to
 * @param {number|string} jobId the job
 * @param {"instructor"|"staff"} viewPath which view of the course the page is
 *   in: the instructor one, or the staff one, which staff are allowed into
 */
export function jobLogPagePath(courseId, jobId, viewPath = "instructor") {
  return `/${viewPath}/courses/${courseId}/jobs/${jobId}/logs`;
}