-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/43328 ps report transformation (#1802)
* [tslib] add new function skel * Add pupil fields to report * Fix typos * fix timestamp typo * [tslib] add tests test constructor / add immutability * [admin] fix flaky test * Add fields * Add fields * Add check fields * refactor * add incomplete check tests * Add missing mock * Add device fields * Change date of birth to be an actual date type * Add start of question fields * refactor * refactor part 2 * add tests * Fix the check form service integration test * Add first and last key press calculations * [tslib] Add tests for response time * Fix test, broken by recent change to the unit test * [tslib] add question timeout * [tslib] add timeoutResponse * [tslib] add timeout score * [tslib] add question load time * [tslib] add overall time * [tslib] add recall time * [tslib] type update * [tslib] Drop obsolete table mtc_admin.answer was migrated to mtc_results.answer * [db] Drop obsolete table * [db] drop obsolete table * [tslib] clean up Co-authored-by: Guy Harwood <[email protected]> Co-authored-by: Mohsen Qureshi <[email protected]>
- Loading branch information
1 parent
a6a9c31
commit 45783a0
Showing
36 changed files
with
2,510 additions
and
52 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
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
1 change: 1 addition & 0 deletions
1
db/migrations/schema-objects/20210128093754.do.drop-mtc-admin-answer.sql
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 @@ | ||
DROP TABLE IF EXISTS [mtc_admin].[answer]; |
30 changes: 30 additions & 0 deletions
30
db/migrations/schema-objects/20210128093754.undo.drop-mtc-admin-answer.sql
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,30 @@ | ||
CREATE TABLE [mtc_admin].[answer] | ||
([id] [int] IDENTITY (1,1) NOT NULL, | ||
[createdAt] [datetimeoffset](3) NOT NULL, | ||
[updatedAt] [datetimeoffset](3) NOT NULL, | ||
[version] [timestamp] NOT NULL, | ||
[check_id] [int] NOT NULL, | ||
[questionNumber] [smallint] NOT NULL, | ||
[answer] [nvarchar](60) NOT NULL, | ||
[isCorrect] [bit] NOT NULL, | ||
[question_id] [int] NOT NULL, | ||
CONSTRAINT [PK_answers] PRIMARY KEY CLUSTERED ([id] ASC) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY] | ||
) | ||
ON [PRIMARY] | ||
GO | ||
|
||
/****** Object: Index [answer_check_id_questionNumber_uindex] ******/ | ||
CREATE UNIQUE NONCLUSTERED INDEX [answer_check_id_questionNumber_uindex] ON [mtc_admin].[answer] ([check_id] ASC, [questionNumber] ASC) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY] | ||
GO | ||
|
||
/****** Object: Index [ix_answer_question_id] ******/ | ||
CREATE NONCLUSTERED INDEX [ix_answer_question_id] ON [mtc_admin].[answer] ([question_id] ASC) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY] | ||
GO | ||
|
||
|
||
CREATE TRIGGER [mtc_admin].[answerUpdatedAtTrigger] | ||
ON [mtc_admin].[answer] | ||
FOR UPDATE AS | ||
BEGIN | ||
UPDATE [mtc_admin].[answer] SET updatedAt = GETUTCDATE() FROM inserted WHERE [answer].id = inserted.id | ||
END |
1 change: 1 addition & 0 deletions
1
...ns/schema-objects/20210128112413.do.drop-table-mtc-admin-psychometrician-report-cache.sql
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 @@ | ||
DROP TABLE IF EXISTS [mtc_admin].[psychometricianReportCache]; |
31 changes: 31 additions & 0 deletions
31
.../schema-objects/20210128112413.undo.drop-table-mtc-admin-psychometrician-report-cache.sql
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 @@ | ||
CREATE TABLE [mtc_admin].[psychometricianReportCache] | ||
( | ||
id INT IDENTITY | ||
CONSTRAINT PK_psychometricianReportCache | ||
PRIMARY KEY, | ||
check_id INT NOT NULL | ||
REFERENCES mtc_admin.[check], | ||
jsonData NVARCHAR(max) NOT NULL, | ||
version TIMESTAMP NOT NULL, | ||
createdAt DATETIMEOFFSET(3) DEFAULT getutcdate() NOT NULL, | ||
updatedAt DATETIMEOFFSET(3) DEFAULT getutcdate() NOT NULL | ||
) | ||
GO | ||
|
||
GRANT DELETE ON mtc_admin.psychometricianReportCache to mtcAdminUser | ||
GO | ||
|
||
CREATE UNIQUE INDEX psychometricianReportCache_check_id_uindex | ||
on mtc_admin.psychometricianReportCache (check_id) | ||
GO | ||
|
||
CREATE TRIGGER [mtc_admin].[psychometricianReportCacheUpdatedAtTrigger] | ||
ON [mtc_admin].[psychometricianReportCache] | ||
FOR UPDATE | ||
AS | ||
BEGIN | ||
UPDATE [mtc_admin].[psychometricianReportCache] | ||
SET updatedAt = GETUTCDATE() | ||
FROM inserted | ||
WHERE [psychometricianReportCache].id = inserted.id | ||
END |
1 change: 1 addition & 0 deletions
1
db/migrations/schema-objects/20210128113040.do.drop-table-mtc-admin-anomaly-report-cache.sql
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 @@ | ||
DROP TABLE IF EXISTS [mtc_admin].[anomalyReportCache]; |
24 changes: 24 additions & 0 deletions
24
...grations/schema-objects/20210128113040.undo.drop-table-mtc-admin-anomaly-report-cache.sql
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,24 @@ | ||
CREATE TABLE mtc_admin.anomalyReportCache | ||
(id INT IDENTITY | ||
CONSTRAINT PK_anomalyReportCache PRIMARY KEY, | ||
check_id INT NOT NULL REFERENCES mtc_admin.[check], | ||
jsonData NVARCHAR(MAX) NOT NULL, | ||
version TIMESTAMP NOT NULL, | ||
createdAt DATETIMEOFFSET(3) DEFAULT getutcdate() NOT NULL, | ||
updatedAt DATETIMEOFFSET(3) DEFAULT getutcdate() NOT NULL | ||
) | ||
GO | ||
|
||
GRANT DELETE ON mtc_admin.anomalyReportCache TO mtcAdminUser | ||
GO | ||
|
||
|
||
CREATE TRIGGER [mtc_admin].[anomalyReportCacheUpdatedAtTrigger] | ||
ON [mtc_admin].[anomalyReportCache] | ||
FOR UPDATE AS | ||
BEGIN | ||
UPDATE [mtc_admin].[anomalyReportCache] | ||
SET updatedAt = GETUTCDATE() | ||
FROM inserted | ||
WHERE [anomalyReportCache].id = inserted.id | ||
END |
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
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,21 @@ | ||
AzureWebJobs.check-marker.Disabled=false | ||
AzureWebJobs.check-notifier-batch.Disabled=false | ||
AzureWebJobs.check-notifier.Disabled=false | ||
AzureWebJobs.check-marker.Disabled=true | ||
AzureWebJobs.check-notifier-batch.Disabled=true | ||
AzureWebJobs.check-notifier.Disabled=true | ||
AzureWebJobs.check-pin-expiry.Disabled=true | ||
AzureWebJobs.check-receiver.Disabled=false | ||
AzureWebJobs.check-receiver.Disabled=true | ||
AzureWebJobs.check-started.Disabled=false | ||
AzureWebJobs.check-sync.Disabled=true | ||
AzureWebJobs.check-validator.Disabled=false | ||
AzureWebJobs.check-validator.Disabled=true | ||
AzureWebJobs.gias-sync.Disabled=true | ||
AzureWebJobs.pupil-auth.Disabled=false | ||
AzureWebJobs.pupil-feedback.Disabled=false | ||
AzureWebJobs.pupil-login.Disabled=false | ||
AzureWebJobs.pupil-prefs.Disabled=false | ||
AzureWebJobs.school-pin-generator.Disabled=false | ||
AzureWebJobs.school-pin-http-service.Disabled=false | ||
AzureWebJobs.school-results-cache-determiner.Disabled=false | ||
AzureWebJobs.school-results-cache.Disabled=false | ||
AzureWebJobs.ps-report-transformer.Disabled=false | ||
AzureWebJobs.pupil-auth.Disabled=true | ||
AzureWebJobs.pupil-feedback.Disabled=true | ||
AzureWebJobs.pupil-login.Disabled=true | ||
AzureWebJobs.pupil-prefs.Disabled=true | ||
AzureWebJobs.school-pin-generator.Disabled=true | ||
AzureWebJobs.school-pin-http-service.Disabled=true | ||
AzureWebJobs.school-results-cache-determiner.Disabled=true | ||
AzureWebJobs.school-results-cache.Disabled=true | ||
AzureWebJobs.util-diag.Disabled=true | ||
AzureWebJobs.util-school-pin-sampler.Disabled=true | ||
AzureWebJobs.util-submit-check.Disabled=true |
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,19 @@ | ||
{ | ||
"bindings": [ | ||
{ | ||
"direction": "in", | ||
"type": "serviceBusTrigger", | ||
"name": "inputData", | ||
"queueName": "ps-report-staging", | ||
"connection": "AZURE_SERVICE_BUS_CONNECTION_STRING" | ||
}, | ||
{ | ||
"direction": "out", | ||
"type": "serviceBus", | ||
"name": "outputData", | ||
"queueName": "ps-report-export", | ||
"connection": "AZURE_SERVICE_BUS_CONNECTION_STRING" | ||
} | ||
], | ||
"scriptFile": "../dist/functions/ps-report-transformer/index.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,17 @@ | ||
export function deepFreeze <T> (obj: T): T { | ||
if (typeof obj !== 'object') { | ||
return obj | ||
} | ||
if (obj === null) { | ||
return obj | ||
} | ||
const properties = Object.getOwnPropertyNames(obj) | ||
for (const name of properties) { | ||
// @ts-ignore - ignore any return type | ||
const value: any = obj[name] | ||
if (value !== null && value !== undefined && typeof value === 'object') { | ||
deepFreeze(value) | ||
} | ||
} | ||
return Object.freeze(obj) | ||
} |
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,21 @@ | ||
import moment from 'moment' | ||
const simpleIso8601Regex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/ | ||
|
||
/** | ||
* Reviver function for use with JSON.parse() to instantiate DateTime strings as Moment.moment objects | ||
* @param key | ||
* @param value | ||
*/ | ||
export function jsonReviver (key: any, value: any): any { | ||
if (value !== null && value !== undefined && typeof value === 'string') { | ||
if (simpleIso8601Regex.test(value)) { | ||
try { | ||
const d = moment(value) | ||
if (d?.isValid()) { | ||
return d | ||
} | ||
} catch (ignored) {} | ||
} | ||
} | ||
return value | ||
} |
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
Oops, something went wrong.