Support from Acquia helps fund testing for Drupal Acquia logo

Comments

AjitS created an issue. See original summary.

AjitS’s picture

Assigned: Unassigned » AjitS
Priority: Normal » Critical
Sharique’s picture

Status: Active » Needs review
FileSize
6.59 KB

Status: Needs review » Needs work

The last submitted patch, 3: remove_hook_queue_info-2610834-3.patch, failed testing.

The last submitted patch, 3: remove_hook_queue_info-2610834-3.patch, failed testing.

piyuesh23’s picture

Sharique’s picture

Status: Needs work » Needs review

triggering test.

naveenvalecha’s picture

Title: Remove hook_queue_info and implement the Queue entity » Remove hook_queue_info and add Queue Worker Plugin

reupdating the title.hope this would be better.

Sharique’s picture

FileSize
8.38 KB

Here is updated patch, the patch also some code formatting corrections in module file.

Sharique’s picture

Assigned: AjitS » Sharique
FileSize
9.95 KB

Updated patch to fix error during cron run.

dhruveshdtripathi’s picture

AjitS’s picture

Status: Needs review » Needs work
  1. +++ b/social_stats.module
    @@ -21,49 +21,40 @@ function social_stats_help($route_name, RouteMatchInterface $route_match) {
    +        $variable['twitter'] ||
    

    We are not supporting Twitter anymore, since it stopped providing the stats. This should be removed.

  2. +++ b/social_stats.module
    @@ -164,8 +155,7 @@ function _social_stats_googleplus_plusone($node_path) {
    +  } catch (RequestException $e) {
    

    This change is not required.

  3. +++ b/social_stats.module
    @@ -199,8 +189,7 @@ function _social_stats_googleplus_share($node_path) {
    +  } catch (RequestException $e) {
    

    This was correct earlier.

  4. +++ b/src/Plugin/QueueWorker/SocialStatsUpdator.php
    @@ -0,0 +1,81 @@
    +use Drupal\social_stats\SocialStatsTwitterManager;
    

    Should be removed.

  5. +++ b/src/Plugin/QueueWorker/SocialStatsUpdator.php
    @@ -0,0 +1,81 @@
    +    $twitter_total = 0;
    

    Should be removed.

  6. +++ b/src/Plugin/QueueWorker/SocialStatsUpdator.php
    @@ -0,0 +1,81 @@
    +    // Getting data from Twitter for nodes of selected node type.
    +    if ($variable['twitter']) {
    +      $twitter_baseurl = 'http://urls.api.twitter.com/1/urls/count.json';
    +      $TwitterStatsManager = new SocialStatsTwitterManager($twitter_baseurl, $node_path, $result->nid, 'get');
    +      $twitter_total = $TwitterStatsManager->execute();
    +    }
    

    Should be removed.

  7. +++ b/src/Plugin/QueueWorker/SocialStatsUpdator.php
    @@ -0,0 +1,81 @@
    +    $count_total = $facebook_total + $twitter_total;
    +    $count_total += $linkedin_total + $google_plusone;
    

    $twitter_total should be removed.
    This could just be replaced by

    $count_total = $facebook_total + $linkedin_total + $google_plusone;
    
Sharique’s picture

Status: Needs work » Needs review
FileSize
8.96 KB

Removed twitter code, fixed coding standard issue.

naveenvalecha’s picture

Assigned: dhruveshdtripathi » Unassigned
Priority: Critical » Major
Status: Needs review » Needs work

interdiff please next time
https://www.drupal.org/documentation/git/interdiff

  1. +++ b/social_stats.module
    @@ -21,49 +21,39 @@ function social_stats_help($route_name, RouteMatchInterface $route_match) {
    +  $cron_settings = \Drupal::config('social_stats.cron_settings');
    

    call an getEditable object at first place and then reuse it when you will save it. instead of calling the method again and again.

  2. +++ b/social_stats.module
    @@ -21,49 +21,39 @@ function social_stats_help($route_name, RouteMatchInterface $route_match) {
    +  if (time() >= $cron_settings->get('next_execution', 0)) {
    

    use REQUEST_TIME https://api.drupal.org/api/drupal/core%21includes%21bootstrap.inc/consta...

  3. +++ b/src/Plugin/QueueWorker/SocialStatsUpdator.php
    @@ -0,0 +1,71 @@
    +class SocialStatsUpdator extends QueueWorkerBase {
    

    SocialStatusUpdates sounds better name. leaving this for module maintainer what he reckons here ?

  4. +++ b/src/Plugin/QueueWorker/SocialStatsUpdator.php
    @@ -0,0 +1,71 @@
    +    $variable = unserialize(\Drupal::config('social_stats.settings')
    

    Inject the configFactory service here. See how to in LocaleTranslation queue worker https://api.drupal.org/api/drupal/core%21modules%21locale%21src%21Plugin...

  5. +++ b/src/Plugin/QueueWorker/SocialStatsUpdator.php
    @@ -0,0 +1,71 @@
    +    $config = $this->configFactory->get('social_stats.cron_settings');
    

    how have you used the ConfigFactory here ?

  6. +++ b/src/Plugin/QueueWorker/SocialStatsUpdator.php
    @@ -0,0 +1,71 @@
    +      $connection = Database::getConnection();
    

    inject the connection service here.

Sharique’s picture

Status: Needs work » Needs review
FileSize
9.09 KB
2.14 KB

@Naveen didn't understand what your are trying to say in 4.
Here is update patch. and interdiff too.

naveenvalecha’s picture

Status: Needs review » Needs work

#15 see below.

  1. +++ b/src/Plugin/QueueWorker/SocialStatsUpdator.php
    @@ -0,0 +1,72 @@
    +    $config = \Drupal::config('social_stats.cron_settings');
    

    use DI to inject the config factory.

  2. +++ b/src/Plugin/QueueWorker/SocialStatsUpdator.php
    @@ -0,0 +1,72 @@
    +      $connection = \Drupal::database();
    

    use DI to inject the connection service.

Sharique’s picture

@Naveen For database this was mention here https://www.drupal.org/node/2133171, similarly core has provided helper function for config also, please provide the link for which way your talking about.

naveenvalecha’s picture

Status: Needs work » Needs review
FileSize
10.72 KB
3.59 KB

Addressed #16.
#17, See interdiff

naveenvalecha’s picture

Status: Needs review » Reviewed & tested by the community

Let's do it.
The whole code is of sharique and I only inject the services. So doing RTBC it :)

+++ b/src/Plugin/QueueWorker/SocialStatsUpdator.php
@@ -0,0 +1,121 @@
+    $url_root = $config->get('social_stats_url_root', $base_url);

only question why are we passing another argument here ?
As per function defination it only takes one argument ?
have you handled any special case ? if not then remove this second $base_url argument.
It can be taken care at commit.

  • Sharique committed 1235b97 on 8.x-1.x
    Issue #2610834 by Sharique, naveenvalecha, AjitS: Remove hook_queue_info...
Sharique’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.