Skip to content

Commit 5bf6628

Browse files
committed
2 parents 9af6fb7 + 05b7ef9 commit 5bf6628

File tree

12 files changed

+228
-25
lines changed

12 files changed

+228
-25
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
on:
2+
push:
3+
branches:
4+
- main
5+
pull_request_target:
6+
types: [opened, synchronize, reopened]
7+
8+
name: CodeSee Map
9+
10+
jobs:
11+
test_map_action:
12+
runs-on: ubuntu-latest
13+
continue-on-error: true
14+
name: Run CodeSee Map Analysis
15+
steps:
16+
- name: checkout
17+
id: checkout
18+
uses: actions/checkout@v2
19+
with:
20+
repository: ${{ github.event.pull_request.head.repo.full_name }}
21+
ref: ${{ github.event.pull_request.head.ref }}
22+
fetch-depth: 0
23+
24+
# codesee-detect-languages has an output with id languages.
25+
- name: Detect Languages
26+
id: detect-languages
27+
uses: Codesee-io/codesee-detect-languages-action@latest
28+
29+
- name: Configure JDK 16
30+
uses: actions/setup-java@v2
31+
if: ${{ fromJSON(steps.detect-languages.outputs.languages).java }}
32+
with:
33+
java-version: '16'
34+
distribution: 'zulu'
35+
36+
# CodeSee Maps Go support uses a static binary so there's no setup step required.
37+
38+
- name: Configure Node.js 14
39+
uses: actions/setup-node@v2
40+
if: ${{ fromJSON(steps.detect-languages.outputs.languages).javascript }}
41+
with:
42+
node-version: '14'
43+
44+
- name: Configure Python 3.x
45+
uses: actions/setup-python@v2
46+
if: ${{ fromJSON(steps.detect-languages.outputs.languages).python }}
47+
with:
48+
python-version: '3.x'
49+
architecture: 'x64'
50+
51+
- name: Configure Ruby '3.x'
52+
uses: ruby/setup-ruby@v1
53+
if: ${{ fromJSON(steps.detect-languages.outputs.languages).ruby }}
54+
with:
55+
ruby-version: '3.0'
56+
57+
# CodeSee Maps Rust support uses a static binary so there's no setup step required.
58+
59+
- name: Generate Map
60+
id: generate-map
61+
uses: Codesee-io/codesee-map-action@latest
62+
with:
63+
step: map
64+
github_ref: ${{ github.ref }}
65+
languages: ${{ steps.detect-languages.outputs.languages }}
66+
67+
- name: Upload Map
68+
id: upload-map
69+
uses: Codesee-io/codesee-map-action@latest
70+
with:
71+
step: mapUpload
72+
api_token: ${{ secrets.CODESEE_ARCH_DIAG_API_TOKEN }}
73+
github_ref: ${{ github.ref }}
74+
75+
- name: Insights
76+
id: insights
77+
uses: Codesee-io/codesee-map-action@latest
78+
with:
79+
step: insights
80+
api_token: ${{ secrets.CODESEE_ARCH_DIAG_API_TOKEN }}
81+
github_ref: ${{ github.ref }}

.gitignore

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,23 @@
1-
node_modules
2-
.env
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# production
12+
/build
13+
14+
# misc
15+
.DS_Store
16+
.env.local
17+
.env.development.local
18+
.env.test.local
19+
.env.production.local
20+
21+
npm-debug.log*
22+
yarn-debug.log*
23+
yarn-error.log*

.prettierrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"arrowParens": "always",
3+
"useTabs": false,
4+
"tabWidth": 4
5+
}

src/Graphql/Resolvers/courses.js

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const Course = require('../../Models/Courses');
22
const User = require('../../Models/Users');
3+
const checkAuth = require('../../Util/check_auth');
34

45
module.exports = {
56

@@ -41,6 +42,30 @@ module.exports = {
4142
}
4243

4344
},
45+
async getCourse(_, { courseId }, context) {
46+
47+
try {
48+
49+
const student = checkAuth(context);
50+
51+
if(!student) {
52+
throw new Error('No se encuentra disponible')
53+
}
54+
55+
const course = await Course.findOne({
56+
$and: [
57+
{'_id': courseId},
58+
{'students.student_id': student.id}
59+
]
60+
});
61+
62+
return course;
63+
64+
} catch (err) {
65+
throw new Error(err);
66+
}
67+
68+
}
4469

4570
},
4671
Mutation: {
@@ -51,11 +76,18 @@ module.exports = {
5176
teacherId
5277
}) {
5378

79+
const teacher = await User.findById(teacherId);
80+
5481
const newCourse = new Course({
5582

5683
name,
5784
grade_section,
58-
teacher_id: teacherId
85+
teacher: {
86+
teacher_id: teacher.id,
87+
name: teacher.name,
88+
email: teacher.email,
89+
cellphone: teacher.cellphone,
90+
}
5991

6092
});
6193

src/Graphql/Resolvers/homeworks.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
const Homework = require('../../Models/Homework');
2+
const Course = require('../../Models/Courses');
3+
const Reminder = require('../../Models/Reminders');
24
const checkAuth = require('../../Util/check_auth');
35
const { UserInputError } = require('apollo-server');
6+
const { findById } = require('../../Models/Reminders');
47

58
module.exports = {
69

@@ -33,7 +36,7 @@ module.exports = {
3336

3437
Mutation: {
3538

36-
async createHomework(_, { courseId, title, content }, context) {
39+
async createHomework(_, { courseId, title, content, endDate }, context) {
3740

3841
const user = checkAuth(context);
3942

@@ -54,6 +57,19 @@ module.exports = {
5457

5558
const res = await newHomework.save();
5659

60+
const course = await findById(course_id);
61+
62+
if(res) {
63+
const newReminder = new Reminder({
64+
homework_id: res.id,
65+
title: res.title,
66+
endDate: endDate,
67+
students: course.students,
68+
});
69+
70+
await newReminder.save();
71+
}
72+
5773
return res;
5874

5975
},

src/Graphql/Resolvers/users.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ function generateToken(user) {
1515
lastname: user.lastname,
1616
email: user.email,
1717
cellphone: user.cellphone,
18-
username: user.username
1918
},
2019
SECRET_KEY,
2120
{
@@ -102,16 +101,15 @@ module.exports = {
102101

103102
async registerUser(_, {
104103
name,
105-
lastname,
106-
username,
104+
lastname,
107105
cellphone,
108106
email,
109107
rol,
110108
password,
111109
confirmPassword
112110
}) {
113111

114-
const { valid, errors } = validateRegisterInput(username, email, password, confirmPassword);
112+
const { valid, errors } = validateRegisterInput(email, password, confirmPassword);
115113

116114
if(!valid) {
117115
throw new UserInputError('Errors', {errors});
@@ -130,7 +128,6 @@ module.exports = {
130128
const newUser = new User({
131129
name,
132130
lastname,
133-
username,
134131
cellphone,
135132
email,
136133
rol,

src/Graphql/typeDefs.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,19 @@ module.exports = gql`
3333
3434
}
3535
36+
type Teacher {
37+
teacher_id: ID!
38+
name: String!
39+
email: String!
40+
cellphone: Int!
41+
}
42+
3643
type Course {
3744
3845
id: ID!
3946
name: String!
4047
grade_section: ID!
41-
teacher_id: ID!
48+
teacher: Teacher
4249
students: [Student!]
4350
4451
}
@@ -94,6 +101,7 @@ module.exports = gql`
94101
getUsers: [User]
95102
getUser(userId: ID!): User
96103
getCourses(userId: ID!): [Course]
104+
getCourse(courseId: ID!): Course
97105
getGrades: [Grade]
98106
getHomeworks(courseId: ID!, userId: ID!): [Homework]
99107
@@ -102,7 +110,7 @@ module.exports = gql`
102110
type Mutation {
103111
104112
login(email: String!, password: String!): User
105-
registerUser(name: String!, lastname: String!, username: String!, cellphone: Int!, email: String!, rol: String!, password: String!, confirmPassword: String! ): User
113+
registerUser(name: String!, lastname: String!, cellphone: Int!, email: String!, rol: String!, password: String!, confirmPassword: String! ): User
106114
updateUser(userId: ID!, name: String!, lastname: String!, email: String!): User
107115
deleteUser(userId: ID!): String
108116
createGrade(grade: String!, section: String!, teacherId: String!): Grade!

src/Models/Courses.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@ const courseSchema = new Schema({
1111
ref: 'Grades',
1212
required: true,
1313
},
14-
teacher_id: {
15-
type: Schema.Types.ObjectId,
16-
ref: 'Users',
17-
required: true,
14+
teacher: {
15+
_id: false,
16+
teacher_id: { type: Schema.Types.ObjectId, ref: 'User' },
17+
name: { type: String },
18+
email: { type: String },
19+
cellphone: { type: Number },
20+
1821
},
1922
students: [
2023
{

src/Models/Reminders.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const { Schema, model } = require('mongoose');
2+
3+
const reminderSchema = new Schema({
4+
5+
homework_id: { type: Schema.Types.ObjectId, ref: 'Homework' },
6+
title: { type: String },
7+
endDate: { type: Date },
8+
students: [
9+
{
10+
_id: false,
11+
student_id: {
12+
type: Schema.Types.ObjectId,
13+
ref: 'Users',
14+
},
15+
}
16+
]
17+
18+
});
19+
20+
module.exports = model('Reminder', reminderSchema);

src/Models/Users.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@ const userSchema = new Schema({
99
type: String,
1010
required: true
1111
},
12-
username:{
13-
type: String,
14-
required: true,
15-
trim: true,
16-
unique: true
17-
},
1812
cellphone:{
1913
type: Number,
2014
required: true,

0 commit comments

Comments
 (0)