Wednesday, 5 December 2018

Nifty improved - Yaay! Dependence on YQL removed!

✅ You might notice an improvement in using the Nifty Promo Control Panel, especially if using filters.



I'm happy to say that I've been able to remove the use of YQL in the Nifty Promo Control Panels and its tools.

The only exception is in two of the widgets, the (live) Product Grid and the Slideshow (which is also 'live'). The term 'live' means that the contents are pulled from Zazzle when a visitor lands on a page using them. The alternative used by the others is a static set of products, set in stone when you first make the widget.

My code was using a service called YQL to do the pulling from Zazzle and a drawback with YQL is that it has a 5 second timeout. I found the timeout was often kicking in when using filters or if Zazzle was being a little slow to respond to "pull requests".

I've now rewritten that part of the code, so YQL isn't being used anymore. It only took 4 days 🤪 to find out how and get it right! I really am a 🙇‍♂️ coding klutz, hehe!

Here's a screenshot of the control panel with settings to filter out products with christmas, chinese or wedding in titles, descriptions or tags, shown, with a search for new years (not in screenshot):




http://www.kdl.to/nifty-slideshows.html?qs=new+years&storeid=&dp=252771842883420464&cg=&ps=50&pg=1&pm=&tc=nnslsh&tcschd=nnschdlr&trm1=christmas&trm2=chinese&trm3=wedding&fttls=1&fdscs=1&ftags=1
click / tap the image to try the filters as shown



-----------------------------

🤓 geeky bit...

The reason the timeout was sometimes kicking in when using filters is that the code:
  • ⏳ does a pull
  • ⏳ removes products matching any of the filters
  • ⏳ repeats the above until the requested page size (of products) is obtained.
and has to complete within 5 seconds.

Of course, more 'pulls' are required if there are lots of products matching any of the filters - and if there's too many pulls, eventually the timeout kicks in.