Skip to content

Control Booking Options, add search fallback and API credit stats - #14

Merged
hoangsvit merged 20 commits into
mainfrom
fix/booking-options-flag
Aug 26, 2026
Merged

Control Booking Options, add search fallback and API credit stats#14
hoangsvit merged 20 commits into
mainfrom
fix/booking-options-flag

Conversation

@hoangsvit

@hoangsvit hoangsvit commented Aug 26, 2026

Copy link
Copy Markdown
Member

Mục tiêu

Tách rõ quota theo từng SerpApi credential, không tự chạy Booking Options mỗi lần refresh, nhưng vẫn tận dụng credential Booking Options làm nguồn search dự phòng khi các credential tracking hết quota hoặc lỗi.

Thay đổi

  • Thêm cờ BOOKING_OPTIONS_ENABLED:
    • không có / rỗng / false => không gọi Booking Options enrichment;
    • true / 1 / yes / on => cho phép enrichment nếu có SERPAPI_BOOKING_API_KEY.
  • Giữ BOOKING_OPTIONS_LIMIT_PER_ROUTE để giới hạn số offer enrich.
  • Đổi thứ tự fallback search:
    1. SERPAPI_API_KEY
    2. SERPAPI_API_KEY_2
    3. SERPAPI_API_KEY_3
    4. SERPAPI_BOOKING_API_KEY làm last-resort Google Flights search credential.
  • Nếu booking credential đã phải dùng để tracking/search trong run đó thì skip Booking Options enrichment để tránh tiêu thêm credit ngay sau fallback.
  • Thêm scripts/update-api-usage.mjs gọi SerpApi Account API để lấy usage thật của từng credential/account: đã dùng, tổng tháng, còn lại, plan.
  • Ghi snapshot vào data/api-usage.json và tự cập nhật bảng usage trong README.md sau mỗi refresh.
  • README bổ sung bảng chi phí request theo flow hiện tại và ước tính 30 ngày.

Credit / request flow

  • Google Flights Search bình thường: 2 request / refresh (1 request mỗi chiều).
  • Booking Options: 0 khi tắt; mặc định tối đa 8 request / refresh khi bật (4 offer × 2 route).
  • Booking key search fallback: tối đa 2 search request khi các search credentials không dùng được; enrichment bị skip trong run đó.
  • SerpApi Account API: dùng để thống kê usage và không tính vào monthly search quota.

Dữ liệu mới

  • data/api-usage.json
  • Bảng SerpApi usage / credits trong README được workflow cập nhật tự động.

Lưu ý

Usage lấy từ Account API là usage theo account đứng sau từng credential. Nếu credential còn dùng ở project khác, README sẽ phản ánh cả phần usage đó.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 749653ec-ac4b-49f5-b3f4-3a3c2ca531c2


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

🌍 Web preview

Preview is pinned to commit 9d80c32 and updates automatically when the PR changes.

@hoangsvit hoangsvit changed the title Gate Booking Options enrichment behind an explicit flag Control Booking Options, add search fallback and API credit stats Aug 26, 2026
@hoangsvit
hoangsvit merged commit a9a821a into main Aug 26, 2026
2 checks passed
@hoangsvit
hoangsvit deleted the fix/booking-options-flag branch August 26, 2026 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant