A
A
atis //2016-05-10 14:43:03
PHP
atis //, 2016-05-10 14:43:03

What pattern to use when designing multiple search?

Hello.
I am writing a search engine that will search for products in several databases and return the search result. The trick is that product catalogs have different fields (that's right!), but as a result, you need to display everything in the same structure. Sql queries are useless, they have nothing to do with it.
Help is needed only in choosing a pattern.

Answer the question

In order to leave comments, you need to log in

6 answer(s)
A
Alexey Ukolov, 2016-05-10
@atis2345

The Adapter pattern allows the design process to ignore possible differences in the interfaces of existing classes. If there is a class that has the required methods and properties (at least conceptually), then if necessary, you can always use the Adapter pattern to bring its interface to the desired form.

https://ru.wikipedia.org/wiki/Adapter_(project_template...

A
Antony, 2016-05-10
@RiseOfDeath

json, xml?

M
Maxim Kuznetsov, 2015-06-26
@NewProject1

setTimeout ? ;-)

var now = +new Date();
console.log(now);

setTimeout(function() {
    var future = +new Date();
    console.log(future);
}, 5000); // Время в милисекундах, 1 сек = 1000 мсек

Time from timestamp to what format you need, I think you will translate it yourself :-)

E
Evgeny Petrov, 2015-06-26
@Petroveg

Is that a plugin?

function timer (delta, step) {
  var count = 0;

  (function t () {
    if (count < step) {
      console.log(count);
      count++;
      setTimeout(t, delta);
    } else {
      console.log(count, 'end');
    }
  })();
}

timer(1000, 5);

_
_ _, 2015-06-26
@AMar4enko

.factory('countdown', function($q, $interval) {
  return function(to) {
      var d = $q.defer();
      var elapsed = 0;
      var intervalId = $interval(function() {
          elapsed += 1;
          d.notify(elapsed);
          if(Date.now() >= to) {
            $interval.cancel(intervalId);
            d.resolve();    
          }    
      }, 1000); 
      return d.promise;
  };
});

A
Alastor, 2015-06-26
@Alastor

If the accuracy is not important, then you can use the options given above
For after a few hours without reloading the page, the timer will lag behind for a time from one second to several minutes. Depends on the computer.
And if you need accuracy, then be sure to check against the current timestamp and adjust setInterval.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question