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

Function executeClientCommandHandler

main.js:9066–9132  ·  view source on GitHub ↗
(event, commandData)

Source from the content-addressed store, hash-verified

9064 return new Promise((resolve, reject) => {
9065 const row = cachedPrepare('SELECT COUNT(*) as count FROM model_tags WHERE tag_id = ?').get(tagId);
9066 if (row) {
9067 resolve(row.count);
9068 } else {
9069 reject(new Error('Tag not found'));
9070 }
9071 });
9072}
9073ipcMain.handle('get-tag-model-count', getTagModelCountHandler);
9074ipcHandlerRegistry.set('get-tag-model-count', getTagModelCountHandler);
9075
9076ipcMain.handle('get-all-metadata', async () => {
9077 try {
9078 return cachedPrepare(`
9079 SELECT 'designer' as type, designer as name, COUNT(*) as model_count
9080 FROM models
9081 WHERE designer IS NOT NULL AND designer != ''
9082 GROUP BY designer
9083 UNION ALL
9084 SELECT 'parentModel' as type, parentModel as name, COUNT(*) as model_count
9085 FROM models
9086 WHERE parentModel IS NOT NULL AND parentModel != ''
9087 GROUP BY parentModel
9088 UNION ALL
9089 SELECT 'license' as type, license as name, COUNT(*) as model_count
9090 FROM models
9091 WHERE license IS NOT NULL AND license != ''
9092 GROUP BY license
9093 ORDER BY type, name
9094 `).all();
9095 } catch (error) {
9096 console.error('Error getting metadata:', error);
9097 throw error;
9098 }
9099});
9100
9101ipcMain.handle('get-stats', async () => {
9102 try {
9103 // Total model count
9104 const totalModels = cachedPrepare('SELECT COUNT(*) as count FROM models').get();
9105 const totalCount = totalModels ? totalModels.count : 0;
9106
9107 // File type breakdown (count + disk usage)
9108 const stlStats = cachedPrepare("SELECT COUNT(*) as count, COALESCE(SUM(size), 0) as bytes FROM models WHERE LOWER(fileName) LIKE '%.stl'").get();
9109 const threeMfStats = cachedPrepare("SELECT COUNT(*) as count, COALESCE(SUM(size), 0) as bytes FROM models WHERE LOWER(fileName) LIKE '%.3mf'").get();
9110 const otherStats = cachedPrepare("SELECT COUNT(*) as count, COALESCE(SUM(size), 0) as bytes FROM models WHERE LOWER(fileName) NOT LIKE '%.stl' AND LOWER(fileName) NOT LIKE '%.3mf'").get();
9111 const totalBytesRow = cachedPrepare('SELECT COALESCE(SUM(size), 0) as bytes FROM models').get();
9112
9113 // Archived models (models inside ZIP files)
9114 const archivedCount = cachedPrepare("SELECT COUNT(*) as count FROM models WHERE filePath LIKE '%::%'").get();
9115
9116 // Models with metadata
9117 const withDesigner = cachedPrepare("SELECT COUNT(*) as count FROM models WHERE designer IS NOT NULL AND designer != ''").get();
9118 const withParentModel = cachedPrepare("SELECT COUNT(*) as count FROM models WHERE parentModel IS NOT NULL AND parentModel != ''").get();
9119 const withLicense = cachedPrepare("SELECT COUNT(*) as count FROM models WHERE license IS NOT NULL AND license != ''").get();
9120 const withTags = cachedPrepare("SELECT COUNT(DISTINCT model_id) as count FROM model_tags").get();
9121
9122 // Tag statistics
9123 const totalTags = cachedPrepare('SELECT COUNT(*) as count FROM tags').get();

Callers

nothing calls this directly

Calls 2

getWindowFromEventFunction · 0.85
execFunction · 0.85

Tested by

no test coverage detected