Fix first chat date injestion (I'm pretty sure).

This commit is contained in:
BlipRanger
2023-07-19 09:51:22 -04:00
parent 2f73506e25
commit 284fb68478
2 changed files with 6 additions and 5 deletions

View File

@@ -110,7 +110,7 @@ function createHtml(statsType, stats) {
if (statsType === "User") {
html += createStatBlock("Chatting Since", `${chatAge} ago`);
} else {
html += createStatBlock("Chat Age", chatAge);
html += createStatBlock("First Interaction", `${chatAge} ago`);
}
html += createStatBlock("Chat Time", timeStirng);
html += createStatBlock("User Messages", stats.user_msg_count);
@@ -284,11 +284,11 @@ async function statMesProcess(line, type, characters, this_chid, oldMesssage) {
stat.total_swipe_count++;
}
stat.date_last_chat = Date.now();
stat.first_chat_time = Math.min(
stat.date_first_chat = Math.min(
stat.date_first_chat ?? new Date("9999-12-31T23:59:59.999Z").getTime(),
Date.now()
);
updateStats();
}
export { userStatsHandler, characterStatsHandler, getStats, statMesProcess };
export { userStatsHandler, characterStatsHandler, getStats, statMesProcess, charStats };

View File

@@ -393,8 +393,9 @@ function calculateTotalGenTimeAndWordCount(
}
// If this is the first user message, set the first chat time
if (json.is_user && firstChatTime > Date.now()) {
firstChatTime = timestampToMoment(json.send_date);
if (json.is_user) {
//get min between firstChatTime and timestampToMoment(json.send_date)
firstChatTime = Math.min(timestampToMoment(json.send_date), firstChatTime);
}
} catch (error) {
console.error(`Error parsing line ${line}: ${error}`);