refactor(backend): Linting
This commit is contained in:
		
							parent
							
								
									f537830b15
								
							
						
					
					
						commit
						2dbadc7eab
					
				
					 3 changed files with 20 additions and 9 deletions
				
			
		|  | @ -66,12 +66,13 @@ async function fetchLearningObjects(learningPathId: LearningPathIdentifier, full | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         const objects = await Promise.all( |         const objects = await Promise.all( | ||||||
|             nodes.map(async (node) => |             nodes.map(async (node) => { | ||||||
|                 dwengoApiLearningObjectProvider.getLearningObjectById({ |                 const learningObjectId: LearningObjectIdentifier = { | ||||||
|                     hruid: node.learningobject_hruid, |                     hruid: node.learningobject_hruid, | ||||||
|                     language: learningPathId.language, |                     language: learningPathId.language | ||||||
|                 }) |                 }; | ||||||
|             ) |                 return dwengoApiLearningObjectProvider.getLearningObjectById(learningObjectId); | ||||||
|  |             }) | ||||||
|         ); |         ); | ||||||
|         return objects.filter((obj): obj is FilteredLearningObject => obj !== null); |         return objects.filter((obj): obj is FilteredLearningObject => obj !== null); | ||||||
|     } catch (error) { |     } catch (error) { | ||||||
|  |  | ||||||
|  | @ -75,9 +75,14 @@ export async function createQuestion(questionDTO: QuestionDTO): Promise<Question | ||||||
| 
 | 
 | ||||||
|     const author = mapToStudent(questionDTO.author); |     const author = mapToStudent(questionDTO.author); | ||||||
| 
 | 
 | ||||||
|  |     const loId: LearningObjectIdentifier = { | ||||||
|  |         ...questionDTO.learningObjectIdentifier, | ||||||
|  |         version: questionDTO.learningObjectIdentifier.version ?? 1, | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     try { |     try { | ||||||
|         await questionRepository.createQuestion({ |         await questionRepository.createQuestion({ | ||||||
|             loId: questionDTO.learningObjectIdentifier, |             loId, | ||||||
|             author, |             author, | ||||||
|             content: questionDTO.content, |             content: questionDTO.content, | ||||||
|         }); |         }); | ||||||
|  | @ -97,8 +102,13 @@ export async function deleteQuestion(questionId: QuestionId): Promise<QuestionDT | ||||||
|         return null; |         return null; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     const loId : LearningObjectIdentifier = { | ||||||
|  |         ...questionId.learningObjectIdentifier, | ||||||
|  |         version: questionId.learningObjectIdentifier.version ?? 1 | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     try { |     try { | ||||||
|         await questionRepository.removeQuestionByLearningObjectAndSequenceNumber(questionId.learningObjectIdentifier, questionId.sequenceNumber); |         await questionRepository.removeQuestionByLearningObjectAndSequenceNumber(loId, questionId.sequenceNumber); | ||||||
|     } catch (_) { |     } catch (_) { | ||||||
|         return null; |         return null; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | @ -37,7 +37,7 @@ describe('DatabaseLearningObjectProvider', () => { | ||||||
|         it('should return the learning object when it is queried by its id', async () => { |         it('should return the learning object when it is queried by its id', async () => { | ||||||
|             const result: FilteredLearningObject | null = await databaseLearningObjectProvider.getLearningObjectById(exampleLearningObject); |             const result: FilteredLearningObject | null = await databaseLearningObjectProvider.getLearningObjectById(exampleLearningObject); | ||||||
|             expect(result).toBeTruthy(); |             expect(result).toBeTruthy(); | ||||||
|             expectToBeCorrectFilteredLearningObject(result!, exampleLearningObject); |             expectToBeCorrectFilteredLearningObject(result, exampleLearningObject); | ||||||
|         }); |         }); | ||||||
| 
 | 
 | ||||||
|         it('should return the learning object when it is queried by only hruid and language (but not version)', async () => { |         it('should return the learning object when it is queried by only hruid and language (but not version)', async () => { | ||||||
|  | @ -46,7 +46,7 @@ describe('DatabaseLearningObjectProvider', () => { | ||||||
|                 language: exampleLearningObject.language, |                 language: exampleLearningObject.language, | ||||||
|             }); |             }); | ||||||
|             expect(result).toBeTruthy(); |             expect(result).toBeTruthy(); | ||||||
|             expectToBeCorrectFilteredLearningObject(result!, exampleLearningObject); |             expectToBeCorrectFilteredLearningObject(result, exampleLearningObject); | ||||||
|         }); |         }); | ||||||
| 
 | 
 | ||||||
|         it('should return null when queried with an id that does not exist', async () => { |         it('should return null when queried with an id that does not exist', async () => { | ||||||
|  |  | ||||||
		Reference in a new issue