Algolia Instant Search can't add numeric filter / not working - algolia

I try to have an always on filter in my Instantsearch App (before & while the user is searching) & tried both ways from the docs:
1st
var search = instantsearch({
appId: '------------------,
apiKey: '-----------------',
indexName: 'words',
urlSync: true,
filters: 'sendDateUnix<'+ Date.now(),
});
2nd
var search = instantsearch({
appId: '------------------,
apiKey: '-----------------',
indexName: 'words',
urlSync: true,
numericFilters: [
'sendDateUnix<'+ Date.now()
]
});
As you can see, I have an property that is a Unix timestamp and would like to only get results where this timestamp ist greater then now. It works perfectly when I set this param in the algolia interface. It also does not work when i write the fully filter: 'sendDateUnix < 1519751110'
IS Version:
<script src="https://cdn.jsdelivr.net/instantsearch.js/1/instantsearch.min.js"></script>

The numericFilters option doesn't exist on instantsearch. You need to wrap the additional parameters in the searchParameters attribute. See the documentation for more informations.
const search = instantsearch({
appId: '------------------,
apiKey: '-----------------',
indexName: 'words',
urlSync: true,
searchParameters: {
numericFilters: ['sendDateUnix < ' + Date.now()],
},
});

Related

Esri-leaflet-geocoder: Component not rendering; How to connect providers in Production

I am using the great esri-leaflet-geocoder plugin and can't get it to render in production.
I registered for a provider (ArcGIS Online Geocoding Service) and got a api key, and followed the documentation on the github page to add the api key:
var searchControl = L.esri.Geocoding.geosearch({
providers: [
L.esri.Geocoding.arcgisOnlineProvider({
// API Key to be passed to the ArcGIS Online Geocoding Service
useMapBounds: false,
apikey: process.env.ESRI_API_KEY
})
]
});
I was getting the following error:
TypeError: Cannot read property 'Geocoding' of undefined
So with that I went to the official documentation page of esri-leaflet-geocoder here and tried what was listed there. Turns out it seems more up to date.
var provider = ELG.arcgisOnlineProvider({ token: process.env.ESRI_API_KEY });
var searchControl = new ELG.Geosearch({
useMapBounds: false,
providers: [provider]
});
console.log('ELG.arcgisOnlineProvider() ', provider);
console.log('searchControl', searchControl);
It didn't work but the consoles seems to show that they indeed take the props listed in the documentation:
ELG.arcgisOnlineProvider()
NewClass {_requestQueue: Array(0), _authenticating: false, options: {…}, _initHooksCalled: true, _eventParents: {…}}
options:
supportsSuggest: true
token: process.env.ESRI_API_KEY // In the log it's a string
url: "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/"
__proto__: Object
_authenticating: false
_eventParents: {1: NewClass}
_initHooksCalled: true
_requestQueue: []
__proto__: NewClass
searchControl
NewClass {options: {…}, _geosearchCore: NewClass, _leaflet_id: 1, _initHooksCalled: true}
options:
providers: Array(1)
0: NewClass
options: {token: process.env.ESRI_API_KEY // Again it is logging a string
url: "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/", supportsSuggest: true}
_authenticating: false
_eventParents: {1: NewClass}
_initHooksCalled: true
_requestQueue: []
__proto__: NewClass
length: 1
__proto__: Array(0)
useMapBounds: false
__proto__: Object
So how can I get the 'searchControl' to work/render in Production?
This is working for me:
import * as ELG from "esri-leaflet-geocoder";
var searchControl = ELG.geosearch({
useMapBounds: false,
providers: [
ELG.arcgisOnlineProvider({
apikey: "your key here"
})
]
});
searchControl.addTo(leafletMap);
Working codesandbox

What is the correct dataURL including filters for sapui5 spreadsheet control

I am using the export to spreadsheet control in SAPUI5 ( "sap/ui/export/Spreadsheet" described under https://sapui5.hana.ondemand.com/#/api/sap.ui.export.Spreadsheet).
When calling the odata Service without filters it works fine. When adding filters I get an 'uncaught in promise Unexpected Server Response' error in the frontend. What is the correct Url including filters that I have to specify under dataUrl?
Thank you for the help!
Christophe
So far I am trying with:
dataUrl: "/sap/opu/odata/sap//?$filter=Export eq 'X'"
oSettings = {
workbook: {
columns: aCols,
hierarchyLevel: "Level",
},
dataSource: {
type: "odata",
dataUrl: "/sap/opu/odata/sap/<myService>/<myEntitySet>?$filter=Export eq 'X'",
serviceUrl: oModelInterface.sServiceUrl,
headers: oModelInterface.getHeaders ? oModelInterface.getHeaders() : null,
count: oBinding.getLength ? oBinding.getLength() : null,
useBatch: true,
sizeLimit: oModelInterface.iSizeLimit
},
worker: false,
};
var oSpreadsheet = new Spreadsheet(oSettings);
oSpreadsheet.build();
There is an API for the download URL.
Just use oBinding.getDownloadUrl()
Just to be safe:
dataUrl: oRowBinding.getDownloadUrl ? oRowBinding.getDownloadUrl() : null
Reference: https://openui5.hana.ondemand.com/#/api/sap.ui.model.odata.v2.ODataListBinding

testing a site not working in internet explorer-values not able to enter in fields

I am using protractor version 5.2.2 and cucumber-protractor framework, I have started practising testing for the LinkedIn site, but when I use the internet explorer browser it is only able to open the LinkedIn URL as mentioned in the config file and no scenarios are being executed, can anybody help me?
//config file
var params = require('./browsers.js');
var browser = params.browser;
var multiCapabilities = browser.split(',').map(function(browserName){
return {
browserName: browserName.trim()
};
})
var moment = require('moment')
var timeStamp = moment().format('YYYYMMDD_hhmmss');
exports.config = {
seleniumAddress: 'http://127.0.0.1:4444/wd/hub',
getPageTimeout: 60000,
allScriptsTimeout: 500000,
framework: 'custom',
frameworkPath: require.resolve('protractor-cucumber-framework'),
// Capabilities to be passed to the webdriver instance.
multiCapabilities: multiCapabilities,
// Spec patterns are relative to the current working directory when
// protractor is called.
specs: ['Features/*.feature'],
baseUrl: 'https://www.linkedin.com/',
cucumberOpts: {
require: 'Features/step_definition/searchstep_linkedin.js',
tags: false,
plugin: ['pretty'],
format: 'json:reports/report'+timeStamp+' '+browser+'/results.json',
profile: false,
'no-source': true
},
plugins: [{
package: 'protractor-multiple-cucumber-html-reporter-plugin',
options:{
automaticallyGenerateReport: true,
}
}]
};
//Feature file
Background: I need to go linked in site
Given I go to url ""
Scenario: Should not login with blank username and password
Then I wait for "2000"
When I enter " " in "#login-email"
When I enter " " in "#login-password"
Then I click on "#login-submit"
Then I should see ""
//Spec File
Given(/^I go to url "(.*)"$/, function (url){
return browser.get(url);
});
When(/^I enter "(.*)" in "(.*)"$/, function (value,locator){ /**/
return element(by.xpath(locator)).sendKeys(value);
});
Then(/^I should see "(.*)"$/, function (url){ /**/
browser.sleep(2000);
return
expect(browser.getCurrentUrl()).to.eventually.equal(browser.baseUrl
+ url);
});
Then(/^I click on "(.*)"$/, function (locator){ /**/
return return element(by.xpath(locator)).click();
});

Using Winston and Morgan to log in Sails

In the config/log.js file for Sails this is my code:
var express = require("express");
var app = express();
var winston = require('winston');
var logger = new(winston.Logger)({
transports: [
new(winston.transports.File)({
level: 'info',
timestamp: true,
filename: './logFile.log',
handleExceptions: true,
json: true,
colorize: false
}),
new(winston.transports.Console)({
level: 'debug',
timestamp: true,
handleExceptions: true,
json: false,
colorize: true
})
],
exitOnError: false
});
logger.stream = {
write: function (message, encoding) {
logger.verbose(message);
}
};
app.use(require('morgan')("combined", {"stream": logger.stream}));
module.exports.log = {
level: 'info',
custom: logger
};
I'm trying to use morgan along with winston to log all the HTTP requests. I found an example online that said to do it this way, and this makes sense to me, but for some reason my log file isn't showing any of the requests that are made. The winston part is fine as it is logging all the information that it should be, but I don't know how to get morgan to work with winston. Any advice or suggestions? Thanks!
Morgan is an express middleware so it should be loaded as a custom middleware to Sails.
To do that add the following to config/http.js:
customMiddleware: function(app) {
app.use(require('morgan')("combined", {"stream": sails.config.log.custom.stream}));
}

is there a getConfig() for Protractor?

I've the following config.js file:
var testName = 'Testing';
var HtmlReporter = require('protractor-html-screenshot-reporter');
var reporter = new HtmlReporter({
baseDirectory: './protractor-result', // a location to store screen shots.
docTitle: 'Report Test Summary',
docName: 'protractor-tests-report.html'
});
exports.config = {
seleniumAddress: 'http://hub.browserstack.com/wd/hub',
multiCapabilities: [
{
name: testName,
browserName: 'Chrome',
browser_version: '39.0',
os: 'OS X',
os_version: 'Yosemite',
resolution: '1920x1080',
'browserstack.user': browserstackUser,
'browserstack.key': browserstackKey,
'browserstack.debug': 'true',
'browserstack.selenium_version': '2.45.0'
}
,
{
name: testName,
browserName: 'IE',
browser_version: '11.0',
os: 'Windows',
os_version: '8.1',
resolution: '2048x1536',
'browserstack.user': browserstackUser,
'browserstack.key': browserstackKey,
'browserstack.debug': 'true',
'browserstack.selenium_version': '2.45.0',
'browserstack.ie.driver': '2.44',
//ignoreProtectedModeSettings: true
}
],
// Spec patterns are relative to the current working directly when
// protractor is called.
suites: {
waitlist: './././specs/waitlist_page_spec.js',
press: './././specs/press_page_spec.js',
news: './././specs/news_page_spec.js',
landing: './././specs/landing_page_spec.js'
},
// Maximum number of total browser sessions to run. Tests are queued in
// sequence if number of browser sessions is limited by this parameter.
// Use a number less than 1 to denote unlimited. Default is unlimited.
maxSessions: 2,
// protractor will save the test output in json format at this path.
// The path is relative to the location of this config.
resultJsonOutputFile: null,
framework: 'jasmine2',
// Options to be passed to Jasmine-node.
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 100000,
realtimeFailure: true,
showTiming: true,
includeStackTrace: true,
isVerbose: true,
onComplete: null
},
onPrepare: function () {
jasmine.getEnv().addReporter(reporter);
browser.driver.manage().window().maximize();
global.dvr = browser.driver; //variable to call selenium directly
global.isAngularSite = function (flag) {
browser.ignoreSynchronization = !flag; //This setup is to configure when testing non-angular pages
};
//browser.manage().timeouts().pageLoadTimeout(90000);
browser.manage().timeouts().implicitlyWait(100000);
}
};
And I would like to find a way to ask on my test that if the capability.browserName is IE do a certain/especial action, so, I would like to do some sort of getConfig(), is that possible? does anyone had implemented something similar?
Thanks all for your time!
The getCapabilities in browser returns a promise with these values:
browser.getCapabilities().then(function (capabilities) {
browser = capabilities.caps_.browserName;
platform = capabilities.caps_.platform;
}).then(function displayEnv() {
console.log('Browser:', browser, 'on platform', platform);
});