You are here:  » Email alert for incomplete imports


Email alert for incomplete imports

Submitted by Convergence on Tue, 2013-04-09 17:14 in

Greetings,

From time to time, due to human error, we will modify filters on a feed and do so incorrectly. When one of the filters is formatted wrong or blank, the slow_import process via CRON will stop at that feed and not process the remaining feeds registered or re-registered after the feed with the bad filter.

This leaves the "products_import" table sitting there, incomplete.

Is there a way we can get an email alert if the slow_import CRON does not complete, example: the "products" table does not get deleted and the "products_import" does not get renamed to "products"?

Thanks!

Submitted by support on Wed, 2013-04-10 07:34

Hi,

Incorrect filter configuration shouldn't stop the import at all - if you could identify an example that does cause the slow import process to stop I'll check that out!

To obtain an email alert, one thing to do would be to see if products_import exists after CRON has run, which the following script, saved as scripts/alert.php will do:

<?php
  
require("../includes/common.php");
  
$sql "SELECT id FROM `".$config_databaseTablePrefix."products_import` LIMIT 1";
  if (
database_querySelect($sql,$rows))
  {
    
mail("you@example.com","Alert Subject","Alert Message");
  }
?>

This can be chained along with your existing CRON job using a semi-colon- which will ensure that it runs immediately following the import command, even if that aborts. For example, if your current CRON job is

wget http://www.example.com/scripts/import_slow.php

...then use:

wget http://www.example.com/scripts/import_slow.php;wget http://www.example.com/scripts/alert.php

Cheers,
David.
--
PriceTapestry.com

Submitted by Convergence on Wed, 2013-04-10 15:26

Hi David,

Examples:

1) Most recent: "Drop Record If Not RegExp" - had added another term at the end of the string (term1|term2|term3) and by accident had done this: (term1|term2|term3)) Two closing parentheses.

2) Also occurred: If the rule is blank, say one adds a new filter type and field, but forgets to fill in the field. Usually with the Drop record / or Drop record RegExp (and also "If Not".

Both these examples will stop that current feed in it's tracks and all feeds to follow.

Submitted by support on Wed, 2013-04-10 19:40

Hi,

Ah - that would be because of an invalid regular expression; so one thing to do would be to check that the expression is valid when saving the filter. To do this, first for "Drop Record RegExp", look for the following code at line 205:

  function filter_dropRecordRegExpValidate($filter_data)
  {
  }

...and REPLACE with:

  function filter_dropRecordRegExpValidate($filter_data)
  {
    if (@preg_match($filter_data["text"],"TEST")===FALSE)
    {
      widget_errorSet("text","invalid regular expression");
    }
  }

And for "Drop Record If Not RegExp", look for the following code at line 277:

  function filter_dropRecordIfNotRegExpValidate($filter_data)
  {
  }

...and REPLACE with:

  function filter_dropRecordIfNotRegExpValidate($filter_data)
  {
    if (@preg_match($filter_data["text"],"TEST")===FALSE)
    {
      widget_errorSet("text","invalid regular expression");
    }
  }

Cheers,
David.
--
PriceTapestry.com