-
Notifications
You must be signed in to change notification settings - Fork 30
send a notification on crawler success/failure #421
base: master
Are you sure you want to change the base?
Conversation
) { | ||
parent::__construct($projectRepository, $logger); | ||
$this->repoCrawlerRegistry = $repoCrawlerFactory; | ||
$this->entityManager = $entityManager; | ||
$this->notificationCreator = $notificationCreatorService; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use consistent naming: call the member variable notificationCreatorService as well.
@@ -90,6 +117,21 @@ protected function processProject(Project $project) : bool | |||
// Ignore -- we're already in the error handling path. | |||
// The project will most likely remain in the "in processing" | |||
// state. | |||
// Send a notification that the project cannot be processed | |||
$users = new ArrayCollection(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not simply an array?
->setType("crawler_success") | ||
->setRecipient($user); | ||
$this->notificationCreator->createNotification($notification); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only send a notification in case of a failure.
} else { | ||
$users->add($project->getParentUser()); | ||
} | ||
foreach ($users as $user) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about adding a helper function to the NotificationCreatorService class, e.g. notifyProjectOwners($project, $notification)
, that wraps this functionality?
foreach ($users as $user) { | ||
$notification = new Notification(); | ||
$notification->setSubject("Crawler Failure") | ||
->setMessage("Our RepoCrawler has failed to fetch metrics for your project") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Users will get this message without knowing how exactly LibreCores processes their data. They also want to have information on how to fix the problem. To do so, (a) give as much information as possible; include potential error messages we get, (b) include a way to fix the problem (e.g. fix repository permissions in GitHub), and (c) don't use any jargon. "Our RepoCrawler" for example isn't helpful, "On LibreCores, we regularly update your project listing with the latest data from your GitHub repository at github.com/asdf/asdf. Unfortunately, the last time we tried, we encountered this error: xxx. To fix this error, you can xzy"
4ea38ec
to
68e81af
Compare
For #419