All checks were successful
Server Tests / Mocha – Unit & Utility Tests (push) Successful in 42s
+ Added public data export API enhancements, tests, and customer documentation + Extended /api/v1 data export endpoints with richer session, records, area, and async export output + Added confirmed/fallback report values, client metadata, mapped area, over-spray, volume/apprate (string) units, and weather blocks + Normalized flowController to "No FC" and align record field names with playback output + Converted record wind speed output to knots, add Fligh Mater only record/export fields behind fm=true, and persist fm on export jobs + Added export status/area constants, HTTP 202 support, route-level API docs, and per-account export rate limiting support + Added comprehensive endpoint, format, and verification test coverage plus test-suite README + Added customer-facing data export design, integration, rate-limit, and documentation index guides + Updated README/DLQ docs and related documentation links to current HTTPS dashboard paths
36 lines
1.6 KiB
JavaScript
36 lines
1.6 KiB
JavaScript
'use strict';
|
|
|
|
const mongoose = require('mongoose'), Schema = mongoose.Schema;
|
|
const { ExportUnits, ExportJobStatus } = require('../helpers/constants');
|
|
|
|
/**
|
|
* ExportJob model — tracks async CSV/GeoJSON export requests.
|
|
*
|
|
* Lifecycle: pending → processing → ready | error
|
|
* Files are written to env.TEMP_DIR and expire after EXPORT_TTL_HOURS.
|
|
* The download endpoint streams the file and then schedules deletion.
|
|
*/
|
|
const schema = new Schema({
|
|
owner: { type: Schema.Types.ObjectId, ref: 'User', required: true, index: true },
|
|
jobId: { type: Number, required: true },
|
|
format: { type: String, enum: ['csv', 'geojson'], required: true },
|
|
interval: { type: Number, default: null }, // GPS point thinning interval in seconds, null = all points
|
|
units: { type: String, enum: Object.values(ExportUnits), default: ExportUnits.METRIC }, // output measurement system
|
|
fm: { type: Boolean, default: false }, // include Flight Master / AgDisp fields when true
|
|
status: {
|
|
type: String,
|
|
enum: Object.values(ExportJobStatus),
|
|
default: ExportJobStatus.PENDING,
|
|
index: true
|
|
},
|
|
filePath: { type: String }, // absolute path on disk, set when ready
|
|
errorMsg: { type: String },
|
|
createdAt: { type: Date, default: Date.now, index: true },
|
|
expiresAt: { type: Date } // TTL; file and record deleted after this time
|
|
});
|
|
|
|
// Auto-expire documents from MongoDB after expiresAt (background cleanup)
|
|
schema.index({ expiresAt: 1 }, { expireAfterSeconds: 0 });
|
|
|
|
module.exports = mongoose.model('ExportJob', schema);
|