| 49 | } |
| 50 | |
| 51 | protected async fetch( |
| 52 | username: string, |
| 53 | site: "us" | "cn", |
| 54 | headers: Record<string, string>, |
| 55 | ): Promise<FetchedData> { |
| 56 | this.log("fetching", username, site); |
| 57 | const cache_key = `https://leetcode-stats-card.local/data-${username.toLowerCase()}-${site}`; |
| 58 | console.log("cache_key", cache_key); |
| 59 | |
| 60 | if (cache_key in this.fetches) { |
| 61 | return this.fetches[cache_key]; |
| 62 | } |
| 63 | this.fetches[cache_key] = this._fetch(username, site, headers, cache_key); |
| 64 | this.fetches[cache_key].finally(() => { |
| 65 | delete this.fetches[cache_key]; |
| 66 | }); |
| 67 | return this.fetches[cache_key]; |
| 68 | } |
| 69 | |
| 70 | protected async _fetch( |
| 71 | username: string, |