-
Notifications
You must be signed in to change notification settings - Fork 0
feat: adds matching markets for sports by date, ticker, or slug #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
7229ce8
feat: adds matching markets for sports by date, ticker, or slug
bougyman cbffc30
test: removes :nocov: from params blocks. They are working now
bougyman b7bf65f
ci: adds copilot instructions
bougyman a923c7a
test: adds spec for market_matchers method
bougyman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| # Copilot Code Review Guidelines | ||
|
|
||
| --- | ||
| This file configures GitHub Copilot Code Review according to GitHub’s official guidance: [Use Copilot Code Review](https://docs.github.com/en/copilot/how-tos/use-copilot-agents/request-a-code-review/use-code-review). | ||
|
|
||
| ## Project Context | ||
|
|
||
| **Language:** Ruby ~> 4 | ||
| **Framework:** [trailblazer](https://trailblazer.to/) | ||
| **Testing:** [minitest](https://docs.seattlerb.org/minitest/) following [BetterSpecs](https://evenbetterspecs.github.io/) guidelines | ||
|
|
||
| --- | ||
|
|
||
| ## Purpose & Scope | ||
|
|
||
| Focused inline review guidance for Ruby pull requests—style, tests, performance, and tone. (CI setup, contributor workflows, and documentation policies belong in separate docs.) | ||
|
|
||
| --- | ||
|
|
||
| ## 1. Style Guides | ||
|
|
||
| > ⚠️ **Be constructive:** Frame style feedback as suggestions (e.g., “Consider using…”). | ||
|
|
||
| All standard rules follow the [Shopify Ruby Style Guide](https://ruby-style-guide.shopify.dev/); only team-specific overrides are listed below: | ||
| - Indentation and line length enforced by RuboCop per project config. | ||
| - Use guard clauses, and explicit receivers. | ||
| - Prefer Railway Oriented Programming (ROP) for error handling and flow. | ||
| - Leverage dry-rb conventions and Trailblazer patterns for clarity and maintainability. | ||
| - Keep methods short. 1 line is fine. 5 is a lot. At 7, you should consider extracting a method. | ||
|
|
||
| --- | ||
|
|
||
| ## 2. Tone and Delivery | ||
|
|
||
| > 🤝 **Be succinct:** Don't overwhelm with too many minor issues; prioritize key improvements. | ||
|
|
||
| - Use phrasing like “Consider extracting…” or “You might simplify…” rather than absolutes. | ||
| - Keep comments concise—2–3 sentences max. | ||
|
|
||
| --- | ||
|
|
||
| ## 3. Conventions & Readability | ||
|
|
||
| > ✨ **Keep it clear:** Propose naming and structure that clarify intent. | ||
|
|
||
| - **SOLID principles:** Single responsibility; inject dependencies via initializers. | ||
| - **Descriptive names:** Recommend clear class, method, and variable names. | ||
| - **DRY:** Suggest extracting duplicate logic into modules or service objects. | ||
| - **Method size:** Flag methods >= 8 lines; suggest splitting into helpers. | ||
| - Ensure files have EOF newline. | ||
| - Flag trailing white space in code and comments. | ||
| - Always ensure rubocop runs cleanly. | ||
|
|
||
| --- | ||
|
|
||
| ## 4. Testing and Coverage | ||
|
|
||
| > 🧪 **Be thorough:** Highlight gaps in meaningful test coverage. | ||
|
|
||
| - Flag missing or outdated specs for changed behaviors (unit, integration, request). | ||
| - Suggest tests for edge cases: error conditions, invalid inputs, boundary values, and potential `nil` handling or pointer exceptions. Follow best practices from the [BetterSpecs style guide](https://evenbetterspecs.github.io/). | ||
| - Encourage descriptive `context` blocks and example names per [BetterSpecs](https://evenbetterspecs.github.io/). | ||
| - Flag missing specs when logic is updated but no tests were added or modified | ||
| --- | ||
|
|
||
| ## 5. Performance and Security | ||
|
|
||
| > 🚀 **Guard quality:** Call out patterns that may hurt performance or security. | ||
|
|
||
| - Detect potential N+1 queries; suggest `includes` or batching. | ||
| - Attempt to identify O(n^2) or O(n log n) algorithms; recommend more efficient alternatives. | ||
| - Flag raw SQL, unsanitized interpolation, or other patterns that could introduce potential SQL injection vulnerabilities; recommend parameter binding and Sequel-based alternatives. Build these into a model, avoid raw sequel unless absolutely necessary. | ||
| - Identify unescaped user input in route methods | ||
|
|
||
| --- | ||
|
|
||
| ## 6. Commit Message and PR title guidelines | ||
|
|
||
| > 📝 **Be clear:** Ensure commit messages and PR titles reflect changes accurately. | ||
|
|
||
| - We use Conventional Commits. Ensure commit messages follow the format: `<type>(<scope>): <description>`. | ||
| - We use Semantic PR titles as well, ensure PR titles also match the conventional commit format. | ||
|
|
||
| ## 7. Balancing Feedback | ||
|
|
||
| > ⚖️ **Be selective:** Focus on the highest-impact issues. | ||
|
|
||
| - Limit critical suggestions to the top 3–5 items per review. | ||
| - Combine minor style tweaks into a single comment when possible. | ||
|
|
||
| --- | ||
|
|
||
| ## 8. Quick Reference | ||
|
|
||
| - **Max comment length:** 2–3 sentences. | ||
| - **Severity tags:** `[Major]`, `[Medium]`, `[Minor]`. | ||
| - **Mandatory header:** `Enable frozen-string-literal`. | ||
| - **Top issues:** 3–5 critical comments. | ||
|
|
||
| --- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| module Rubyists | ||
| module Domeapi | ||
| # Matching Markets API endpoints | ||
| class MatchingMarkets | ||
| SPORTS = %w[nfl mlb cfb nba nhl cbb].freeze | ||
|
|
||
| # Filter for matching markets sports | ||
| class SportsFilter < Contract | ||
| propertize(%i[sport date]) | ||
|
|
||
| validation do | ||
| params do | ||
| required(:sport).filled(:string, included_in?: SPORTS) | ||
| required(:date).filled(:string, format?: /\A\d{4}-\d{2}-\d{2}\z/) | ||
| end | ||
| end | ||
| end | ||
|
|
||
| # Filter for matching markets | ||
| class Filter < Contract | ||
| propertize(%i[polymarket_market_slug kalshi_event_ticker]) | ||
|
|
||
| validation do | ||
| params do | ||
| optional(:polymarket_market_slug).maybe(Types::PolymarketMarketSlug) | ||
| optional(:kalshi_event_ticker).maybe(Types::KalshiEventTicker) | ||
| end | ||
|
|
||
| rule(:polymarket_market_slug, :kalshi_event_ticker) do | ||
| if !values[:polymarket_market_slug] && !values[:kalshi_event_ticker] | ||
| key.failure('Either polymarket_market_slug or kalshi_event_ticker must be provided') | ||
| end | ||
| end | ||
| end | ||
| end | ||
|
|
||
| attr_reader :client | ||
|
|
||
| # @param client [Rubyists::Domeapi::Client] | ||
| # | ||
| # @return [void] | ||
| def initialize(client = Rubyists::Domeapi::Client.new) | ||
| @client = client | ||
| end | ||
|
|
||
| # List matching markets | ||
| # | ||
| # @param filter [Filter|Hash] Filter options | ||
| # | ||
| # @return [Hash|Array] resource data | ||
| def sports(filter = Filter.new(Filter::Properties.new)) | ||
| filter = Filter.new(Filter::Properties.new(**filter)) if filter.is_a?(Hash) | ||
| raise ArgumentError, filter.errors.full_messages.join(', ') unless filter.validate({}) | ||
|
|
||
| client.get('matching-markets/sports', params: filter.to_h) | ||
| end | ||
|
|
||
| # List matching markets for a specific sport and date | ||
| # | ||
| # @param filter [SportsFilter|Hash] Filter options | ||
| # | ||
| # @return [Hash|Array] resource data | ||
| def sports_by_date(filter = SportsFilter.new(SportsFilter::Properties.new)) | ||
| filter = prepare_sports_filter(filter) | ||
| raise ArgumentError, filter.errors.full_messages.join(', ') unless filter.validate({}) | ||
|
|
||
| client.get("matching-markets/sports/#{filter.sport}", params: { date: filter.date }) | ||
| end | ||
|
|
||
| SPORTS.each do |sport| | ||
| define_method("#{sport}_on") do |date| | ||
| sports_by_date(sport: sport, date: date) | ||
| end | ||
|
|
||
| define_singleton_method("#{sport}_on") do |date| | ||
| new.send("#{sport}_on", date) | ||
| end | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def prepare_sports_filter(filter) | ||
| return filter unless filter.is_a?(Hash) | ||
|
|
||
| filter[:date] = filter[:date].strftime('%Y-%m-%d') if filter[:date].respond_to?(:strftime) | ||
| SportsFilter.new(SportsFilter::Properties.new(**filter)) | ||
| end | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing test coverage for the new
matching_marketsmethod added to the Client class. Similar to the existing test forpolymarketon line 32-34, there should be a test verifying thatclient.matching_marketsreturns an instance ofRubyists::Domeapi::MatchingMarkets.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot open a new pull request to apply changes based on this feedback
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot open a new pull request to apply changes based on this feedback. Make sure all of your commit messages and PR titles pass the Conventional Commits action check.