mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-12-29 02:11:28 -06:00
Fixed some bugs related to build
This commit is contained in:
parent
c76397f601
commit
8a61b86a3d
@ -34,7 +34,7 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div style="padding: 20px;">
|
<div style="padding: 20px;">
|
||||||
<h1>Symphony Electron API Demo</h1>
|
<h1>Symphony Electron Search API Demo</h1>
|
||||||
<div>
|
<div>
|
||||||
<p>Search</p>
|
<p>Search</p>
|
||||||
</div>
|
</div>
|
||||||
@ -67,9 +67,14 @@
|
|||||||
<div>
|
<div>
|
||||||
<label for="var1">var1:</label><input id="var1" value="0" size=5>
|
<label for="var1">var1:</label><input id="var1" value="0" size=5>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="realTimeIndexing">Real Time Indexing:</label><input placeholder="Pass array of messages:" id="realTimeIndexing">
|
||||||
|
<button id='sendMessage'>Send</button>
|
||||||
|
</div>
|
||||||
<br>
|
<br>
|
||||||
<div>
|
<div>
|
||||||
<button id='index'>IndexMessages</button>
|
<label for="batchNumber">Batch Number: </label><input placeholder="Ex: batch1, batch2" id="batchNumber">
|
||||||
|
<button id='index'>Index Messages</button>
|
||||||
<button id='merge'>Merge</button>
|
<button id='merge'>Merge</button>
|
||||||
</div>
|
</div>
|
||||||
<br>
|
<br>
|
||||||
@ -102,10 +107,14 @@
|
|||||||
var threadIdEl = document.getElementById('threadId');
|
var threadIdEl = document.getElementById('threadId');
|
||||||
var var1El = document.getElementById('var1');
|
var var1El = document.getElementById('var1');
|
||||||
var table = document.getElementById('table');
|
var table = document.getElementById('table');
|
||||||
|
var sendMessage = document.getElementById('sendMessage');
|
||||||
|
var realTimeIndexing = document.getElementById('realTimeIndexing');
|
||||||
|
var batchNumber = document.getElementById('batchNumber');
|
||||||
|
|
||||||
|
|
||||||
buttonIndex.addEventListener('click', function () {
|
buttonIndex.addEventListener('click', function () {
|
||||||
search.readJson().then(function (res) {
|
let batchIndex = batchNumber.value;
|
||||||
|
search.readJson(batchIndex).then(function (res) {
|
||||||
search.indexBatch(res).then(function () {
|
search.indexBatch(res).then(function () {
|
||||||
resultsEl.innerHTML = "Index created";
|
resultsEl.innerHTML = "Index created";
|
||||||
});
|
});
|
||||||
@ -151,6 +160,11 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
sendMessage.addEventListener('click', function () {
|
||||||
|
let message = JSON.parse(realTimeIndexing.value);
|
||||||
|
search.realTimeIndexing(message);
|
||||||
|
});
|
||||||
|
|
||||||
merge.addEventListener('click', function () {
|
merge.addEventListener('click', function () {
|
||||||
search.mergeIndexBatches();
|
search.mergeIndexBatches();
|
||||||
})
|
})
|
||||||
|
@ -3,18 +3,20 @@
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const randomString = require('randomstring');
|
const randomString = require('randomstring');
|
||||||
|
|
||||||
|
|
||||||
const electron = require('electron');
|
const electron = require('electron');
|
||||||
const app = electron.app;
|
const app = electron.app;
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const isDevEnv = require('../utils/misc.js').isDevEnv;
|
const isDevEnv = require('../utils/misc.js').isDevEnv;
|
||||||
const isMac = require('../utils/misc.js').isMac;
|
const isMac = require('../utils/misc.js').isMac;
|
||||||
|
|
||||||
|
let userData = path.join(app.getPath('userData'));
|
||||||
|
let execPath = path.dirname(app.getPath('exe'));
|
||||||
|
|
||||||
const libSymphonySearch = require('./searchLibrary');
|
const libSymphonySearch = require('./searchLibrary');
|
||||||
const TEMP_BATCH_INDEX_FOLDER = './data/temp_batch_indexes';
|
const TEMP_BATCH_INDEX_FOLDER = path.join(userData, '/data/temp_batch_indexes');
|
||||||
const TEMP_REALTIME_INDEX = './data/temp_realtime_index';
|
const TEMP_REALTIME_INDEX = path.join(userData, '/data/temp_realtime_index');
|
||||||
const INDEX_PREFIX = './data/search_index';
|
const INDEX_PREFIX = path.join(userData, '/data/search_index');
|
||||||
const INDEX_DATA_FOLDER = './data';
|
const INDEX_DATA_FOLDER = path.join(userData, '/data');
|
||||||
const SEARCH_PERIOD_SUBTRACTOR = 3 * 31 * 24 * 60 * 60 * 1000;//3 months
|
const SEARCH_PERIOD_SUBTRACTOR = 3 * 31 * 24 * 60 * 60 * 1000;//3 months
|
||||||
const MINIMUM_DATE = '0000000000000';
|
const MINIMUM_DATE = '0000000000000';
|
||||||
const MAXIMUM_DATE = '9999999999999';
|
const MAXIMUM_DATE = '9999999999999';
|
||||||
@ -24,9 +26,8 @@ const SORT_BY_SCORE = 0;
|
|||||||
|
|
||||||
const BATCH_RANDOM_INDEX_PATH_LENGTH = 20;
|
const BATCH_RANDOM_INDEX_PATH_LENGTH = 20;
|
||||||
|
|
||||||
let execPath = path.dirname(app.getPath('exe'));
|
|
||||||
|
|
||||||
class Search {
|
class Search {
|
||||||
|
/*eslint-disable class-methods-use-this */
|
||||||
|
|
||||||
constructor(userId) {
|
constructor(userId) {
|
||||||
this.isInitialized = false;
|
this.isInitialized = false;
|
||||||
@ -71,7 +72,7 @@ class Search {
|
|||||||
let indexId = randomString.generate(BATCH_RANDOM_INDEX_PATH_LENGTH);
|
let indexId = randomString.generate(BATCH_RANDOM_INDEX_PATH_LENGTH);
|
||||||
libSymphonySearch.symSECreatePartialIndexAsync(TEMP_BATCH_INDEX_FOLDER, indexId, JSON.stringify(messages), function (err, res) {
|
libSymphonySearch.symSECreatePartialIndexAsync(TEMP_BATCH_INDEX_FOLDER, indexId, JSON.stringify(messages), function (err, res) {
|
||||||
if (err) reject(err);
|
if (err) reject(err);
|
||||||
resolve(res)
|
resolve(res);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -84,15 +85,19 @@ class Search {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/*eslint-disable class-methods-use-this */
|
realTimeIndexing(message) {
|
||||||
readJson() {
|
libSymphonySearch.symSEIndexRealTime(TEMP_REALTIME_INDEX, JSON.stringify(message));
|
||||||
|
}
|
||||||
|
|
||||||
|
readJson(batch) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let dirPath = path.join(execPath, isMac ? '..' : '', 'Resources/msgsjson');
|
let dirPath = path.join(execPath, isMac ? '..' : '', 'Resources/msgsjson', batch);
|
||||||
let messageFolderPath = isDevEnv ? './msgsjson/' : dirPath;
|
let messageFolderPath = isDevEnv ? path.join('./msgsjson', batch ): dirPath;
|
||||||
let files = fs.readdirSync(messageFolderPath);
|
let files = fs.readdirSync(messageFolderPath);
|
||||||
let messageData = [];
|
let messageData = [];
|
||||||
files.forEach(function (file) {
|
files.forEach(function (file) {
|
||||||
let data = fs.readFileSync(messageFolderPath + file, "utf8");
|
let tempPath = path.join(messageFolderPath, file);
|
||||||
|
let data = fs.readFileSync(tempPath, "utf8");
|
||||||
if (data) {
|
if (data) {
|
||||||
messageData.push(JSON.parse(data));
|
messageData.push(JSON.parse(data));
|
||||||
resolve(messageData);
|
resolve(messageData);
|
||||||
@ -145,7 +150,7 @@ class Search {
|
|||||||
let ret = JSON.parse(returnedResult);
|
let ret = JSON.parse(returnedResult);
|
||||||
resolve(ret);
|
resolve(ret);
|
||||||
if (ret.messages.length > 0) {
|
if (ret.messages.length > 0) {
|
||||||
libSymphonySearch.symSEFreeResultAsync(returnedResult);
|
libSymphonySearch.symSEFreeResult(returnedResult);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,13 @@ const isMac = require('../utils/misc.js').isMac;
|
|||||||
|
|
||||||
var symLucyIndexer = ref.types.void;
|
var symLucyIndexer = ref.types.void;
|
||||||
var symLucyIndexerPtr = ref.refType(symLucyIndexer);
|
var symLucyIndexerPtr = ref.refType(symLucyIndexer);
|
||||||
|
|
||||||
|
|
||||||
|
let messageData = ref.types.void;
|
||||||
|
let messagePtr = ref.refType(messageData);
|
||||||
|
|
||||||
let execPath = path.dirname(app.getPath('exe'));
|
let execPath = path.dirname(app.getPath('exe'));
|
||||||
let libraryPath = isMac ? 'Resources/libsymphonysearch' : 'Resources/libsymphonysearchwin64';
|
let libraryPath = isMac ? 'Resources/libsymphonysearch' : 'resources/libsymphonysearchwin64';
|
||||||
let fullPath = path.join(execPath, isMac ? '..' : '', libraryPath);
|
let fullPath = path.join(execPath, isMac ? '..' : '', libraryPath);
|
||||||
let libPath = isDevEnv ? 'libsymphonysearch.dylib' : fullPath;
|
let libPath = isDevEnv ? 'libsymphonysearch.dylib' : fullPath;
|
||||||
|
|
||||||
@ -37,7 +42,7 @@ var libSymphonySearch = ffi.Library(libPath, {
|
|||||||
//Index commit/optimize
|
//Index commit/optimize
|
||||||
'symSE_commit_index': ['int', [symLucyIndexerPtr, 'int']], //will be removed
|
'symSE_commit_index': ['int', [symLucyIndexerPtr, 'int']], //will be removed
|
||||||
//freePointer
|
//freePointer
|
||||||
'symSE_free_results': ['int', ['string']]
|
'symSE_free_results': ['int', [messagePtr]]
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
@ -33,7 +33,11 @@
|
|||||||
"!installer/*",
|
"!installer/*",
|
||||||
"!tests/*"
|
"!tests/*"
|
||||||
],
|
],
|
||||||
"extraResources": ["msgsjson", "libsymphonysearch.dylib", "libsymphonysearchwin64.dll"],
|
"extraResources": [
|
||||||
|
"msgsjson",
|
||||||
|
"libsymphonysearch.dylib",
|
||||||
|
"libsymphonysearchwin64.dll"
|
||||||
|
],
|
||||||
"extraFiles": "config/Symphony.config",
|
"extraFiles": "config/Symphony.config",
|
||||||
"appId": "symphony-electron-desktop",
|
"appId": "symphony-electron-desktop",
|
||||||
"mac": {
|
"mac": {
|
||||||
|
Loading…
Reference in New Issue
Block a user