Skip to content

Commit

Permalink
Feature/58454 logon events and MI views (#2487)
Browse files Browse the repository at this point in the history
* views to surface json data and sum distinct school logins

* remove unused output

* docs

* surface more data from dfe signin

* views

---------

Co-authored-by: Mohsen Qureshi <[email protected]>
  • Loading branch information
GuyHarwood and activemq authored Apr 26, 2023
1 parent 627729e commit 49bcb2a
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 0 deletions.
4 changes: 4 additions & 0 deletions admin/services/dfe-signin.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const service = {
/**
* @description maps an authenticated dfe sign-in user to an MTC user, school and role
* @param {object} dfeUser all decrypted user information sent in the request payload
* @param {object} tokenset identification data associated with login provider
*/
initialiseUser: async (dfeUser, tokenset) => {
if (!dfeUser) {
Expand Down Expand Up @@ -101,6 +102,9 @@ const service = {

if (schoolRecord) {
logonEvent.school_id = schoolRecord.id
logonEvent.urn = dfeUser.organisation.urn
logonEvent.mtcRole = dfeUser.role
logonEvent.dfeRole = dfeRole
}

await adminLogonEventDataService.sqlCreate(logonEvent)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
IF NOT EXISTS(
SELECT *
FROM sys.columns
WHERE object_ID = object_id('mtc_admin.adminLogonEvent')
AND col_name(object_ID, column_Id) = 'urn')
BEGIN
ALTER TABLE [mtc_admin].[adminLogonEvent]
ADD [urn] int NULL;
END
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE [mtc_admin].[adminLogonEvent] DROP COLUMN IF EXISTS [urn];
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
IF NOT EXISTS(
SELECT *
FROM sys.columns
WHERE object_ID = object_id('mtc_admin.adminLogonEvent')
AND col_name(object_ID, column_Id) = 'mtcRole')
BEGIN
ALTER TABLE [mtc_admin].[adminLogonEvent]
ADD [mtcRole] nvarchar(50) NULL;
END
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE [mtc_admin].[adminLogonEvent] DROP COLUMN IF EXISTS [mtcRole];
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
IF NOT EXISTS(
SELECT *
FROM sys.columns
WHERE object_ID = object_id('mtc_admin.adminLogonEvent')
AND col_name(object_ID, column_Id) = 'dfeRole')
BEGIN
ALTER TABLE [mtc_admin].[adminLogonEvent]
ADD [dfeRole] nvarchar(max) NULL;
END
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE [mtc_admin].[adminLogonEvent] DROP COLUMN IF EXISTS [dfeRole];
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CREATE OR ALTER VIEW mtc_admin.[vewMiChecksWithErrors] AS
SELECT COUNT(chk.id) as [numberOfChecksWithErrors]
FROM [mtc_admin].[check] chk
WHERE chk.processingFailed = 1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP VIEW IF EXISTS mtc_admin.[vewMiChecksWithErrors];
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CREATE OR ALTER VIEW mtc_admin.[vewMiChecksNotStarted] AS
SELECT COUNT(chk.id) as [numberOfChecksNotStarted]
FROM [mtc_admin].[check] chk
WHERE chk.startedAt IS NULL AND chk.isLiveCheck = 1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP VIEW IF EXISTS mtc_admin.[vewMiChecksNotStarted];
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CREATE OR ALTER VIEW mtc_admin.[vewMiSchoolsLoggedOnAtLeastOnce] AS
SELECT COUNT(DISTINCT ale.urn) as [numberOfSchoolsAccessedService]
FROM [mtc_admin].[adminLogonEvent] ale
WHERE ale.mtcRole = 'TEACHER'
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP VIEW IF EXISTS mtc_admin.[vewMiSchoolsLoggedOnAtLeastOnce];

0 comments on commit 49bcb2a

Please sign in to comment.