Skip to content
Snippets Groups Projects
Commit d485863b authored by sacha's avatar sacha
Browse files

Merge branch 'algo-recommendation' of...

Merge branch 'algo-recommendation' of https://forge.univ-lyon1.fr/p2306959/projet-tutore-s5 into algo-recommendation
parents 577f751f 00603876
No related branches found
No related tags found
No related merge requests found
...@@ -24,6 +24,15 @@ function top3(movies) { ...@@ -24,6 +24,15 @@ function top3(movies) {
return highestNotes; return highestNotes;
} }
exports.getRecommandations = (req,res,next) => {
let username = req.session.username;
let infos = recommendationForUser(username);
res.status(200).json(infos);
};
/** /**
* Cette fonction selectionne les 3 meilleurs films pour un utilisateur. * Cette fonction selectionne les 3 meilleurs films pour un utilisateur.
* *
......
const express = require('express'); const express = require('express');
const router = express.Router(); const router = express.Router();
const controller = require('../controllers/userController'); const controller = require('../controllers/userController');
const recommandationController = require('../controllers/recommendation');
const auth = require('../middlewares/auth'); const auth = require('../middlewares/auth');
router.get('/',auth.auth,controller.getUserInformations); router.get('/',auth.auth,controller.getUserInformations);
...@@ -13,5 +14,7 @@ router.get('/logout',auth.auth,controller.logout); ...@@ -13,5 +14,7 @@ router.get('/logout',auth.auth,controller.logout);
router.put('/',auth.auth,controller.changeUserInfos); router.put('/',auth.auth,controller.changeUserInfos);
router.get('/recommandation',auth.auth,recommandationController.getRecommandations);
module.exports = router; module.exports = router;
\ No newline at end of file
...@@ -28,8 +28,27 @@ function getUserInfo() { ...@@ -28,8 +28,27 @@ function getUserInfo() {
} }
function getRecommandation() {
const req = fetch('http://localhost:3000/user/recommandation', { credentials: 'include' }).then(response => {
if (response.ok) {
return response.json();
}
}).then(data => {
if (data) {
console.log(data);
}
}).catch(erreur => {
console.error('Erreur lors de l\'appel API :', erreur);
isConnected.value = false;
});
}
onMounted(() => { onMounted(() => {
getUserInfo(); getUserInfo();
getRecommandation();
}); });
</script> </script>
...@@ -49,6 +68,7 @@ onMounted(() => { ...@@ -49,6 +68,7 @@ onMounted(() => {
<button>Changer de mot de passe</button> <button>Changer de mot de passe</button>
</div> </div>
<h1>Films préférés :</h1> <h1>Films préférés :</h1>
<h3></h3>
</template> </template>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment