koishi-plugin-best-cave 1.4.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +17 -12
- package/lib/utils/HashStorage.d.ts +5 -0
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -712,11 +712,12 @@ var HashStorage = class _HashStorage {
|
|
|
712
712
|
await this.processCaveTextHashes(cave);
|
|
713
713
|
processedCount++;
|
|
714
714
|
if (processedCount % 100 === 0 || processedCount === total) {
|
|
715
|
-
logger3.info(`
|
|
715
|
+
logger3.info(`Progress: ${processedCount}/${total} caves (${Math.floor(processedCount / total * 100)}%)`);
|
|
716
716
|
}
|
|
717
717
|
}
|
|
718
718
|
await this.saveHashes();
|
|
719
|
-
|
|
719
|
+
const stats = this.getStorageStats();
|
|
720
|
+
logger3.info(`Cave Hashes Initialized: ${stats.text} text hashes, ${stats.image} image hashes`);
|
|
720
721
|
}
|
|
721
722
|
/**
|
|
722
723
|
* 更新缺失的哈希值
|
|
@@ -728,23 +729,15 @@ var HashStorage = class _HashStorage {
|
|
|
728
729
|
const missingTextCaves = caveData.filter((cave) => !this.textHashes.has(cave.cave_id));
|
|
729
730
|
const total = missingImageCaves.length + missingTextCaves.length;
|
|
730
731
|
if (total > 0) {
|
|
731
|
-
let processedCount = 0;
|
|
732
732
|
for (const cave of missingImageCaves) {
|
|
733
733
|
await this.processCaveHashes(cave);
|
|
734
|
-
processedCount++;
|
|
735
|
-
if (processedCount % 100 === 0 || processedCount === total) {
|
|
736
|
-
logger3.info(`Updating missing hashes: ${processedCount}/${total} (${Math.floor(processedCount / total * 100)}%)`);
|
|
737
|
-
}
|
|
738
734
|
}
|
|
739
735
|
for (const cave of missingTextCaves) {
|
|
740
736
|
await this.processCaveTextHashes(cave);
|
|
741
|
-
processedCount++;
|
|
742
|
-
if (processedCount % 100 === 0 || processedCount === total) {
|
|
743
|
-
logger3.info(`Updating missing hashes: ${processedCount}/${total} (${Math.floor(processedCount / total * 100)}%)`);
|
|
744
|
-
}
|
|
745
737
|
}
|
|
746
738
|
await this.saveHashes();
|
|
747
|
-
|
|
739
|
+
const stats = this.getStorageStats();
|
|
740
|
+
logger3.info(`Hash storage updated: ${stats.text} text hashes, ${stats.image} image hashes`);
|
|
748
741
|
}
|
|
749
742
|
}
|
|
750
743
|
/**
|
|
@@ -815,6 +808,18 @@ var HashStorage = class _HashStorage {
|
|
|
815
808
|
static hashText(text) {
|
|
816
809
|
return import_crypto.default.createHash("md5").update(text).digest("hex");
|
|
817
810
|
}
|
|
811
|
+
/**
|
|
812
|
+
* 获取存储统计数据
|
|
813
|
+
* @private
|
|
814
|
+
*/
|
|
815
|
+
getStorageStats() {
|
|
816
|
+
const textCount = Array.from(this.textHashes.values()).reduce((sum, arr) => sum + arr.length, 0);
|
|
817
|
+
const imageCount = Array.from(this.imageHashes.values()).reduce((sum, arr) => sum + arr.length, 0);
|
|
818
|
+
return {
|
|
819
|
+
text: textCount,
|
|
820
|
+
image: imageCount
|
|
821
|
+
};
|
|
822
|
+
}
|
|
818
823
|
};
|
|
819
824
|
|
|
820
825
|
// src/index.ts
|