feat(report): improve daily intelligence UX and price tracking
Some checks failed
CI / go-test (push) Has been cancelled
CI / scripts-regression (push) Has been cancelled
CI / frontend-build (push) Has been cancelled
CI / docker-build (push) Has been cancelled

This commit is contained in:
phamnazage-jpg
2026-05-27 17:23:08 +08:00
parent f274621013
commit f5b373caf4
29 changed files with 4257 additions and 801 deletions

View File

@@ -101,6 +101,17 @@ func fetchSubscriptionPage(url string, fixture string, client *http.Client) (str
return string(data), nil
}
body, err := fetchSubscriptionPageWithRetry(url, client)
if err == nil {
return body, nil
}
if markdownURL, ok := markdownFallbackURL(url, err); ok {
return fetchSubscriptionPageWithRetry(markdownURL, client)
}
return "", err
}
func fetchSubscriptionPageWithRetry(url string, client *http.Client) (string, error) {
var lastErr error
for attempt := 1; attempt <= subscriptionFetchMaxAttempts; attempt++ {
body, retryable, err := fetchSubscriptionPageOnce(url, client)
@@ -116,6 +127,7 @@ func fetchSubscriptionPage(url string, fixture string, client *http.Client) (str
return "", lastErr
}
func fetchSubscriptionPageOnce(url string, client *http.Client) (string, bool, error) {
req, err := http.NewRequest(http.MethodGet, url, nil)
if err != nil {
@@ -146,6 +158,20 @@ func fetchSubscriptionPageOnce(url string, client *http.Client) (string, bool, e
return normalizeSubscriptionPage(string(body)), false, nil
}
func markdownFallbackURL(url string, err error) (string, bool) {
if strings.TrimSpace(url) == "" || err == nil {
return "", false
}
lower := strings.ToLower(err.Error())
if !strings.Contains(lower, "status 403") && !strings.Contains(lower, "forbidden") {
return "", false
}
if strings.HasSuffix(url, ".md") {
return "", false
}
return strings.TrimRight(url, "/") + ".md", true
}
func isRetriableSubscriptionFetchError(err error) bool {
if err == nil {
return false