Skip to content

Conversation

@owens1127
Copy link
Contributor

This PR modifies the blacklist logic to respect the instance whitelist flag. When an instance has is_whitelisted set to true, it will never be marked as blacklisted, even if there's a blacklist entry.

Changes

  • Modified getInstance, getActivities, and getInstances to check is_whitelisted before marking an instance as blacklisted
  • Whitelisted instances are now excluded from blacklist status: (b.instance_id IS NOT NULL AND NOT instance.is_whitelisted) AS "isBlacklisted"
  • Added test for instance 16707634209 to verify whitelist behavior

Testing

  • Added test case using pgcr 16707634209 to verify that whitelisted instances are not marked as blacklisted

- Modified getInstance, getActivities, and getInstances to check is_whitelisted
- Whitelisted instances are never marked as blacklisted, even if they have a blacklist entry
- Added test for instance 16707634209 to verify whitelist behavior
Copilot AI review requested due to automatic review settings January 2, 2026 21:41
- Added test in history.test.ts to verify whitelisted instances are not blacklisted
- Added test in instances.test.ts to verify whitelisted instances are not blacklisted
- Both tests use instance 16707634209 to verify the whitelist behavior
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

This PR modifies the blacklist logic to respect instance whitelist status. When an instance has is_whitelisted set to true, it will no longer be marked as blacklisted, even if a blacklist entry exists for it.

Key Changes:

  • Updated SQL queries in three service functions to check is_whitelisted before marking instances as blacklisted
  • The new logic: (b.instance_id IS NOT NULL AND NOT instance.is_whitelisted) AS "isBlacklisted"
  • Added a test case for getInstance to verify that whitelisted instances return isBlacklisted: false

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

File Description
src/services/instance/instance.ts Modified getInstance query to exclude whitelisted instances from blacklist status
src/services/player-instances/history.ts Modified getActivities query to exclude whitelisted instances from blacklist status
src/services/player-instances/instances.ts Modified getInstances query to exclude whitelisted instances from blacklist status
src/services/instance/instance.test.ts Added test case to verify whitelisted instances are not marked as blacklisted

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

CASE WHEN av.is_contest_eligible THEN date_completed < COALESCE(contest_end, TIMESTAMP 'epoch') ELSE false END AS "isContest",
date_completed < COALESCE(week_one_end, TIMESTAMP 'epoch') AS "isWeekOne",
b.instance_id IS NOT NULL AS "isBlacklisted"
(b.instance_id IS NOT NULL AND NOT instance.is_whitelisted) AS "isBlacklisted"
Copy link

Copilot AI Jan 2, 2026

Choose a reason for hiding this comment

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

The expression NOT instance.is_whitelisted may not handle NULL values as expected. In SQL, NOT NULL evaluates to NULL (not FALSE), which could cause instances with NULL is_whitelisted values to be excluded from the blacklist when they should be included. Consider using COALESCE(instance.is_whitelisted, false) to treat NULL as false, ensuring the logic works as: (b.instance_id IS NOT NULL AND NOT COALESCE(instance.is_whitelisted, false))

Suggested change
(b.instance_id IS NOT NULL AND NOT instance.is_whitelisted) AS "isBlacklisted"
(b.instance_id IS NOT NULL AND NOT COALESCE(instance.is_whitelisted, false)) AS "isBlacklisted"

Copilot uses AI. Check for mistakes.
CASE WHEN av.is_contest_eligible THEN date_completed < COALESCE(contest_end, TIMESTAMP 'epoch') ELSE false END AS "isContest",
date_completed < COALESCE(week_one_end, TIMESTAMP 'epoch') AS "isWeekOne",
bi.instance_id IS NOT NULL AS "isBlacklisted",
(bi.instance_id IS NOT NULL AND NOT instance.is_whitelisted) AS "isBlacklisted",
Copy link

Copilot AI Jan 2, 2026

Choose a reason for hiding this comment

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

The expression NOT instance.is_whitelisted may not handle NULL values as expected. In SQL, NOT NULL evaluates to NULL (not FALSE), which could cause instances with NULL is_whitelisted values to be excluded from the blacklist when they should be included. Consider using COALESCE(instance.is_whitelisted, false) to treat NULL as false, ensuring the logic works as: (bi.instance_id IS NOT NULL AND NOT COALESCE(instance.is_whitelisted, false))

Suggested change
(bi.instance_id IS NOT NULL AND NOT instance.is_whitelisted) AS "isBlacklisted",
(bi.instance_id IS NOT NULL AND NOT COALESCE(instance.is_whitelisted, false)) AS "isBlacklisted",

Copilot uses AI. Check for mistakes.
CASE WHEN av.is_contest_eligible THEN date_completed < COALESCE(contest_end, TIMESTAMP 'epoch') ELSE false END AS "isContest",
date_completed < COALESCE(week_one_end, TIMESTAMP 'epoch') AS "isWeekOne",
b.instance_id IS NOT NULL AS "isBlacklisted",
(b.instance_id IS NOT NULL AND NOT instance.is_whitelisted) AS "isBlacklisted",
Copy link

Copilot AI Jan 2, 2026

Choose a reason for hiding this comment

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

The expression NOT instance.is_whitelisted may not handle NULL values as expected. In SQL, NOT NULL evaluates to NULL (not FALSE), which could cause instances with NULL is_whitelisted values to be excluded from the blacklist when they should be included. Consider using COALESCE(instance.is_whitelisted, false) to treat NULL as false, ensuring the logic works as: (b.instance_id IS NOT NULL AND NOT COALESCE(instance.is_whitelisted, false))

Suggested change
(b.instance_id IS NOT NULL AND NOT instance.is_whitelisted) AS "isBlacklisted",
(b.instance_id IS NOT NULL AND NOT COALESCE(instance.is_whitelisted, false)) AS "isBlacklisted",

Copilot uses AI. Check for mistakes.
CASE WHEN av.is_contest_eligible THEN date_completed < COALESCE(contest_end, TIMESTAMP 'epoch') ELSE false END AS "isContest",
date_completed < COALESCE(week_one_end, TIMESTAMP 'epoch') AS "isWeekOne",
bi.instance_id IS NOT NULL AS "isBlacklisted",
(bi.instance_id IS NOT NULL AND NOT instance.is_whitelisted) AS "isBlacklisted",
Copy link

Copilot AI Jan 2, 2026

Choose a reason for hiding this comment

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

The whitelist behavior change should be tested in the getActivities function as well, similar to the test added for getInstance. This ensures that whitelisted instances are not marked as blacklisted when retrieved through player activity history.

Copilot uses AI. Check for mistakes.
CASE WHEN av.is_contest_eligible THEN date_completed < COALESCE(contest_end, TIMESTAMP 'epoch') ELSE false END AS "isContest",
date_completed < COALESCE(week_one_end, TIMESTAMP 'epoch') AS "isWeekOne",
b.instance_id IS NOT NULL AS "isBlacklisted",
(b.instance_id IS NOT NULL AND NOT instance.is_whitelisted) AS "isBlacklisted",
Copy link

Copilot AI Jan 2, 2026

Choose a reason for hiding this comment

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

The whitelist behavior change should be tested in the getInstances function as well, similar to the test added for getInstance. This ensures that whitelisted instances are not marked as blacklisted when retrieved through player instance queries.

Copilot uses AI. Check for mistakes.
- Use COALESCE to treat NULL is_whitelisted as false
- Prevents NULL values from causing incorrect blacklist status
- Updated getInstance, getActivities, and getInstances queries
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.

2 participants