Permalink
Browse files

api updates

log read size limited to 256mb
  • Loading branch information...
Manuel-777 committed Nov 17, 2018
1 parent 3ed0e3f commit 58a0a14426ca9dc83fa27beb3ccc84ff8afd8586
Showing with 27 additions and 18 deletions.
  1. +1 −1 shared/util.js
  2. +17 −8 window_background/background.js
  3. +9 −9 window_main/renderer.js
@@ -1006,7 +1006,7 @@ function timeSince(_date) {
return interval + " days";
interval = Math.floor(seconds / 3600);
if (interval == 1)
return interval + " hous";
return interval + " hour";
if (interval > 0)
return interval + " hours";
interval = Math.floor(seconds / 60);
@@ -199,6 +199,7 @@ ipc.on('set_renderer_state', function (event, arg) {
if (rstore.get("token") !== "" && rstore.get("email") !== "") {
rememberMe = true;
tokenAuth = rstore.get("token");
ipc_send("set_remember", rstore.get("email"));
}
});
@@ -604,7 +605,7 @@ function readLog() {
var stats = fs.fstatSync(file);
logSize = stats.size;
logDiff = logSize - prevLogSize;
if (logDiff > 268435440) logDiff = 268435440;
//ipc_send("ipc_log", "readLog logloopmode: "+logLoopMode+", renderer state:"+renderer_state+", logSize: "+logSize+", prevLogSize: "+prevLogSize);
// Something went wrong obtaining the file size, try again later
@@ -619,6 +620,7 @@ function readLog() {
logDiff = logSize;
}
console.log("log diff: ", logDiff, "log size: ", logSize);
// If the log has changed since we last checked (or if this is the first time we read it)
if (logSize > prevLogSize+1) {
// We are looping only to get user data (processLogUser)
@@ -968,6 +970,13 @@ function processLogData(data) {
strCheck = '<== Event.GetPlayerCourse(';
json = checkJsonWithStart(data, strCheck, '', ')');
if (json != false) {
strCheck = 'Logger]';
if (data.indexOf(strCheck) > -1) {
var str = dataChop(data, strCheck, 'M')+'M';
var logTime = parseWotcTime(str);
json.date = logTime;
}
if (json.Id != "00000000-0000-0000-0000-000000000000") {
json._id = json.Id;
delete json.Id;
@@ -2352,7 +2361,7 @@ function httpBasic() {
async.forEachOfSeries(httpAsyncNew, function (value, index, callback) {
var _headers = value;
if (store.get("settings").send_data == false && _headers.method != 'get_picks' && _headers.method != 'delete_data' && _headers.method != 'get_database' && _headers.method != 'get_status' && debugLog == false) {
if (store.get("settings").send_data == false && _headers.method != 'auth' && _headers.method != 'delete_data' && _headers.method != 'get_database' && _headers.method != 'get_status' && debugLog == false) {
callback({message: "Settings dont allow sending data! > "+_headers.method});
removeFromHttp(_headers.reqId);
}
@@ -2385,6 +2394,7 @@ function httpBasic() {
ipc_send("ipc_log", "SEND >> "+index+", "+_headers.method+", "+_headers.reqId+", "+_headers.token);
}
console.log("POST", _headers);
var post_data = qs.stringify(_headers);
options.headers = { 'Content-Type': 'application/x-www-form-urlencoded', 'Content-Length': post_data.length};
@@ -2415,7 +2425,6 @@ function httpBasic() {
//ipc_send("auth", parsedResult.arenaids);
if (rememberMe) {
console.log(tokenAuth, parsedResult);
rstore.set("token", tokenAuth);
rstore.set("email", playerUsername);
}
@@ -2473,13 +2482,13 @@ function httpBasic() {
}
});
});
console.log(req);
req.on('error', function(e) {
callback(e);
removeFromHttp(_headers.reqId);
ipc_send("ipc_log", e.message);
});
req.write(post_data);
console.log(req);
req.end();
}, function (err) {
@@ -2514,7 +2523,7 @@ function httpSubmitCourse(course) {
course.PlayerName = "Anonymous";
}
course = JSON.stringify(course);
//httpAsync.push({'reqId': _id, 'method': 'submit_course', 'method_path': '/mongo/send_course.php', 'course': course});
httpAsync.push({'reqId': _id, 'method': 'submit_course', 'method_path': '/mongo/send_course.php', 'course': course});
}
function httpSetPlayer(name, rank, tier) {
@@ -2525,12 +2534,12 @@ function httpSetPlayer(name, rank, tier) {
function httpGetTopDecks(query) {
var _id = makeId(6);
//httpAsync.push({'reqId': _id, 'method': 'get_top_decks', 'method_path': '/mongo/get_top_decks.php', 'query': query});
httpAsync.push({'reqId': _id, 'method': 'get_top_decks', 'method_path': '/mongo/get_courses_list.php', 'query': query});
}
function httpGetCourse(courseId) {
var _id = makeId(6);
//httpAsync.push({'reqId': _id, 'method': 'get_course', 'method_path': '/mongo/get_course.php', 'courseid': courseId});
httpAsync.push({'reqId': _id, 'method': 'get_course', 'method_path': '/mongo/get_course.php', 'courseid': courseId});
}
function httpSetMatch(match) {
@@ -2548,7 +2557,7 @@ function httpSetDraft(draft) {
function httpSetEconomy(change) {
var _id = makeId(6);
change = JSON.stringify(change);
//httpAsync.push({'reqId': _id, 'method': 'set_economy', 'method_path': '/mongo/send_economy.php', 'change': change});
httpAsync.push({'reqId': _id, 'method': 'set_economy', 'method_path': '/mongo/send_economy.php', 'change': change});
}
function httpSendError(error) {
@@ -1944,7 +1944,7 @@ function setDecks(arg) {
//
function updateExplore() {
filterEvent = getEventId(document.getElementById("query_select").value);
ipc_send('request_explore', filterEvent.toLowerCase());
ipc_send('request_explore', filterEvent);
}
//
@@ -2043,15 +2043,15 @@ function setExplore(arg, loadMore) {
actuallyLoaded++;
if (_deck.deck_colors == undefined) {
_deck.deck_colors = [];
if (_deck.colors == undefined) {
_deck.colors = [];
}
if (_deck.wins == undefined) {
_deck.wins = 0;
_deck.losses = 0;
}
var tileGrpid = _deck.deck_tile;
var tileGrpid = _deck.tile;
try {
var tileCard = cardsDb.get(tileGrpid).set;
}
@@ -2095,15 +2095,15 @@ function setExplore(arg, loadMore) {
var d = document.createElement("div");
d.classList.add("list_deck_name");
d.innerHTML = _deck.deck_name;
d.innerHTML = _deck.deckname;
flt.appendChild(d);
var d = document.createElement("div");
d.classList.add("list_deck_name_it");
d.innerHTML = "by "+_deck.player_name;
d.innerHTML = "by "+_deck.player;
flt.appendChild(d);
_deck.deck_colors.forEach(function(color) {
_deck.colors.forEach(function(color) {
var d = document.createElement("div");
d.classList.add("mana_s20");
d.classList.add("mana_"+mana[color]);
@@ -2118,7 +2118,7 @@ function setExplore(arg, loadMore) {
var d = document.createElement("div");
d.classList.add("list_deck_name_it");
let ee = _deck.event;
d.innerHTML = getReadableEvent(ee)+" - "+timeSince(_deck.date*1000)+" ago";
d.innerHTML = getReadableEvent(ee)+" - "+timeSince(new Date(_deck.date))+" ago";
flr.appendChild(d);
div.appendChild(fll);
@@ -2142,7 +2142,7 @@ function setExplore(arg, loadMore) {
});
$('.'+index).on('click', function(e) {
open_course_request(_deck.id);
open_course_request(_deck._id);
});
}

0 comments on commit 58a0a14

Please sign in to comment.