Skip to content

Commit 1bf62fd

Browse files
Fetch recommendations for filtered skills
1 parent 64ab802 commit 1bf62fd

File tree

4 files changed

+23
-11
lines changed

4 files changed

+23
-11
lines changed

Backend/app.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ def protected():
271271
def get_recommendations():
272272
filter_skill_arr = request.json['filter_skills']
273273
filter_skill_arr = [x.strip().lower() for x in filter_skill_arr]
274+
# print(filter_skill_arr)
274275
id = get_jwt_identity()
275276
student = Student.query.filter_by(Student_ID=id).first()
276277
skill_arr = []
@@ -279,10 +280,12 @@ def get_recommendations():
279280
else:
280281
skill_arr = filter_skill_arr
281282
rec_names = pipelining.predict(skill_arr)
283+
# NOTE For testing
284+
# rec_names = ["Dummy_a", "Dummy_ab"]
282285
# id, name, photo, headline, requirements, info created using branch-year-batch, skills
283286
cards = list()
284287
for rec_name in rec_names:
285-
if(student.Name.title() == rec_name):
288+
if(student.Name.lower() == rec_name):
286289
continue
287290
curr_rec = dict()
288291
rec = Student.query.filter_by(Name=rec_name).first()

Frontend/components/Discover.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ function Discover() {
3030

3131
const [isLoading, setIsLoading] = React.useState(true);
3232
const [cards, setCards] = useState([]);
33+
const [filtered_skills, setFiltered_skills] = useState([]);
3334

3435
const styles = StyleSheet.create({
3536
container: {
@@ -150,7 +151,9 @@ function Discover() {
150151
// If user has done filtering post that list
151152
// If not, then post users skill list
152153
const res = await axiosInstance.post('/get_recommendations', {
153-
filter_skills: [],
154+
filter_skills: filtered_skills.map(skill => {
155+
return skill.skill_name;
156+
}),
154157
});
155158

156159
setCards(res.data);
@@ -161,17 +164,18 @@ function Discover() {
161164

162165
const init = async () => {
163166
try {
167+
setIsLoading(true);
164168
updateAxiosInstance();
165169
//TODO Build two model files first using retraining function in server for updated db
166-
// await getCards();
170+
await getCards();
167171
setIsLoading(false);
168172
} catch (err) {
169173
console.log(err);
170174
}
171175
};
172176

173177
init();
174-
}, []);
178+
}, [filtered_skills]);
175179

176180
return (
177181
<View style={styles.container}>
@@ -212,7 +216,13 @@ function Discover() {
212216
color={colors.textWhite}
213217
onPress={() => setIsFilterModalVisible(true)}
214218
/>
215-
{isFilterModalVisible && <Filter close={setIsFilterModalVisible} />}
219+
{isFilterModalVisible && (
220+
<Filter
221+
close={setIsFilterModalVisible}
222+
setFiltered_skills={setFiltered_skills}
223+
filtered_skills={filtered_skills}
224+
/>
225+
)}
216226
</View>
217227

218228
{/* Main content with swipe cards */}

Frontend/components/Filter.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ import SkillSection from './SkillSection';
3333
const {height} = Dimensions.get('window');
3434

3535
function Filter(props) {
36-
const {close} = props;
36+
const {close, setFiltered_skills, filtered_skills} = props;
3737

3838
const {colors} = useTheme();
3939

4040
const springAnim = React.useRef(new Animated.Value(1000)).current;
4141

4242
const [selectedLeftIndex, setSelectedLeftIndex] = React.useState(0);
4343

44-
const [filterSkills, setFilterSkills] = React.useState([]);
44+
const [filterSkills, setFilterSkills] = React.useState(filtered_skills);
4545
const [filterLanguages, setFilterLanguages] = React.useState([]);
4646
const [filterYears, setFilterYears] = React.useState([]);
4747
const [filterBranches, setFilterBranches] = React.useState([]);
@@ -85,6 +85,7 @@ function Filter(props) {
8585
duration: 256,
8686
useNativeDriver: true,
8787
}).start(() => {
88+
setFiltered_skills(filterSkills);
8889
close();
8990
});
9091
};

Frontend/components/SkillSection.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
import React from 'react';
2-
import {
3-
Chip,
4-
Button,
5-
} from 'react-native-paper';
2+
import {Chip, Button} from 'react-native-paper';
63
import {ScrollView, View} from 'react-native';
74
import NewSection from './NewSection';
85
import SearchBox from './SearchBox';
@@ -29,6 +26,7 @@ function SkillSection(props) {
2926
});
3027
});
3128
const flatSkills = skillArr.flat();
29+
//can simply return flatSkills right?
3230
const ids = flatSkills.map(it => it.skill_id);
3331
return flatSkills.filter((it, index) => ids.indexOf(it.skill_id) === index);
3432
}

0 commit comments

Comments
 (0)