Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Christian Fischer Pedersen
AIR
Commits
f35b3046
Commit
f35b3046
authored
Jan 04, 2022
by
thecml
Browse files
Merge branch 'master' of
https://gitlab.au.dk/cfp/air
parents
c996bd82
25659090
Pipeline
#102376
passed with stage
in 5 minutes and 17 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
web/api/server.js
View file @
f35b3046
...
...
@@ -16,17 +16,17 @@ app.use(cors(corsOptions));
app
.
use
(
express
.
json
());
app
.
use
(
express
.
urlencoded
({
extended
:
true
}));
var
corsOptions
=
{
origin
:
"
http://localhost:8081
"
};
var
corsOptions
=
{
origin
:
"
http://localhost:8081
"
};
/
*
var corsOptions = {
origin: "https://air-app.azurewebsites.net"
};
*/
/
/
var corsOptions = {
//
origin: "https://air-app.azurewebsites.net"
//
};
const
log
=
bunyan
.
createLogger
({
name
:
"
AIR_UI_Backend:
"
});
const
predictionURL_training
=
'
https://air-fastapi.azurewebsites.net/predict_training
'
;
const
predictionURL_alarm
=
'
https://air-fastapi.azurewebsites.net/predict_alarm
'
;
const
log
=
bunyan
.
createLogger
({
name
:
"
AIR_UI_Backend:
"
});
const
predictionURL_training
=
'
https://air-fastapi.azurewebsites.net/predict_training
'
;
const
predictionURL_alarm
=
'
https://air-fastapi.azurewebsites.net/predict_alarm
'
;
async
function
deleteVariable
(
variablesMarkedForDeletion
)
{
variablesMarkedForDeletion
.
forEach
(
element
=>
{
...
...
@@ -129,12 +129,15 @@ app.post("/home/:ssn", async (req, res) => {
var
assistiveAidsWithCorrectDateFormat
=
changeLendDateFormat
(
citizenData
.
Assistive_Aids
);
var
sortedAssistiveAids
=
sortAssistiveAidsByDate
(
assistiveAidsWithCorrectDateFormat
);
//Case Complete Training
var
assistiveAidsTraining
=
appendAssistiveAidsISO
(
sortedAssistiveAids
);
var
loanPeriod
=
calculateMeanLoanPeriod
(
sortedAssistiveAids
);
//Remove invalid assistive aids iso's
var
sortedAndCleanedAssistiveAids
=
removeInvalidAssistiveAidsFromList
(
sortedAssistiveAids
);
//Case Alarm
var
assistiveAidsWithoutAlarm
=
removeAlarmFromAssistiveAidsList
(
sortedAssistiveAids
);
//Assistive Aids and Loan Period Calculations for the complete training case
var
assistiveAidsTraining
=
appendAssistiveAidsISO
(
sortedAndCleanedAssistiveAids
);
var
loanPeriod
=
calculateMeanLoanPeriod
(
sortedAndCleanedAssistiveAids
);
//Assistive Aids Calculations for the alarm case (it utilizes the same loan period as the complete training case)
var
assistiveAidsWithoutAlarm
=
removeAlarmFromAssistiveAidsList
(
sortedAndCleanedAssistiveAids
);
var
assistiveAidsAlarm
=
appendAssistiveAidsISO
(
assistiveAidsWithoutAlarm
);
//Input to ML model for both cases
...
...
@@ -152,7 +155,8 @@ app.post("/home/:ssn", async (req, res) => {
await
deleteVariable
([
citizenData
,
assistiveAidsWithCorrectDateFormat
,
sortedAssistiveAids
,
sortedAssistiveAids
,
sortedAndCleanedAssistiveAids
,
assistiveAidsTraining
,
loanPeriod
,
inputForCompleteTrainingPrediction
,
...
...
@@ -189,6 +193,15 @@ function sortAssistiveAidsByDate(assistiveAids){
}
}
function
removeInvalidAssistiveAidsFromList
(
assistiveAids
)
{
for
(
var
i
=
0
;
i
<
assistiveAids
.
length
;
i
++
)
{
if
(
assistiveAids
[
i
].
iso
===
'
999999
'
)
{
assistiveAids
.
splice
(
i
,
1
);
}
}
return
assistiveAids
;
}
function
removeAlarmFromAssistiveAidsList
(
assistiveAids
)
{
for
(
var
i
=
0
;
i
<
assistiveAids
.
length
;
i
++
)
{
if
(
assistiveAids
[
i
].
iso
===
'
222718
'
)
{
...
...
@@ -229,11 +242,11 @@ function dateDifferenceInDays(assistiveAidLendDate) {
return
Math
.
round
(((
differenceInTime
))
/
(
oneDayInMilliseconds
)
-
1
);
}
//http.createServer(app).listen(80);
//https.createServer(app).listen(443);
//log.info(`Server is listening on port ${80} and ${443}.`);
//
http.createServer(app).listen(80);
//
https.createServer(app).listen(443);
//
log.info(`Server is listening on port ${80} and ${443}.`);
const
PORT
=
process
.
env
.
PORT
||
8080
;
app
.
listen
(
PORT
,
()
=>
{
log
.
info
(
`Server is listening on port
${
PORT
}
.`
);
});
\ No newline at end of file
app
.
listen
(
PORT
,
()
=>
{
log
.
info
(
`Server is listening on port
${
PORT
}
.`
);
});
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment