Add dedupe
This commit is contained in:
parent
606a1e57e4
commit
4b9b8b726c
|
@ -169,7 +169,7 @@ router.post('/import', authenticate, upload.single('fileInput'), async (req, res
|
|||
const data = fs.readFileSync(filePath, 'utf-8');
|
||||
const lines = data.split('\n');
|
||||
const conn = await pool.getConnection();
|
||||
uploads[uploadId] = { completed: false, total: lines.length, processed: 0 };
|
||||
uploads[uploadId] = { completed: false, total: lines.length, processed: 0, skipped: 0 };
|
||||
res.end(JSON.stringify({ success: true, message: 'Started upload, please wait!', id: uploadId }));
|
||||
for (const line of lines) {
|
||||
// This is a text file, split by "x/"", get [0], then split by / and get the last element, that will be an ID. All other values are static.
|
||||
|
@ -178,6 +178,12 @@ router.post('/import', authenticate, upload.single('fileInput'), async (req, res
|
|||
const reasonShort = "Listed by MFD";
|
||||
const moderator = "MFD";
|
||||
const reasonsFlag = flags.addFlag(0, reasonFlags.CHILD_SAFETY)
|
||||
const existingBan = await conn.query('SELECT * FROM bans WHERE robloxId = ?', [robloxId]);
|
||||
if (existingBan.length > 0) {
|
||||
uploads[uploadId].processed++;
|
||||
uploads[uploadId].skipped++
|
||||
continue; // Skip this entry if robloxId already exists
|
||||
}
|
||||
await conn.query('INSERT INTO bans (robloxId, reasonShort, reasonLong, reasonsFlag, moderator) VALUES (?, ?, ?, ?, ?)',
|
||||
[robloxId, reasonShort, reasonLong, reasonsFlag, moderator]);
|
||||
uploads[uploadId].processed++;
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<h2 class="text-center mb-4">Mass Ban (Import)</h2>
|
||||
<div class="alert" id="message" style="display: none;"></div>
|
||||
<div class="alert alert-warning">
|
||||
The import system does <strong>NOT</strong> have deduplication. Please be sure to remove duplicate entries from your list <strong>BEFORE</strong> uploading!
|
||||
The import system does <strong>NOT</strong> have deduplication for CSV files. Please be sure to remove duplicate entries from your list <strong>BEFORE</strong> uploading!
|
||||
</div>
|
||||
<form id="banForm">
|
||||
<div class="mb-3">
|
||||
|
|
Loading…
Reference in a new issue