@justair/justair-library 4.8.48 → 4.9.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@justair/justair-library",
3
- "version": "4.8.48",
3
+ "version": "4.9.0",
4
4
  "description": "JustAir Internal Library",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
package/src/index.js CHANGED
@@ -22,10 +22,6 @@ import {
22
22
  deploymentTypesEnum,
23
23
  } from "./models/monitors.js";
24
24
  import { organizationsSchema, Organizations } from "./models/organizations.js";
25
- import {
26
- referenceMonitorInfoSchema,
27
- ReferenceMonitorInfo,
28
- } from "./models/referenceMonitorInfo.js";
29
25
  import { lightMonitorSchema, LightMonitors } from "./models/lightmonitors.js";
30
26
  import {
31
27
  monitorSuppliersSchema,
@@ -56,6 +52,7 @@ import {
56
52
  dataCompletenessSchema,
57
53
  } from "./models/dataCompleteness.js";
58
54
  import { NetworkMetrics, networkMetricsSchema } from "./models/networkMetrics.js";
55
+ import { RateOfChange, rateOfChangeSchema } from "./models/rateOfChange.js";
59
56
  import Database from "./config/db.js"; // Import the new Database class
60
57
  import CustomLogger from "./config/logger.js";
61
58
 
@@ -95,8 +92,6 @@ export {
95
92
  Monitors,
96
93
  organizationsSchema,
97
94
  Organizations,
98
- referenceMonitorInfoSchema,
99
- ReferenceMonitorInfo,
100
95
  usersSchema,
101
96
  Users,
102
97
  eventsSchema,
@@ -135,6 +130,8 @@ export {
135
130
  DataCompleteness,
136
131
  networkMetricsSchema,
137
132
  NetworkMetrics,
133
+ rateOfChangeSchema,
134
+ RateOfChange,
138
135
  // SampleSites related exports
139
136
  sampleSitesSchema,
140
137
  SampleSites,
@@ -18,6 +18,7 @@ const monitorSuppliersSchema = mongoose.Schema(
18
18
  authenticationStructure: [String],
19
19
  defaultParameterThresholds: Object,
20
20
  defaultCompletenessThresholdCount: Number,
21
+ defaultRateOfChangeThresholds: Object,
21
22
  runFrequencyMinutes: { type: Number, default: 5 },
22
23
  aqiServiceRunMinute: { type: Number, default: 5 },
23
24
  lastSuccessfulRun: Date,
@@ -230,8 +230,19 @@ const monitorsSchema = mongoose.Schema(
230
230
  monitorLatitude: Number,
231
231
  monitorLongitude: Number,
232
232
  gpsLocation: {
233
- type: { type: String, enum: ["Point"], required: true },
234
- coordinates: { type: [Number], required: true },
233
+ type: {
234
+ type: String,
235
+ enum: ["Point"],
236
+ required: function () {
237
+ return this.monitorLatitude != null && this.monitorLongitude != null;
238
+ },
239
+ },
240
+ coordinates: {
241
+ type: [Number],
242
+ required: function () {
243
+ return this.monitorLatitude != null && this.monitorLongitude != null;
244
+ },
245
+ },
235
246
  },
236
247
  location: Object,
237
248
  context: [String],
@@ -254,6 +265,7 @@ const monitorsSchema = mongoose.Schema(
254
265
  parameterThresholds: Object,
255
266
  completionPercentageThresholds: Object,
256
267
  anomalyPercentageThresholds: Object,
268
+ rateOfChangeThresholds: Object,
257
269
  // A Map, keyed by pollutant (e.g. "PM2_5"), storing Correction sub-docs
258
270
  corrections: {
259
271
  type: Map,
@@ -0,0 +1,34 @@
1
+ import mongoose from "mongoose";
2
+
3
+ const rateOfChangeSchema = mongoose.Schema(
4
+ {
5
+ monitorId: { type: mongoose.Types.ObjectId, ref: "Monitors" },
6
+ monitorSupplier: String,
7
+ parameter: String,
8
+ hourStart: Date,
9
+ hourEnd: Date,
10
+ previousHourStart: Date,
11
+ previousHourEnd: Date,
12
+ hourlyAvg: { type: Number, default: null },
13
+ previousHourlyAvg: { type: Number, default: null },
14
+ absoluteDifference: Number,
15
+ flags: Object,
16
+ },
17
+ { timestamps: true }
18
+ );
19
+
20
+ rateOfChangeSchema.index({
21
+ monitorId: 1,
22
+ parameter: 1,
23
+ hourStart: 1,
24
+ });
25
+
26
+ rateOfChangeSchema.index({
27
+ monitorId: 1,
28
+ hourStart: 1,
29
+ flags: 1,
30
+ });
31
+
32
+ const RateOfChange = mongoose.model("RateOfChange", rateOfChangeSchema);
33
+
34
+ export { rateOfChangeSchema, RateOfChange };
@@ -1,19 +0,0 @@
1
- import mongoose from 'mongoose';
2
-
3
- const referenceMonitorInfoSchema = mongoose.Schema({
4
- bboxStartLat: String,
5
- bboxStartLong: String,
6
- bboxEndLat: String,
7
- bboxEndLong: String,
8
- parameters: String,
9
- sponsor: { type: mongoose.Types.ObjectId, ref: 'Organizations' },
10
- location: Object,
11
- isActive: { type: Boolean, default: true },
12
- context: [String]
13
- }, {
14
- timestamps: true
15
- });
16
-
17
- const ReferenceMonitorInfo = mongoose.model('ReferenceMonitorInfo', referenceMonitorInfoSchema);
18
-
19
- export {referenceMonitorInfoSchema, ReferenceMonitorInfo};