@go-avro/avro-js 1.6.6-rc14 → 1.6.6-rc16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -61,7 +61,13 @@ export class Job {
61
61
  if (contextTasks.length === 0) {
62
62
  return 0;
63
63
  }
64
- return contextTasks.filter((t) => t.isDone?.(route)).length / contextTasks.length;
64
+ // Progress counts only what this visit should do: tasks not due until
65
+ // after the route's next visit (or inactive) are left out entirely.
66
+ const due = contextTasks.filter((t) => t.isDueOn?.(route) ?? true);
67
+ if (due.length === 0) {
68
+ return 1;
69
+ }
70
+ return due.filter((t) => t.isDone?.(route)).length / due.length;
65
71
  };
66
72
  this.isDone = (route) => {
67
73
  return this.portionDone(route) === 1;
@@ -123,5 +123,13 @@ export declare class Task {
123
123
  getPrepaidEventsRemaining: () => number;
124
124
  getPrepaidMonthsRemaining: () => number;
125
125
  isDone: (route: Route) => boolean;
126
+ /**
127
+ * Whether this visit of `route` should do the task: it's active and
128
+ * either done on the route's day or due before the route's next visit.
129
+ * A task repeating less often than its route (biweekly edging on a
130
+ * weekly route) is not due on its off-weeks, so a stop's progress
131
+ * leaves it out instead of showing the stop as partly done.
132
+ */
133
+ isDueOn: (route: Route) => boolean;
126
134
  }
127
135
  export {};
@@ -66,6 +66,12 @@ export const getTaskOverdueness = (task, now = Date.now() / 1000) => {
66
66
  }
67
67
  return overdueTime / (86400 * (task.priority ? 1 : 7));
68
68
  };
69
+ /** Local midnight starting the day of the route's current occurrence. */
70
+ function routeDayStart(route) {
71
+ const day = new Date((route.start_time ?? 0) * 1000);
72
+ day.setHours(0, 0, 0, 0);
73
+ return day;
74
+ }
69
75
  export class Task {
70
76
  constructor(init) {
71
77
  this.getStatusLabel = () => {
@@ -182,25 +188,31 @@ export class Task {
182
188
  // an early-started visit that finishes a few minutes before
183
189
  // route.start_time) while still rejecting stale events from previous
184
190
  // occurrences. Applies to both recurring and one-shot tasks.
185
- const routeDay = new Date((route.start_time ?? 0) * 1000);
186
- routeDay.setHours(0, 0, 0, 0);
187
- const cutoff = Math.floor(routeDay.getTime() / 1000);
188
- if ((this.last_completed_event?.time_ended ?? 0) >= cutoff)
191
+ const cutoff = Math.floor(routeDayStart(route).getTime() / 1000);
192
+ return (this.last_completed_event?.time_ended ?? 0) >= cutoff;
193
+ };
194
+ /**
195
+ * Whether this visit of `route` should do the task: it's active and
196
+ * either done on the route's day or due before the route's next visit.
197
+ * A task repeating less often than its route (biweekly edging on a
198
+ * weekly route) is not due on its off-weeks, so a stop's progress
199
+ * leaves it out instead of showing the stop as partly done.
200
+ */
201
+ this.isDueOn = (route) => {
202
+ if (this.status !== TaskStatus.ACTIVE)
203
+ return false;
204
+ if (this.isDone(route))
189
205
  return true;
190
- // Not due this visit: a task repeating less often than its route
191
- // (biweekly edging on a weekly route) that won't come due before the
192
- // route's next visit needs nothing today. Without this, every
193
- // off-week visit showed as half done however complete it was.
194
206
  const nextDue = this.getNextDue();
195
207
  if (nextDue == null)
196
- return false;
197
- const routeDayEnd = new Date(routeDay);
208
+ return true;
209
+ const routeDayEnd = routeDayStart(route);
198
210
  routeDayEnd.setDate(routeDayEnd.getDate() + 1);
199
211
  const nextVisit = route.getNextOccurrence(routeDayEnd);
200
212
  // One-off routes have no next visit: then only the route's day counts.
201
213
  const horizon = nextVisit ? new Date(nextVisit) : routeDayEnd;
202
214
  horizon.setHours(0, 0, 0, 0);
203
- return nextDue >= Math.floor(horizon.getTime() / 1000);
215
+ return nextDue < Math.floor(horizon.getTime() / 1000);
204
216
  };
205
217
  assignData(this, init);
206
218
  // Payloads from the server carry no timestamp: they were computed
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const AVRO_JS_VERSION = "1.6.6-rc14";
1
+ export declare const AVRO_JS_VERSION = "1.6.6-rc16";
package/dist/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  // AUTO-GENERATED by scripts/gen-version.js — do not edit by hand.
2
2
  // Regenerated from package.json by the `prebuild` npm hook.
3
- export const AVRO_JS_VERSION = '1.6.6-rc14';
3
+ export const AVRO_JS_VERSION = '1.6.6-rc16';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@go-avro/avro-js",
3
- "version": "1.6.6-rc14",
3
+ "version": "1.6.6-rc16",
4
4
  "description": "JS client for Avro backend integration.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",