From 8ff4092ebcf568b6549b20262b6fd605ac82d8b5 Mon Sep 17 00:00:00 2001 From: buzz-lightsnack-2007 <73412182+buzz-lightsnack-2007@users.noreply.github.com> Date: Sun, 6 Apr 2025 15:26:42 +0800 Subject: [PATCH] feat: add log result formatter --- scripts/database/entry/log.JS | 40 +++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 scripts/database/entry/log.JS diff --git a/scripts/database/entry/log.JS b/scripts/database/entry/log.JS new file mode 100644 index 0000000..5d8d409 --- /dev/null +++ b/scripts/database/entry/log.JS @@ -0,0 +1,40 @@ +const Entry = require(`./object.JS`); + +class Log extends Entry { + // Default properties + name; + ID; + count; + activities; + + constructor(PROPERTIES) { + super(PROPERTIES); + this.calculate(); + } + + /* + Update and clean information. + */ + calculate () { + const set_activitiesCount = () => { + this.count = (this.activities instanceof Array) ? this.activities.length : 0; + }; + + const clean_activities = () => { + if ((this.activities instanceof Array) ? this.activities.length : false) { + for (let INDEX = 0; INDEX < this.activities.length ; INDEX++) { + [`username`].forEach((TBD) => { + if (Object.keys(this.activities[INDEX].includes(TBD))) { + delete this.activities[INDEX][TBD] + } + }) + } + } + } + + clean_activities(); + set_activitiesCount(); + } +} + +module.exports = Log; \ No newline at end of file