-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
2910: Flutracking - percent fever & cough per postcode SOL-56 #2872
Changes from 15 commits
ccd40a1
258e437
bb726b7
608a51d
2be758d
c90713f
2eeeeb0
e217f4f
a4441fc
0e414fc
c6ef73e
ada7430
8e6cc75
82a769e
ce62f2e
bd321d6
a3e0f3c
91517b1
ad3aa81
582d83d
723b74e
c88430f
05415d4
5d2960d
2d574af
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
'use strict'; | ||
|
||
import { generateId, insertObject } from '../utilities'; | ||
|
||
var dbm; | ||
var type; | ||
var seed; | ||
|
||
/** | ||
* We receive the dbmigrate dependency from dbmigrate initially. | ||
* This enables us to not have to rely on NODE_PATH. | ||
*/ | ||
exports.setup = function (options, seedLink) { | ||
dbm = options.dbmigrate; | ||
type = dbm.dataType; | ||
seed = seedLink; | ||
}; | ||
|
||
const permissionGroupNameToId = async (db, name) => { | ||
const record = await db.runSql(`SELECT id FROM permission_group WHERE name = '${name}'`); | ||
return record.rows[0] && record.rows[0].id; | ||
}; | ||
|
||
const REPORT = { | ||
id: generateId(), | ||
code: 'AU_Flutracking_Postcode_Percent_Report', | ||
config: { | ||
fetch: { | ||
aggregations: [ | ||
{ | ||
type: 'RAW', | ||
config: { | ||
dataSourceEntityType: 'postcode', | ||
}, | ||
}, | ||
], | ||
dataElements: ['FWV_PC_004', 'FWV_PC_003'], | ||
dataGroups: ['FPWV'], | ||
}, | ||
transform: [ | ||
{ | ||
transform: 'select', | ||
"'numerator'": '$row.FWV_PC_004', | ||
"'denominator'": '$row.FWV_PC_003', | ||
"'organisationUnitCode'": '$row.orgUnit', | ||
}, | ||
{ | ||
transform: 'aggregate', | ||
numerator: 'sum', | ||
denominator: 'sum', | ||
organisationUnitCode: 'group', | ||
}, | ||
{ | ||
transform: 'select', | ||
"'value'": 'divide($row.numerator, $row.denominator)', | ||
"'Total respondents'": '$row.denominator', | ||
"'Respondents reporting fever & cough'": '$row.numerator', | ||
'...': ['organisationUnitCode'], | ||
}, | ||
{ | ||
transform: 'filter', | ||
where: "$row.value > '0.01'", | ||
'...': ['organisationUnitCode'], | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
exports.up = async function (db) { | ||
const permissionGroupId = await permissionGroupNameToId(db, 'Public'); | ||
await insertObject(db, 'report', { ...REPORT, permission_group_id: permissionGroupId }); | ||
}; | ||
|
||
exports.down = async function (db) { | ||
return db.runSql(` | ||
DELETE FROM "report" WHERE code = '${REPORT.code}'; | ||
`); | ||
}; | ||
|
||
exports._meta = { | ||
version: 1, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
'use strict'; | ||
|
||
import { insertObject, generateId } from '../utilities'; | ||
|
||
var dbm; | ||
var type; | ||
var seed; | ||
|
||
/** | ||
* We receive the dbmigrate dependency from dbmigrate initially. | ||
* This enables us to not have to rely on NODE_PATH. | ||
*/ | ||
exports.setup = function (options, seedLink) { | ||
dbm = options.dbmigrate; | ||
type = dbm.dataType; | ||
seed = seedLink; | ||
}; | ||
|
||
const MAP_OVERLAY = { | ||
id: 'AU_Flutracking_Postcode_Fever_Percent', | ||
name: '% fever and cough by postcode', | ||
userGroup: 'Public', | ||
dataElementCode: 'value', | ||
isDataRegional: true, | ||
measureBuilder: 'useReportServer', | ||
measureBuilderConfig: { | ||
dataSourceType: 'custom', | ||
reportCode: 'AU_Flutracking_Postcode_Percent_Report', | ||
}, | ||
presentationOptions: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rohan-bes |
||
hideByDefault: { | ||
null: true, | ||
}, | ||
icon: 'circle', | ||
displayType: 'shaded-spectrum', | ||
measureLevel: 'Postcode', | ||
valueType: 'percentage', | ||
scaleType: 'performance', | ||
scaleColorScheme: 'default', | ||
hideFromPopup: false, | ||
hideFromMenu: false, | ||
hideFromLegend: false, | ||
linkedMeasures: null, | ||
periodGranularity: 'one_week_at_a_time', | ||
scaleBounds: { | ||
right: { | ||
max: 0.05, | ||
}, | ||
left: { | ||
max: 0.01, | ||
}, | ||
}, | ||
measureConfig: { | ||
$all: { | ||
type: 'popup-only', | ||
hideFromLegend: true, | ||
measureLevel: 'Postcode', | ||
}, | ||
}, | ||
}, | ||
countryCodes: '{"AU"}', | ||
projectCodes: '{covidau}', | ||
}; | ||
|
||
const getMapOverlayGroupId = async function (db, code) { | ||
const results = await db.runSql(`select "id" from "map_overlay_group" where "code" = '${code}';`); | ||
|
||
if (results.rows.length > 0) { | ||
return results.rows[0].id; | ||
} | ||
|
||
throw new Error('MapOverlayGroup not found'); | ||
}; | ||
|
||
const mapOverlayGroupRelation = groupId => ({ | ||
id: generateId(), | ||
map_overlay_group_id: groupId, | ||
child_id: MAP_OVERLAY.id, | ||
child_type: 'mapOverlay', | ||
sort_order: 0, | ||
}); | ||
|
||
const MAP_OVERLAY_GROUP_CODE = 'Flutracking_Australia'; | ||
|
||
exports.up = async function (db) { | ||
await insertObject(db, 'mapOverlay', MAP_OVERLAY); | ||
const mapOverlayGroupId = await getMapOverlayGroupId(db, MAP_OVERLAY_GROUP_CODE); | ||
await insertObject(db, 'map_overlay_group_relation', mapOverlayGroupRelation(mapOverlayGroupId)); | ||
}; | ||
|
||
exports.down = function (db) { | ||
return db.runSql(` | ||
delete from "map_overlay_group_relation" where "child_id" = '${MAP_OVERLAY.id}'; | ||
delete from "mapOverlay" where "id" = '${MAP_OVERLAY.id}'; | ||
`); | ||
}; | ||
|
||
exports._meta = { | ||
version: 1, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,4 +59,4 @@ Authorization: {{authorization}} | |
} | ||
] | ||
} | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably revert this return change? Totally fine by me but it is up to you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rohan-bes also need help with filtering 'No data' on report server side, not FE, trying
exists()
and other ideas but haven't gotten it working yet. Chat to you this am?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PShoe Do you find a way to filter 'No data'? I guess you do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rohan said it wasn't possible. So no, but also fine with the code as is. 👍