MCPcopy Create free account
hub / github.com/TechJeeper/Printventory / getDuplicatesHandler

Function getDuplicatesHandler

main.js:7854–7908  ·  view source on GitHub ↗
(event, includeZip = false)

Source from the content-addressed store, hash-verified

7852 const writeStart = Date.now();
7853 const transaction = db.transaction(() => {
7854 for (let i = 0; i < iterations; i++) {
7855 insertStmt.run(`benchmark_test_${i}`, `test_value_${i}`);
7856 }
7857 });
7858 transaction();
7859 const writeTime = Date.now() - writeStart;
7860 const writeOpsPerSec = (iterations / (writeTime / 1000)).toFixed(2);
7861
7862 // Read benchmark - select test records
7863 const selectStmt = db.prepare('SELECT value FROM settings WHERE key = ?');
7864 const readStart = Date.now();
7865 for (let i = 0; i < iterations; i++) {
7866 selectStmt.get(`benchmark_test_${i}`);
7867 }
7868 const readTime = Date.now() - readStart;
7869 const readOpsPerSec = (iterations / (readTime / 1000)).toFixed(2);
7870
7871 // Cleanup - delete test records
7872 const deleteStmt = db.prepare('DELETE FROM settings WHERE key LIKE ?');
7873 deleteStmt.run('benchmark_test_%');
7874
7875 return {
7876 success: true,
7877 write: {
7878 time: writeTime,
7879 operations: iterations,
7880 opsPerSec: writeOpsPerSec
7881 },
7882 read: {
7883 time: readTime,
7884 operations: iterations,
7885 opsPerSec: readOpsPerSec
7886 }
7887 };
7888 } catch (error) {
7889 console.error('Error benchmarking database:', error);
7890 return { success: false, error: error.message };
7891 }
7892});
7893
7894ipcMain.handle('rename-metadata', async (event, type, oldName, newName) => {
7895 try {
7896 if (!oldName || !newName || oldName.trim() === '' || newName.trim() === '') {
7897 throw new Error('Name cannot be empty');
7898 }
7899
7900 // Validate type
7901 const validTypes = ['designer', 'parentModel', 'license'];
7902 if (!validTypes.includes(type)) {
7903 throw new Error('Invalid metadata type');
7904 }
7905
7906 // Check if new name already exists for this type (for merge information)
7907 const existing = db.prepare(`
7908 SELECT COUNT(*) as count
7909 FROM models
7910 WHERE ${type} = ? AND ${type} IS NOT NULL AND ${type} != ''
7911 `).get(newName.trim());

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected