koishi-plugin-warframe 1.5.2 → 1.5.3

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.d.ts CHANGED
@@ -165,6 +165,7 @@ declare interface ClosedStatisticsEntry {
165
165
  donch_top: number;
166
166
  donch_bot: number;
167
167
  id: string;
168
+ mod_rank: number;
168
169
  }
169
170
  declare interface LiveStatisticsEntry {
170
171
  datetime: string;
@@ -177,6 +178,7 @@ declare interface LiveStatisticsEntry {
177
178
  order_type: "buy" | "sell";
178
179
  moving_avg: number;
179
180
  id: string;
181
+ mod_rank: number;
180
182
  }
181
183
  export interface StatisticsCollection {
182
184
  statistics_closed: {
@@ -402,6 +404,7 @@ declare interface ClosedStatisticsEntryDTO {
402
404
  donch_top: number;
403
405
  donch_bot: number;
404
406
  id: string;
407
+ mod_rank: number;
405
408
  }
406
409
  declare interface LiveStatisticsEntryDTO {
407
410
  datetime: string;
@@ -414,6 +417,7 @@ declare interface LiveStatisticsEntryDTO {
414
417
  order_type: "buy" | "sell";
415
418
  moving_avg: number;
416
419
  id: string;
420
+ mod_rank: number;
417
421
  }
418
422
  export interface StatisticsCollectionDTO {
419
423
  statistics_closed: {
package/lib/index.js CHANGED
@@ -17843,30 +17843,36 @@ var primedModHistory = createAsyncCache(async () => {
17843
17843
  });
17844
17844
  const result = [];
17845
17845
  const { globalItemDict, globalItemNameToSlugDict } = await globalItemData.get();
17846
- for (let i = 0; i < primeModHistory.length; i++) {
17847
- const mod = primeModHistory[i];
17846
+ const minInterval = 500;
17847
+ let lastRequestTime = 0;
17848
+ for (const mod of primeModHistory) {
17848
17849
  const name2 = normalizeName(mod.Name);
17849
17850
  const slug = globalItemNameToSlugDict[name2];
17850
- if (slug) {
17851
- const item = globalItemDict[slug];
17852
- try {
17853
- const data = await getWFMItemStatistics(slug);
17854
- result.push({
17855
- name: item.i18n["zh-hans"]?.name,
17856
- last: mod.Last,
17857
- plats: data?.statistics_closed["90days"].at(-1)?.median
17858
- // Get medium price
17859
- });
17860
- } catch {
17861
- result.push({
17862
- name: item.i18n["zh-hans"]?.name,
17863
- last: mod.Last
17864
- });
17865
- }
17866
- await sleep(300);
17851
+ if (!slug) {
17852
+ result.push({ name: mod.Name, last: mod.Last });
17853
+ continue;
17854
+ }
17855
+ const item = globalItemDict[slug];
17856
+ const elapsed = Date.now() - lastRequestTime;
17857
+ if (elapsed < minInterval) {
17858
+ await sleep(minInterval - elapsed);
17859
+ }
17860
+ const data = await getWFMItemStatistics(slug);
17861
+ lastRequestTime = Date.now();
17862
+ if (data) {
17863
+ const zeroRankList = data.statistics_closed["90days"].filter(
17864
+ (e) => e.mod_rank === 0
17865
+ );
17866
+ const lastThree = zeroRankList.slice(-3);
17867
+ const avg = lastThree.length > 0 ? Math.round(lastThree.reduce((acc, e) => acc + e.median, 0) / lastThree.length * 10) / 10 : void 0;
17868
+ result.push({
17869
+ name: item.i18n["zh-hans"]?.name,
17870
+ last: mod.Last,
17871
+ plats: avg
17872
+ });
17867
17873
  } else {
17868
17874
  result.push({
17869
- name: mod.Name,
17875
+ name: item.i18n["zh-hans"]?.name,
17870
17876
  last: mod.Last
17871
17877
  });
17872
17878
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-warframe",
3
3
  "description": "WF Toolkit",
4
- "version": "1.5.2",
4
+ "version": "1.5.3",
5
5
  "license": "GPL-3.0",
6
6
  "scripts": {
7
7
  "build": "yakumo build",