-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Display monitoring stations in view licence page summary tab (#773)
* https://eaflood.atlassian.net/browse/WATER-4331 View licence summary monitoring stations
- Loading branch information
1 parent
b39dfcb
commit 0d2ca82
Showing
15 changed files
with
503 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
'use strict' | ||
|
||
/** | ||
* Model for gaugingStations (water.gauging_stations) | ||
* @module GaugingStationsnModel | ||
*/ | ||
|
||
const { Model } = require('objection') | ||
|
||
const BaseModel = require('./base.model.js') | ||
|
||
class GaugingStationsnModel extends BaseModel { | ||
static get tableName () { | ||
return 'gaugingStations' | ||
} | ||
|
||
// Defining which fields contain json allows us to insert an object without needing to stringify it first | ||
static get jsonAttributes () { | ||
return [ | ||
'metadata' | ||
] | ||
} | ||
|
||
static get relationMappings () { | ||
return { | ||
licenceGaugingStations: { | ||
relation: Model.HasManyRelation, | ||
modelClass: 'licence-gauging-station.model', | ||
join: { | ||
from: 'gaugingStations.id', | ||
to: 'licenceGaugingStations.gaugingStationId' | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
module.exports = GaugingStationsnModel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
'use strict' | ||
|
||
/** | ||
* Model for licenceGauginStations (water.licence_gauging_stations) | ||
* @module GauginStationsnModel | ||
*/ | ||
|
||
const { Model } = require('objection') | ||
|
||
const BaseModel = require('./base.model.js') | ||
|
||
class LicenceGauginStationsnModel extends BaseModel { | ||
static get tableName () { | ||
return 'licenceGaugingStations' | ||
} | ||
|
||
static get relationMappings () { | ||
return { | ||
licenceGaugingStations: { | ||
relation: Model.HasManyRelation, | ||
modelClass: 'gauging-station.model', | ||
join: { | ||
from: 'licenceGaugingStations.gaugingStationId', | ||
to: 'gaugingStations.id' | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
module.exports = LicenceGauginStationsnModel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
db/migrations/legacy/20240229142820_water-gauging-stations.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
'use strict' | ||
|
||
const tableName = 'gauging_stations' | ||
|
||
exports.up = function (knex) { | ||
return knex | ||
.schema | ||
.withSchema('water') | ||
.createTable(tableName, (table) => { | ||
// Primary Key | ||
table.uuid('gauging_station_id').primary() | ||
|
||
// Data | ||
table.string('label').notNullable() | ||
table.decimal('lat').notNullable() | ||
table.decimal('long').notNullable() | ||
table.integer('easting') | ||
table.integer('northing') | ||
table.string('grid_reference').notNullable() | ||
table.string('catchment_name') | ||
table.string('river_name') | ||
table.string('wiski_id') | ||
table.string('station_reference') | ||
table.string('status') | ||
table.jsonb('metadata') | ||
table.uuid('hydrology_station_id').notNullable() | ||
table.boolean('is_test') | ||
|
||
// Legacy timestamps | ||
table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) | ||
table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) | ||
}) | ||
} | ||
|
||
exports.down = function (knex) { | ||
return knex | ||
.schema | ||
.withSchema('water') | ||
.dropTableIfExists(tableName) | ||
} |
42 changes: 42 additions & 0 deletions
42
db/migrations/legacy/20240229150612_water-licence-gauging-stations.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
'use strict' | ||
|
||
const tableName = 'licence_gauging_stations' | ||
|
||
exports.up = function (knex) { | ||
return knex | ||
.schema | ||
.withSchema('water') | ||
.createTable(tableName, (table) => { | ||
// Primary Key | ||
table.uuid('licence_gauging_station_id').primary() | ||
|
||
// Data | ||
table.uuid('licence_id').notNullable() | ||
table.uuid('gauging_station_id').notNullable() | ||
table.string('source').notNullable() | ||
table.uuid('licence_version_purpose_condition_id').notNullable() | ||
table.smallint('abstraction_period_start_day') | ||
table.smallint('abstraction_period_start_month') | ||
table.smallint('abstraction_period_end_day') | ||
table.smallint('abstraction_period_end_month') | ||
table.string('restriction_type').notNullable() | ||
table.string('threshold_unit').notNullable() | ||
table.decimal('threshold_value').notNullable() | ||
table.string('status').notNullable() | ||
table.timestamp('date_status_updated', { useTz: false }) | ||
table.timestamp('date_deleted', { useTz: false }) | ||
table.string('alert_type').notNullable() | ||
table.boolean('is_test') | ||
|
||
// Legacy timestamps | ||
table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) | ||
table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) | ||
}) | ||
} | ||
|
||
exports.down = function (knex) { | ||
return knex | ||
.schema | ||
.withSchema('water') | ||
.dropTableIfExists(tableName) | ||
} |
35 changes: 35 additions & 0 deletions
35
db/migrations/public/20240229142857_create-water-gauging-stations-view.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
'use strict' | ||
|
||
const viewName = 'gauging_stations' | ||
|
||
exports.up = function (knex) { | ||
return knex | ||
.schema | ||
.createView(viewName, (view) => { | ||
view.as(knex('gauging_stations').withSchema('water').select([ | ||
'gauging_station_id AS id', | ||
'label', | ||
'lat', | ||
'long', | ||
'easting', | ||
'northing', | ||
'grid_reference', | ||
'catchment_name ', | ||
'river_name', | ||
'wiski_id', | ||
'station_reference', | ||
'status', | ||
'metadata', | ||
'hydrology_station_id', | ||
// 'is_test' | ||
'date_created AS created_at', | ||
'date_updated AS updated_at' | ||
])) | ||
}) | ||
} | ||
|
||
exports.down = function (knex) { | ||
return knex | ||
.schema | ||
.dropViewIfExists(viewName) | ||
} |
37 changes: 37 additions & 0 deletions
37
db/migrations/public/20240229150626_create-water-licence-gauging-stations-view.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
'use strict' | ||
|
||
const viewName = 'licence_gauging_stations' | ||
|
||
exports.up = function (knex) { | ||
return knex | ||
.schema | ||
.createView(viewName, (view) => { | ||
view.as(knex('licence_gauging_stations').withSchema('water').select([ | ||
'licence_gauging_station_id AS id', | ||
'licence_id', | ||
'gauging_station_id', | ||
'source', | ||
'licence_version_purpose_condition_id', | ||
'abstraction_period_start_day', | ||
'abstraction_period_start_month ', | ||
'abstraction_period_end_day', | ||
'abstraction_period_end_month', | ||
'restriction_type', | ||
'threshold_unit', | ||
'threshold_value', | ||
'status', | ||
'date_status_updated', | ||
'date_deleted', | ||
'alert_type', | ||
// 'is_test', | ||
'date_created AS created_at', | ||
'date_updated AS updated_at' | ||
])) | ||
}) | ||
} | ||
|
||
exports.down = function (knex) { | ||
return knex | ||
.schema | ||
.dropViewIfExists(viewName) | ||
} |
Oops, something went wrong.