@anura-gate/watcher-jira 0.2.2 → 0.2.3
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.
- package/lib/gate-watcher-jira.js +20 -3
- package/package.json +1 -1
package/lib/gate-watcher-jira.js
CHANGED
|
@@ -142,7 +142,7 @@ class GateJiraWatcher extends EventEmitter {
|
|
|
142
142
|
this.emit("ready", this._displayName);
|
|
143
143
|
|
|
144
144
|
// Set initial poll time to now minus 5 minutes (catch recent activity on first run)
|
|
145
|
-
this._lastPollTime = new Date(Date.now() - 5 * 60_000)
|
|
145
|
+
this._lastPollTime = this._formatJqlDate(new Date(Date.now() - 5 * 60_000));
|
|
146
146
|
|
|
147
147
|
// Start Jira polling loop
|
|
148
148
|
this._pollJira();
|
|
@@ -306,10 +306,14 @@ class GateJiraWatcher extends EventEmitter {
|
|
|
306
306
|
});
|
|
307
307
|
|
|
308
308
|
const res = await this._jiraGet(`/rest/api/3/search?${params.toString()}`);
|
|
309
|
-
if (!res.ok
|
|
309
|
+
if (!res.ok) {
|
|
310
|
+
this.emit("jira_error", { path: "search", error: `JQL search failed (${res.status}): ${JSON.stringify(res.data?.errorMessages || res.data)}` });
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
if (!res.data?.issues) return;
|
|
310
314
|
|
|
311
315
|
// Update poll time for next cycle
|
|
312
|
-
this._lastPollTime = new Date()
|
|
316
|
+
this._lastPollTime = this._formatJqlDate(new Date());
|
|
313
317
|
|
|
314
318
|
for (const issue of res.data.issues) {
|
|
315
319
|
// Process changelog entries (status transitions, field changes)
|
|
@@ -769,6 +773,19 @@ class GateJiraWatcher extends EventEmitter {
|
|
|
769
773
|
|
|
770
774
|
// -- Internal: Helpers --------------------------------------------
|
|
771
775
|
|
|
776
|
+
/**
|
|
777
|
+
* Format a Date into JQL-compatible format: "yyyy/MM/dd HH:mm"
|
|
778
|
+
* JQL does NOT accept ISO 8601 — it needs this specific format.
|
|
779
|
+
*/
|
|
780
|
+
_formatJqlDate(date) {
|
|
781
|
+
const y = date.getUTCFullYear();
|
|
782
|
+
const m = String(date.getUTCMonth() + 1).padStart(2, "0");
|
|
783
|
+
const d = String(date.getUTCDate()).padStart(2, "0");
|
|
784
|
+
const h = String(date.getUTCHours()).padStart(2, "0");
|
|
785
|
+
const min = String(date.getUTCMinutes()).padStart(2, "0");
|
|
786
|
+
return `${y}/${m}/${d} ${h}:${min}`;
|
|
787
|
+
}
|
|
788
|
+
|
|
772
789
|
_markSeen(id) {
|
|
773
790
|
this._seenEventIds.add(id);
|
|
774
791
|
if (this._seenEventIds.size > this._maxSeenIds) {
|