Add Scrape History #15

Merged
SoXX merged 8 commits from dev/scrape-history into main 2024-10-15 10:46:41 +00:00
Showing only changes of commit ef31399ab6 - Show all commits

View File

@ -40,6 +40,14 @@ func CreateScrapeHistory(ctx context.Context, scrapeHistory models.ScrapeHistory
return models.ScrapeHistory{}, utils.HandleError(ctx, span, localLogger, &otterError.EntityValidationFailed{Reason: otterError.ScrapeTaskIDIsWrongLength})
}
Alphyron marked this conversation as resolved
Review

UserSourceID validation is missing

UserSourceID validation is missing
if len(scrapeHistory.UserSourceID) == 0 {
return models.ScrapeHistory{}, utils.HandleError(ctx, span, localLogger, &otterError.EntityValidationFailed{Reason: otterError.UserSourceIDIsEmpty})
}
if len(scrapeHistory.UserSourceID) != 25 {
return models.ScrapeHistory{}, utils.HandleError(ctx, span, localLogger, &otterError.EntityValidationFailed{Reason: otterError.UserSourceIsWrongLength})
}
result := client.WithContext(ctx).Create(&scrapeHistory)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrDuplicatedKey) {