Skip to content

Commit

Permalink
edited the write/career.js file to send http request to python micros…
Browse files Browse the repository at this point in the history
…ervice to get the correct prediction
  • Loading branch information
mrahmatu committed Nov 9, 2023
1 parent 73d27f5 commit 10b8a39
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/controllers/write/career.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const helpers = require('../helpers');
const user = require('../../user');
const db = require('../../database');

const axios = require('axios');

Check failure on line 6 in src/controllers/write/career.js

View workflow job for this annotation

GitHub Actions / Lint (ubuntu-latest, 16)

Expected 1 empty line after require statement not followed by another require

Check failure on line 6 in src/controllers/write/career.js

View workflow job for this annotation

GitHub Actions / Lint (ubuntu-latest, 16)

`axios` import should occur before import of `../helpers`

Check failure on line 6 in src/controllers/write/career.js

View workflow job for this annotation

GitHub Actions / Lint (ubuntu-latest, 16)

Unable to resolve path to module 'axios'
const Career = module.exports;

Career.register = async (req, res) => {
Expand All @@ -20,8 +20,14 @@ Career.register = async (req, res) => {
num_past_internships: userData.num_past_internships,
};

userCareerData.prediction = Math.round(Math.random()); // TODO: Change this line to do call and retrieve actual candidate success prediction from the model instead of using a random number

try {
const apiUrl = 'https://career-microservice-f474tbkenq-uc.a.run.app/predict';
const response = await axios.get(apiUrl, { params: userCareerData });
userCareerData.prediction = String(response.data.good_employee);
} catch (error) {
console.error('Error while making the HTTP request:', error);
}
console.log(userCareerData)
await user.setCareerData(req.uid, userCareerData);
db.sortedSetAdd('users:career', req.uid, req.uid);
res.json({});
Expand Down

0 comments on commit 10b8a39

Please sign in to comment.