Skip to content

Commit a8cc2fd

Browse files
author
Jon Myrick
authored
Merge pull request CodewarsClone#87 from CodewarsClone/voteBranch
added the correct parameter to certain functions in the home and solu…
2 parents 0850cec + 7cd3b36 commit a8cc2fd

5 files changed

Lines changed: 13 additions & 23 deletions

File tree

controllers/kataCtrl.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ module.exports = {
1414
},
1515

1616
getRandomKata: (req, res, next) => {
17-
var kataLevel = req.params.userkyu;
18-
var bottomRange = kataLevel - 1;
19-
var topRange = kataLevel + 1;
17+
let kataLevel = req.params.userkyu;
18+
let bottomRange = kataLevel - 1;
19+
let topRange = kataLevel + 1;
2020
db.read.random_kata([bottomRange, topRange], (err, katas) => {
2121
if (err) return next(err);
2222
return res.status(200).json(katas[Math.floor(Math.random() * katas.length)]);
2323
})
2424
},
2525

2626
getRandomKataList: (req, res, next) => {
27-
var kataLevel = req.params.userkyu;
28-
var bottomRange = kataLevel - 1;
29-
var topRange = kataLevel + 1;
27+
let kataLevel = req.params.userkyu;
28+
let bottomRange = kataLevel - 1;
29+
let topRange = kataLevel + 1;
3030
db.read.random_kata([bottomRange, topRange], (err, katas) => {
3131
if (err) return next(err);
3232
return res.status(200).json(katas);

src/components/home/homeCtrl.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ angular.module('app').controller('homeCtrl', function($scope, $state, mainServic
2828
})
2929
}
3030

31-
$scope.voteKata = () => {
32-
mainService.voteKata().then(response => {
31+
$scope.voteKata = (kataid, vote) => { // the vote is a true or false value
32+
mainService.voteKata(mainService.user.id, kataid, vote).then(response => {
3333
$scope.kataVotes = response.data;
3434
console.log($scope.kataVotes);
3535
})
@@ -41,7 +41,6 @@ angular.module('app').controller('homeCtrl', function($scope, $state, mainServic
4141

4242
$scope.getUser();
4343
$scope.getUserKatas(mainService.user.id);
44-
$scope.voteKata();
4544

4645

4746
});

src/components/kata_list/kata_listCtrl.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,8 @@ angular.module('app').controller('kata_listCtrl', function($scope, $state, mainS
3535
})
3636
}
3737

38-
// $scope.voteKata = () => {
39-
// mainService.voteKata().then(response => {
40-
// $scope.kataVotes = response.data;
41-
// console.log($scope.kataVotes);
42-
// })
43-
// }
44-
4538
$scope.init = () => {
4639
$scope.getRandomKataList();
4740
}
4841

49-
// $scope.voteKata();
50-
5142
});

src/components/mainService.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ angular.module('app').service('mainService', function($http, $q, $sce) {
44

55
// $sce.trustAsResourceUrl('/s');
66

7-
// Dumby information so I don't have to mess with the server all the time.
7+
// Dummy information so I don't have to mess with the server all the time.
88
this.user = {id: 4, github_id: "20197415", name: "Steven", email: null, picture_url: "https://avatars.githubusercontent.com/u/20197415?v=3", username: "Steven-Nagie"};
99
// this.user = {};
1010

@@ -52,7 +52,7 @@ angular.module('app').service('mainService', function($http, $q, $sce) {
5252
})
5353
}
5454

55-
this.voteKata = (userid, kataid, vote) => {
55+
this.voteKata = (userid, kataid, vote) => {
5656
return $http({
5757
method: 'POST',
5858
url: `/api/kata-votes/` + kataid,

src/components/solutions/solutionsCtrl.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ angular.module('app').controller('solutionsCtrl', function($scope, $state, mainS
3131
})
3232
}
3333

34-
$scope.voteSolution = () => {
35-
mainService.voteSolution().then(response => {
34+
$scope.voteSolution = (solutionid, vote) => { // the vote is a true or false value
35+
mainService.voteSolution(mainService.user.id, solutionid, vote).then(response => {
3636
$scope.solutionVotes = response.data;
3737
console.log($scope.solutionVotes);
3838
})
@@ -42,7 +42,7 @@ angular.module('app').controller('solutionsCtrl', function($scope, $state, mainS
4242
$scope.getKataById($scope.kataid);
4343
}
4444

45-
$scope.voteSolution();
45+
4646

4747

4848

0 commit comments

Comments
 (0)