Skip to content

Commit

Permalink
add enrolledUsers in Offer (#628)
Browse files Browse the repository at this point in the history
  • Loading branch information
MariaAfonina authored Nov 15, 2023
1 parent 8407875 commit 856adf3
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 26 deletions.
9 changes: 9 additions & 0 deletions docs/offer/offer-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ definitions:
author:
type: string
ref: '#components/user'
enrolledUsers:
type: array
ref: '#components/user'
subject:
type: string
ref: '#components/subject'
Expand Down Expand Up @@ -104,6 +107,9 @@ definitions:
- Arabic
authorRole:
type: string
enrolledUsers:
type: array
ref: '#components/user'
subject:
type: string
ref: '#components/subject'
Expand Down Expand Up @@ -164,6 +170,9 @@ definitions:
author:
type: string
ref: '#components/user'
enrolledUsers:
type: array
ref: '#components/user'
subject:
type: string
ref: '#components/subject'
Expand Down
34 changes: 9 additions & 25 deletions docs/offer/offer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ paths:
title: this is a new title for test purposes
description: this is a new description for test purposes
languages: [English]
enrolledUsers: [6512e1ca5fd987b6ce926c2e]
authorRole: tutor
authorFirstName: Amanda
authorLastName: Smith
Expand All @@ -96,29 +97,22 @@ paths:
totalReviews:
student: 0
tutor: 0
FAQ: {
question: tutor question,
_id: 63525e23bf163f5ea609ff2b,
answer: tutor answer
}
FAQ: { question: tutor question, _id: 63525e23bf163f5ea609ff2b, answer: tutor answer }
professionalSummary: My professional summary
photo: link-to-photo.png
subject:
_id: 63da8767c9ad4c9a0b0eacd3
name: english
category: 63525e23bf163f5ea609ff2b
chatId: '64be59667f4136e211435a55'
FAQ: {
question: offer question,
_id: 63525e23bf163f5ea609ff2b,
answer: offer answer
}
FAQ: { question: offer question, _id: 63525e23bf163f5ea609ff2b, answer: offer answer }
- _id: 63ebc6fbd2f34037d0aba791
price: 300
proficiencyLevel: [Intermediate, Advanced]
title: this is a new title for test purposes
description: Lorem ipsum dolor sit amet consectetur
languages: [English, Ukrainian]
enrolledUsers: [6512e1ca5fd987b6ce926c2e]
authorRole: tutor
authorFirstName: John
authorLastName: Smith
Expand Down Expand Up @@ -200,11 +194,7 @@ paths:
subject: 63da8767c9ad4c9a0b0eacd3
category: 63525e23bf163f5ea609ff2b
status: pending
FAQ: {
question: tutor question,
_id: 63525e23bf163f5ea609ff2b,
answer: tutor answer
}
FAQ: { question: tutor question, _id: 63525e23bf163f5ea609ff2b, answer: tutor answer }
_id: 63ec1cd51e9d781cdb6f4b14
createdAt: 2023-02-14T23:44:21.334Z
updatedAt: 2023-02-14T23:44:21.334Z
Expand Down Expand Up @@ -258,6 +248,7 @@ paths:
title: this is a new title for test purposes
description: Lorem ipsum dolor sit amet consectetur
languages: [English, Ukrainian]
enrolledUsers: [6512e1ca5fd987b6ce926c2e]
authorRole: tutor
authorFirstName: John
authorLastName: Smith
Expand All @@ -267,23 +258,15 @@ paths:
totalReviews:
student: 0
tutor: 0
FAQ: {
question: tutor question,
_id: 63525e23bf163f5ea609ff2b,
answer: tutor answer
}
FAQ: { question: tutor question, _id: 63525e23bf163f5ea609ff2b, answer: tutor answer }
professionalSummary: My professional summary
photo: link-to-photo.png
subject:
_id: 63da8767c9ad4c9a0b0eacd3
name: piano
category: 63525e23bf163f5ea609ff2b
chatId: '64be59667f4136e211435a55'
FAQ: {
question: tutor question,
_id: 63525e23bf163f5ea609ff2b,
answer: tutor answer
}
FAQ: { question: tutor question, _id: 63525e23bf163f5ea609ff2b, answer: tutor answer }
createdAt: 2023-02-14T23:44:21.334Z
updatedAt: 2023-02-14T23:44:21.334Z
400:
Expand Down Expand Up @@ -364,6 +347,7 @@ paths:
title: this is a new title for test purposes
description: this is a test text 123
languages: [Ukrainian, Polish]
enrolledUsers: [6512e1ca5fd987b6ce926c2e]
subjectId: 63da8767c9ad4c9a0b0eacd3
categoryId: 63525e23bf163f5ea609ff2b
responses:
Expand Down
5 changes: 5 additions & 0 deletions models/offer.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ const offerSchema = new Schema(
ref: USER,
required: true
},
enrolledUsers: {
type: [Schema.Types.ObjectId],
ref: USER,
required: false
},
subject: {
type: Schema.Types.ObjectId,
ref: SUBJECT,
Expand Down
4 changes: 3 additions & 1 deletion services/offer.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ const offerService = {
},

createOffer: async (author, authorRole, data) => {
const { price, proficiencyLevel, title, description, languages, subject, category, status, FAQ } = data
const { price, proficiencyLevel, title, description, languages, enrolledUsers, subject, category, status, FAQ } =
data

return await Offer.create({
author,
Expand All @@ -83,6 +84,7 @@ const offerService = {
title,
description,
languages,
enrolledUsers,
subject,
category,
status,
Expand Down
2 changes: 2 additions & 0 deletions test/integration/controllers/offer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ let testOffer = {
FAQ: [{ question: 'question1', answer: 'answer1' }],
description: 'TEST 123ASD',
languages: ['Ukrainian'],
enrolledUsers: ['6512e1ca5fd987b6ce926c2e', '652ba66bf6770c3a2d5d8549'],
subject: '',
category: {
_id: '',
Expand Down Expand Up @@ -87,6 +88,7 @@ describe('Offer controller', () => {
subject,
category,
status: 'active',
enrolledUsers: expect.any(Array),
createdAt: expect.any(String),
updatedAt: expect.any(String)
})
Expand Down

0 comments on commit 856adf3

Please sign in to comment.