Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOJ-120: Adding form queue handler. #78

Closed
wants to merge 5 commits into from
Closed

DOJ-120: Adding form queue handler. #78

wants to merge 5 commits into from

Conversation

Tom-Camp
Copy link
Contributor

@Tom-Camp Tom-Camp commented Oct 2, 2017

No description provided.

* {@inheritdoc}
*/
public function sendMessage(WebformSubmissionInterface $webform_submission, array $message) {
// @var @var QueueFactory $queue_factory
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is @var in here twice on purpose?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No

$queue_factory = \Drupal::service('queue');

// @var QueueInterface $queue
$queue = $queue_factory->get('foia_queue_submissions');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe call this something like foia_submissions_queue or just foia_submissions. The current name sounds kind of like an action.


// Log the form submission.
\Drupal::logger('foia_webform')
->info('FOIA form submission added to queue.', ['link' => $webform_submission->toLink($this->t('View'))->toString()]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good thought to log this. Slipped my mind. Mind adding the submission ID to the log message?

/**
* Provides base functionality for the FoiaForm Queue Workers.
*/
abstract class FoiaFormQueue extends QueueWorkerBase implements ContainerFactoryPluginInterface {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should give the worker a similarly formatted name? e.g. FoiaSubmissionQueueWorker

$queue_factory = \Drupal::service('queue');

// @var QueueInterface $queue
$foia_submission_queue = $queue_factory->get('foia_form_manual_submitter');
Copy link
Contributor

@malikkotob malikkotob Oct 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that a queue can be described as a submitter. We might call the worker class a submitter if its submitting the items that it's processing, but the queue itself should probably just be named to describe its contents (e.g. submission, submissions, foia_submission, foia_submissions etc.). That was something I didn't agree with on the sitepoint write up

// @var QueueInterface $queue
$foia_submission_queue = $queue_factory->get('foia_form_manual_submitter');
$submission = new \stdClass();
$submission->sid = $webform_submission->id();;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra semicolon here

\Drupal::logger('foia_webform')
->info('FOIA form submission #%sid added to queue.',
[
'%sid' => $webform_submission->id(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

/**
* Provides base functionality for the FoiaForm Queue Workers.
*/
abstract class FoiaSubmissionQueueWorker extends QueueWorkerBase implements ContainerFactoryPluginInterface {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we're only planning on having a single queue worker (we don't plan on leveraging Drupal's built in Cron system, so we won't have a manual vs cron worker) I'm not sure there is added value in implementing this as an abstract class. I'm thinking we can just have this as our concrete worker (i.e. let's add the @QueueWorker annotation here)

*
* @var \Drupal\webform\WebformSubmissionInterface
*/
protected $formSubmission;
Copy link
Contributor

@malikkotob malikkotob Oct 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this not an instance of WebformSubmissionStorageInterface? See WebformSubmissionLogController.php. Maybe this should be:

  /**
   * The webform submission storage.
   *
   * @var \Drupal\webform\WebformSubmissionStorageInterface
   */
  protected $webformSubmissionStorage;

/**
* {@inheritdoc}
*/
public function __construct(WebformSubmissionInterface $submission) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment here - think this should be WebformSubmissionStorageInterface $webformSubmissionStorage

}

/**
* Adds the submission to the foia_form_manual_submitter queue.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment needs to be cleaned up to reference the right queue name. Or you can keep it generic and say that the submission is added to a queue - whatever your prefer!

* title = @Translation("Manual FOIA Form submitter"),
* )
*/
class FoiaSubmissionQueueWorker extends QueueWorker {}
Copy link
Contributor

@malikkotob malikkotob Oct 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You had this right previously - must've been a typo, but this should extend QueueWorkerBase.

Actually, this must've gotten lost in our communications. This should still have a constructor that instantiates the webform_submission storage.

@malikkotob
Copy link
Contributor

Covered by #79, which was merged.

@malikkotob malikkotob closed this Oct 4, 2017
brockfanning pushed a commit to brockfanning/foia-api that referenced this pull request Sep 26, 2019
…on annual_foia_report_data. (usdoj#78)

* FOIA-37: Removes total_annual_data content type.

* FOIA-37: Updates paragraph reference and continues to polish tabbing on annual_foia_report_data.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants