Skip to content

Commit

Permalink
Updated comments and names
Browse files Browse the repository at this point in the history
  • Loading branch information
cremertim committed Jan 17, 2025
1 parent 2a88697 commit d0cbf6d
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import de.tum.cit.aet.artemis.core.security.annotations.enforceRoleInCourse.EnforceAtLeastTutorInCourse;
import de.tum.cit.aet.artemis.core.service.AuthorizationCheckService;
import de.tum.cit.aet.artemis.core.util.HeaderUtil;
import de.tum.cit.aet.artemis.iris.service.settings.IrisSettingsService;

/**
* REST controller for managing Faqs.
Expand All @@ -65,8 +64,7 @@ public class FaqResource {

private final FaqService faqService;

public FaqResource(CourseRepository courseRepository, AuthorizationCheckService authCheckService, FaqRepository faqRepository, FaqService faqService,
Optional<IrisSettingsService> irisSettingsService) {
public FaqResource(CourseRepository courseRepository, AuthorizationCheckService authCheckService, FaqRepository faqRepository, FaqService faqService) {
this.faqRepository = faqRepository;
this.courseRepository = courseRepository;
this.authCheckService = authCheckService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public boolean getAutoIngestOnFaqCreation() {
return autoIngestOnFaqCreation;
}

public void setAutoIngestOnFaqCreation(boolean autoIngestOnLectureAttachmentUpload) {
this.autoIngestOnFaqCreation = autoIngestOnLectureAttachmentUpload;
public void setAutoIngestOnFaqCreation(boolean autoIngestOnFaqCreation) {
this.autoIngestOnFaqCreation = autoIngestOnFaqCreation;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public void executeFaqDeletionWebhook(PyrisWebhookFaqDeletionExecutionDTO execut
}

/**
* Retrieves the ingestion state of the lecture unit specified by retrieving the ingestion state from the vector database in Pyris.
* Retrieves the ingestion state of the faq specified by retrieving the ingestion state from the vector database in Pyris.
*
* @param courseId id of the course
* @return The ingestion state of the faq
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ public String addLectureIngestionWebhookJob(long courseId, long lectureId, long
public String addFaqIngestionWebhookJob(long courseId, long faqId) {
var token = generateJobIdToken();
var job = new FaqIngestionWebhookJob(token, courseId, faqId);
jobMap.put(token, job);
long timeoutWebhookJob = 60;
TimeUnit unitWebhookJob = TimeUnit.MINUTES;
jobMap.put(token, job, timeoutWebhookJob, unitWebhookJob);
return token;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public void handleStatusUpdate(LectureIngestionWebhookJob job, PyrisLectureInges
}

/**
* Handles the status update of a lecture ingestion job.
* Handles the status update of a FAQ ingestion job.
*
* @param job the job that is updated
* @param statusUpdate the status update
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ private boolean faqIngestionEnabled(Course course) {
}

/**
* send the updated / created attachment to Pyris for ingestion if autoLecturesUpdate is enabled
* send the updated / created faqs to Pyris for ingestion if autoLecturesUpdate is enabled
*
* @param courseId Id of the course where the attachment is added
* @param newFaq the new faqs to be sent to pyris for ingestion
Expand All @@ -265,7 +265,7 @@ public void autoUpdateFaqInPyris(Long courseId, Faq newFaq) {
}

/**
* adds the lectures to the vector database in Pyris
* adds the faq to the vector database in Pyris
*
* @param faq The faq that got Updated
* @return jobToken if the job was created else null
Expand All @@ -278,6 +278,13 @@ public String addFaqToPyris(Faq faq) {
return null;
}

/**
* executes the faq addition webhook to add faq to the vector database on pyris
*
* @param toUpdateFaq The faq that got Updated as webhook DTO
* @return jobToken if the job was created else null
*/

private String executeFaqAdditionWebhook(PyrisFaqWebhookDTO toUpdateFaq) {
String jobToken = pyrisJobService.addFaqIngestionWebhookJob(toUpdateFaq.courseId(), toUpdateFaq.faqId());
PyrisPipelineExecutionSettingsDTO settingsDTO = new PyrisPipelineExecutionSettingsDTO(jobToken, List.of(), artemisBaseUrl);
Expand All @@ -299,6 +306,12 @@ public String deleteFaqFromPyrisDB(Faq faq) {

}

/**
* executes the faq deletion webhook to delete faq from the vector database on pyris
*
* @param toUpdateFaqs The faq that got Updated as webhook DTO
* @return jobToken if the job was created else null
*/
private String executeFaqDeletionWebhook(PyrisFaqWebhookDTO toUpdateFaqs) {
String jobToken = pyrisJobService.addFaqIngestionWebhookJob(0, 0);
PyrisPipelineExecutionSettingsDTO settingsDTO = new PyrisPipelineExecutionSettingsDTO(jobToken, List.of(), artemisBaseUrl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

/**
* Represents a webhook data transfer object for an FAQ in the Pyris system.
* This DTO is used to encapsulate the information related to updates of lecture units,
* providing necessary details such as lecture and course identifiers, names, and descriptions.
* This DTO is used to encapsulate the information related to the faqs
* providing necessary details such as faqId the content as questionTitle and questionAnswer as well as the course description.
*/
@JsonInclude(JsonInclude.Include.NON_EMPTY)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,23 @@ private void initializeIrisCompetencyGenerationSettings(IrisGlobalSettings setti
settings.setIrisCompetencyGenerationSettings(irisCompetencyGenerationSettings);
}

/**
* Get the combined Iris settings for a course.
* Combines the global settings with the course settings.
*
* @return The combined Iris settings for the course
*/
public IrisGlobalSettings getGlobalSettings() {
return irisSettingsRepository.findGlobalSettingsElseThrow();
}

/**
* Get the combined Iris settings for a course.
* Combines the global settings with the course settings.
*
* @param settings The course settings
* @return The combined Iris settings for the course
*/
private void initializeIrisFaqIngestionSettings(IrisGlobalSettings settings) {
var irisFaqIngestionSubSettings = settings.getIrisFaqIngestionSettings();
irisFaqIngestionSubSettings = initializeSettings(irisFaqIngestionSubSettings, IrisFaqIngestionSubSettings::new);
Expand Down Expand Up @@ -606,7 +619,7 @@ public IrisCombinedSettingsDTO getCombinedIrisGlobalSettings() {
irisSubSettingsService.combineCourseChatSettings(settingsList, false),
irisSubSettingsService.combineLectureIngestionSubSettings(settingsList, false),
irisSubSettingsService.combineCompetencyGenerationSettings(settingsList, false),
irisSubSettingsService.combinceFaqIngestionSubSettings(settingsList, false)
irisSubSettingsService.combineFaqIngestionSubSettings(settingsList, false)
);
// @formatter:on
}
Expand All @@ -633,7 +646,7 @@ public IrisCombinedSettingsDTO getCombinedIrisSettingsFor(Course course, boolean
irisSubSettingsService.combineCourseChatSettings(settingsList, minimal),
irisSubSettingsService.combineLectureIngestionSubSettings(settingsList, minimal),
irisSubSettingsService.combineCompetencyGenerationSettings(settingsList, minimal),
irisSubSettingsService.combinceFaqIngestionSubSettings(settingsList, minimal)
irisSubSettingsService.combineFaqIngestionSubSettings(settingsList, minimal)
);
// @formatter:on
}
Expand Down Expand Up @@ -661,7 +674,7 @@ public IrisCombinedSettingsDTO getCombinedIrisSettingsFor(Exercise exercise, boo
irisSubSettingsService.combineCourseChatSettings(settingsList, minimal),
irisSubSettingsService.combineLectureIngestionSubSettings(settingsList, minimal),
irisSubSettingsService.combineCompetencyGenerationSettings(settingsList, minimal),
irisSubSettingsService.combinceFaqIngestionSubSettings(settingsList, minimal)
irisSubSettingsService.combineFaqIngestionSubSettings(settingsList, minimal)
);
// @formatter:on
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,15 +368,15 @@ public IrisCombinedLectureIngestionSubSettingsDTO combineLectureIngestionSubSett
}

/**
* Combines the Lecture Ingestion settings of multiple {@link IrisSettings} objects.
* Combines the FAQ Ingestion settings of multiple {@link IrisSettings} objects.
* If minimal is true, the returned object will only contain the enabled and rateLimit fields.
* The minimal version can safely be sent to students.
*
* @param settingsList List of {@link IrisSettings} objects to combine.
* @param minimal Whether to return a minimal version of the combined settings.
* @return Combined Lecture Ingestion settings.
*/
public IrisCombinedFaqIngestionSubSettingsDTO combinceFaqIngestionSubSettings(ArrayList<IrisSettings> settingsList, boolean minimal) {
public IrisCombinedFaqIngestionSubSettingsDTO combineFaqIngestionSubSettings(ArrayList<IrisSettings> settingsList, boolean minimal) {
var enabled = getCombinedEnabled(settingsList, IrisSettings::getIrisFaqIngestionSettings);
return new IrisCombinedFaqIngestionSubSettingsDTO(enabled);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ describe('FaqComponent', () => {
expect(faq1.faqState).toEqual(FaqState.PROPOSED);
});

it('should call the service to ingest lectures when ingestLecturesInPyris is called', () => {
it('should call the service to ingest faqs when ingestFaqsInPyris is called', () => {
faqComponent.faqs = [faq1];
const ingestSpy = jest.spyOn(faqService, 'ingestFaqsInPyris').mockImplementation(() => of(new HttpResponse<void>({ status: 200 })));
faqComponent.ingestFaqsInPyris();
Expand Down
2 changes: 1 addition & 1 deletion src/test/javascript/spec/service/faq.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ describe('Faq Service', () => {
expect(service.hasSearchTokens(faq1, 'title answer missing')).toBeFalse();
});

it('should send a POST request to ingest lectures and return an OK response', () => {
it('should send a POST request to ingest faqs and return an OK response', () => {
const courseId = 123;
const expectedUrl = `api/courses/${courseId}/faqs/ingest`;
const expectedStatus = 200;
Expand Down

0 comments on commit d0cbf6d

Please sign in to comment.