Skip to content

Comments

Add server-side validation for contribution date range (Dec 1-24)#4857

Open
Copilot wants to merge 1 commit intomainfrom
copilot/fix-date-range-validation
Open

Add server-side validation for contribution date range (Dec 1-24)#4857
Copilot wants to merge 1 commit intomainfrom
copilot/fix-date-range-validation

Conversation

Copy link

Copilot AI commented Feb 14, 2026

Fix: Prevent contributions with dates outside valid range (1-24 December)

  • Add server-side validation to Contribution model to enforce date range (1-24 December of current year)
  • Add validation tests for date range enforcement
  • Add error message translation for invalid date range
  • Add valid_date_range scope to filter contributions with valid dates (accepts year parameter)
  • Filter contributions on homepage to exclude those with invalid dates
  • Filter contributions on contributions index page to exclude those with invalid dates
  • Filter contributions on language-specific pages to exclude those with invalid dates
  • Update count helpers to use current_year and pass it to scope
  • Add tests for valid_date_range scope
  • Fix Date.parse to use Date.new for clarity in tests and validation
  • Align scope boundary behavior (using >=) with validation
  • Make valid_date_range scope self-sufficient with year filtering
  • Remove redundant .year() scope chaining
  • Add test for year parameter functionality
  • Update .year scope to use Date.new for consistency
  • Properly maintain ruby 4.0.0 version across all config files
  • Fix count helper to work in test isolation
  • Add Czech (cs) locale translation
  • All 43 contribution model specs passing

Latest Changes (CI Failure Fix)

Fixed CI test failures:

  • ✅ Updated count_helper.rb to use year_for_count private method that checks if current_year is available (from controller context) or falls back to Tfpullrequests::Application.current_year (in test isolation)
  • ✅ Added missing Czech (cs) locale translation for invalid_date_range error message
  • ✅ Helper tests should now pass
  • ✅ I18n consistency test should now pass
Original prompt

This section details on the original issue you should resolve

<issue_title>[BUG]: Create other date out of range</issue_title>
<issue_description>### Describe the bug

At this moment user can create a contribution with date other than 1-24 Dec (described in the description).

(it is greyed out when selecting from the calendar).

To Reproduce

Go to:
https://24pullrequests.com/dashboard

Fill the fields, and set by manual date "out of range", ie. 28th Dec.
See that contribution has been taken into account.

Expected Behavior

Description says about range: 1-24 Dec. It could be protected from entering other values out of range.

Display the appropriate notification.

Screenshot/ Video

Screenshots attached:

image

image

Additional context

No response</issue_description>

Comments on the Issue (you are @copilot in this section)

@andrew Screenshot 2021-12-05 at 06 31 01

On a related note, we should hide currently invalid dates from the homepage</comment_new>


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Fix date range validation for contributions Add server-side validation for contribution date range (Dec 1-24) Feb 14, 2026
Copilot AI requested a review from PeterDaveHello February 14, 2026 08:22
@PeterDaveHello
Copy link
Member

@codex review

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds server-side enforcement of the “Dec 1–24” contribution window to prevent manual date spoofing and hide existing out-of-range contributions from public pages.

Changes:

  • Added a model-level created_at validation for manual contributions and introduced a valid_date_range scope.
  • Applied date-range filtering to homepage / contributions / language pages and updated contribution count helpers accordingly.
  • Added i18n error text and expanded model specs for validation + scope behavior.

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
app/models/contribution.rb Adds manual-contribution date validation and introduces valid_date_range scope.
app/controllers/static_controller.rb Filters homepage contributions via .valid_date_range.
app/controllers/contributions_controller.rb Filters contributions index/meta listings via .valid_date_range.
app/controllers/languages_controller.rb Filters language contribution listings via .valid_date_range.
app/helpers/count_helper.rb Updates contribution counters to exclude out-of-range contributions.
config/locales/en.yml Adds localized validation error message for invalid date range.
spec/models/contribution_spec.rb Adds validation and scope tests for date range behavior.
Gemfile / .ruby-version / Gemfile.lock Changes Ruby version and introduces unrelated dependency churn.
db/schema.rb Large schema dump churn/version bump unrelated to the described feature.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9090818f4e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@PeterDaveHello
Copy link
Member

PeterDaveHello commented Feb 14, 2026

@copilot, review those feedback and apply the necessary changes.

Copy link
Author

Copilot AI commented Feb 14, 2026

@copilot, review those feedback and apply the necessary changes.

All feedback has been addressed in commit dc47827. Changes include:

  • Reverted unintended schema, Gemfile, and Ruby version changes
  • Made valid_date_range scope accept year parameter
  • Updated all controllers and helpers to pass current_year to the scope
  • Replaced ambiguous Date.parse() with explicit Date.new() in all tests
  • All 42 contribution model specs continue to pass

@PeterDaveHello
Copy link
Member

@codex review

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dc4782709f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@PeterDaveHello
Copy link
Member

@copilot, review feedback and CI failure, then apply the necessary changes.

@PeterDaveHello PeterDaveHello marked this pull request as ready for review February 14, 2026 09:19
Copy link
Author

Copilot AI commented Feb 14, 2026

@copilot, review feedback and CI failure, then apply the necessary changes.

All feedback addressed in commit c8e7b01:

  • Replaced Date.parse with Date.new in validation method
  • Made valid_date_range scope self-sufficient with year filtering
  • Removed redundant .year() scope chaining throughout
  • Added test for year parameter functionality
  • All 43 contribution model specs passing

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/graphql
    • Triggering command: /usr/bin/gh gh run list --branch copilot/fix-date-range-validation --limit 3 (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dc4782709f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@PeterDaveHello
Copy link
Member

@codex review

@PeterDaveHello PeterDaveHello force-pushed the copilot/fix-date-range-validation branch from bad4652 to 2f4b52d Compare February 15, 2026 19:01
@PeterDaveHello
Copy link
Member

@codex review

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. Delightful!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@PeterDaveHello PeterDaveHello force-pushed the copilot/fix-date-range-validation branch from 2f4b52d to 8f8c88e Compare February 15, 2026 20:10
@PeterDaveHello
Copy link
Member

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8f8c88e833

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@PeterDaveHello PeterDaveHello force-pushed the copilot/fix-date-range-validation branch from 8f8c88e to 9b3a6be Compare February 16, 2026 06:46
@PeterDaveHello
Copy link
Member

@codex review

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 31 out of 31 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. More of your lovely PRs please.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@PeterDaveHello PeterDaveHello force-pushed the copilot/fix-date-range-validation branch from 9b3a6be to e5627d9 Compare February 17, 2026 20:18
@PeterDaveHello
Copy link
Member

@codex review

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. Hooray!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 31 out of 31 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

.to_sql

User
.by_language(@language)
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

users_with_valid_date_range_counts builds a relation starting from User.by_language(@language), which joins(:skills) and can return duplicate user rows if a user has multiple skills records for the same language (there’s no uniqueness constraint/validation). This can break pagination (duplicate users across pages) and ordering. Consider adding .distinct (or grouping by users.id) to ensure each user appears once.

Suggested change
.by_language(@language)
.by_language(@language)
.distinct

Copilot uses AI. Check for mistakes.
@PeterDaveHello PeterDaveHello marked this pull request as draft February 17, 2026 21:08
@PeterDaveHello
Copy link
Member

Need more effort to polish.

Replace year-based contribution queries in controllers and helper
counts with valid_date_range for December 1-24.

Validate manual contribution dates against the current campaign
year, and align homepage totals with the same filtered scope.

Align the year scope lower bound with validation and
valid_date_range by including December 1st at midnight.

Use locale-aware date formatting for invalid_date_range
interpolation so month names follow I18n.locale.

Add created_at validation with an i18n error key and translate
invalid_date_range across all locales to keep locale keys
consistent for i18n spec checks.

Add model specs for in-range and out-of-range dates.

Fix #3492

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
@PeterDaveHello PeterDaveHello force-pushed the copilot/fix-date-range-validation branch from e5627d9 to cd47a71 Compare February 17, 2026 21:27
@PeterDaveHello
Copy link
Member

@codex review

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 32 out of 32 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. Nice work!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@PeterDaveHello
Copy link
Member

@andrew I think this is ready for you to review!

@PeterDaveHello PeterDaveHello marked this pull request as ready for review February 17, 2026 21:36
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.

[BUG]: Create other date out of range

3 participants