Skip to content

Commit

Permalink
Merge pull request #177 from marklise/ttlsapi
Browse files Browse the repository at this point in the history
PRC-858 Track status changes.
  • Loading branch information
marklise authored Dec 19, 2018
2 parents 8c6608c + d605280 commit 6a6b2d9
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
8 changes: 8 additions & 0 deletions api/controllers/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ var tagList = ['agency',
'createdDate',
'description',
'legalDescription',
'statusHistoryEffectiveDate',
'location',
'name',
'_proponent',
Expand Down Expand Up @@ -668,5 +669,12 @@ var addStandardQueryFilters = function (query, args) {
centroid: { $geoIntersects: { $geometry: { type: "Polygon", coordinates: JSON.parse(args.swagger.params.centroid.value) } } }
});
}
// Allows filtering of apps that have had their last status change greater than this epoch time.
if (args.swagger.params.statusHistoryEffectiveDate && args.swagger.params.statusHistoryEffectiveDate !== undefined) {
var queryString = qs.parse(args.swagger.params.statusHistoryEffectiveDate.value);
_.assignIn(query, {
$or: [ { statusHistoryEffectiveDate: null }, { statusHistoryEffectiveDate: { $gte: parseInt(queryString.gte, 10) } } ]
});
}
return query;
}
3 changes: 3 additions & 0 deletions api/helpers/models/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
tenureStage : { type: String },
type : { type: String },

// Used to track when the latest status was effective.
statusHistoryEffectiveDate : { type: Number, default: null },

// Note: Default on tag property is purely for display only, they have no real effect on the model.
// This must be done in the code.
tags : [[{ type: String, trim: true, default: '[["sysadmin"]]' }]],
Expand Down
5 changes: 3 additions & 2 deletions api/helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ var helpers = require('@turf/helpers');
var Wkt = require('wicket');
var _serviceHost = process.env.CLAMAV_SERVICE_HOST || '127.0.0.1';
var _servicePort = process.env.CLAMAV_SERVICE_PORT || '3310';
var _tantalisAPI = process.env.TTLS_API_ENDPOINT || "https://i1api.nrs.gov.bc.ca/ttls-api/v1/";
var webADEAPI = process.env.WEBADE_AUTH_ENDPOINT || "https://i1api.nrs.gov.bc.ca/oauth2/v1/";
var _tantalisAPI = process.env.TTLS_API_ENDPOINT || "https://api.nrs.gov.bc.ca/ttls-api/v1/";
var webADEAPI = process.env.WEBADE_AUTH_ENDPOINT || "https://api.nrs.gov.bc.ca/oauth2/v1/";
var username = process.env.WEBADE_USERNAME || "TTLS-EXT";
var password = process.env.WEBADE_PASSWORD || "x";
var MAX_LIMIT = 1000;
Expand Down Expand Up @@ -276,6 +276,7 @@ exports.getApplicationByDispositionID = function (accessToken, disp) {
application.DISPOSITION_TRANSACTION_SID = disp;
application.parcels = [];
application.interestedParties = [];
application.statusHistoryEffectiveDate = (obj.statusHistory[0] != null) ? obj.statusHistory[0].effectiveDate : null;

// WKT conversion to GEOJSON
for (let geo of obj.interestParcels) {
Expand Down
12 changes: 12 additions & 0 deletions api/swagger/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1068,6 +1068,12 @@ paths:
type: string
required: false
description: "Get an Application that relates to size of areaHectares."
- in: query
name: statusHistoryEffectiveDate
collectionFormat: multi
type: number
required: false
description: "Get an Application where the last status change was since this epoch time."
- in: query
name: centroid
required: false
Expand Down Expand Up @@ -1191,6 +1197,12 @@ paths:
type: string
required: false
description: "Get an Application that relates to size of areaHectares."
- in: query
name: statusHistoryEffectiveDate
collectionFormat: multi
type: number
required: false
description: "Get an Application where the last status change was since this epoch time."
- in: query
name: centroid
required: false
Expand Down

0 comments on commit 6a6b2d9

Please sign in to comment.