Skip to content

fix(all_urls):SP-4237 add is_mined and package_hash filter condition…#12

Closed
agustingroh wants to merge 1 commit intomainfrom
fix/SP-4237-add-filter-conditions-for-not-mined-urls
Closed

fix(all_urls):SP-4237 add is_mined and package_hash filter condition…#12
agustingroh wants to merge 1 commit intomainfrom
fix/SP-4237-add-filter-conditions-for-not-mined-urls

Conversation

@agustingroh
Copy link
Copy Markdown
Contributor

@agustingroh agustingroh commented Apr 6, 2026

…s to all_urls queries

Summary by CodeRabbit

  • Bug Fixes

    • Refined query filtering to exclude incomplete and unmined data records from results.
  • Chores

    • Added debug logging for URL selection process.
    • Updated release notes with version 0.10.0 details.

@agustingroh agustingroh requested a review from scanoss-qg April 6, 2026 17:02
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 6, 2026

📝 Walkthrough

Walkthrough

This PR adds filtering constraints to exclude unmined records and empty package hashes across multiple data retrieval methods in the all_urls model. It includes corresponding changelog documentation and a debug logging statement in the component service.

Changes

Cohort / File(s) Summary
Changelog Documentation
CHANGELOG.md
Added version 0.10.0 release entry documenting the fix for query filters excluding unmined and empty-hash records.
Database Query Filters
pkg/models/all_urls.go
Appended AND u.is_mined != false AND u.package_hash != '' to WHERE clauses in GetURLsByPurlNameType, GetURLsByPurlNameTypeVersion, GetVersionsByPurlNameType, and CheckPurlByNameType methods.
Debug Logging
pkg/services/component.go
Added debug log statement in pickOneUrl method to log selected URLs for troubleshooting.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • scanoss-qg
  • isasmendiagus

Poem

🐰✨ Through the mines we hop with care,
Filtering hashes from thin air,
Empty buckets cast aside,
Let only treasured queries guide! 🔍

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: adding is_mined and package_hash filter conditions to all_urls queries, which matches the primary modifications across CHANGELOG.md, pkg/models/all_urls.go, and pkg/services/component.go.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/SP-4237-add-filter-conditions-for-not-mined-urls

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 and usage tips.

Copy link
Copy Markdown

@scanoss-qg scanoss-qg left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@CHANGELOG.md`:
- Line 12: Update the changelog entry to also list the CheckPurlByNameType query
as being modified: editing the line that currently mentions
GetURLsByPurlNameType, GetURLsByPurlNameTypeVersion, and
GetVersionsByPurlNameType to add CheckPurlByNameType (the function in
pkg/models/all_urls.go around the CheckPurlByNameType implementation) so the
release notes reflect that CheckPurlByNameType now also includes the `is_mined
!= false AND package_hash != ''` filter.

In `@pkg/models/all_urls.go`:
- Around line 74-76: The new WHERE predicates referencing all_urls.is_mined and
all_urls.package_hash in pkg/models/all_urls.go break older DBs; add a
compatibility check at startup (e.g., query PRAGMA table_info('all_urls') or
information_schema for your DB) to detect presence of columns is_mined and
package_hash, expose two booleans (hasIsMined, hasPackageHash), and change the
SQL builder(s) in pkg/models/all_urls.go that currently concatenate "AND
u.is_mined != false" / "AND u.package_hash != ''" (the three query strings
shown) to conditionally append those predicates only when the corresponding
boolean is true, or provide a migration path that adds the columns and fixtures
before using the new queries.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d1a855e4-6c20-43fc-a06d-87528e744bbe

📥 Commits

Reviewing files that changed from the base of the PR and between 16165f8 and a07275e.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • pkg/models/all_urls.go
  • pkg/services/component.go

Comment thread CHANGELOG.md

## [0.10.0] - 2026-04-06
### Fixed
- Added `is_mined != false AND package_hash != ''` filter conditions to `GetURLsByPurlNameType`, `GetURLsByPurlNameTypeVersion`, and `GetVersionsByPurlNameType` queries to exclude unmined and empty-hash records
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Changelog entry is missing one updated query method.

Line [12] documents three methods, but this PR also changes CheckPurlByNameType in pkg/models/all_urls.go (Lines [178-179]). Please include it to keep release notes accurate.

Suggested changelog tweak
-- Added `is_mined != false AND package_hash != ''` filter conditions to `GetURLsByPurlNameType`, `GetURLsByPurlNameTypeVersion`, and `GetVersionsByPurlNameType` queries to exclude unmined and empty-hash records
+- Added `is_mined != false AND package_hash != ''` filter conditions to `GetURLsByPurlNameType`, `GetURLsByPurlNameTypeVersion`, `GetVersionsByPurlNameType`, and `CheckPurlByNameType` queries to exclude unmined and empty-hash records
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- Added `is_mined != false AND package_hash != ''` filter conditions to `GetURLsByPurlNameType`, `GetURLsByPurlNameTypeVersion`, and `GetVersionsByPurlNameType` queries to exclude unmined and empty-hash records
- Added `is_mined != false AND package_hash != ''` filter conditions to `GetURLsByPurlNameType`, `GetURLsByPurlNameTypeVersion`, `GetVersionsByPurlNameType`, and `CheckPurlByNameType` queries to exclude unmined and empty-hash records
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@CHANGELOG.md` at line 12, Update the changelog entry to also list the
CheckPurlByNameType query as being modified: editing the line that currently
mentions GetURLsByPurlNameType, GetURLsByPurlNameTypeVersion, and
GetVersionsByPurlNameType to add CheckPurlByNameType (the function in
pkg/models/all_urls.go around the CheckPurlByNameType implementation) so the
release notes reflect that CheckPurlByNameType now also includes the `is_mined
!= false AND package_hash != ''` filter.

Comment thread pkg/models/all_urls.go
Comment on lines +74 to +76
" WHERE m.purl_type = $1 AND u.purl_name = $2" +
" AND u.is_mined != false AND u.package_hash != ''" +
" ORDER BY date DESC"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Blocking: new filters break queries on current DB schema.

The added predicates on Lines [75], [115], [148], and [179] are causing runtime SQL failures (no such column: ...is_mined) per pipeline logs. This currently breaks all affected lookup paths.

Please ship this with matching schema support (migration + fixtures) or add a compatibility path for DBs that don’t yet have all_urls.is_mined / all_urls.package_hash.

Also applies to: 114-116, 147-149, 178-179

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/models/all_urls.go` around lines 74 - 76, The new WHERE predicates
referencing all_urls.is_mined and all_urls.package_hash in
pkg/models/all_urls.go break older DBs; add a compatibility check at startup
(e.g., query PRAGMA table_info('all_urls') or information_schema for your DB) to
detect presence of columns is_mined and package_hash, expose two booleans
(hasIsMined, hasPackageHash), and change the SQL builder(s) in
pkg/models/all_urls.go that currently concatenate "AND u.is_mined != false" /
"AND u.package_hash != ''" (the three query strings shown) to conditionally
append those predicates only when the corresponding boolean is true, or provide
a migration path that adds the columns and fixtures before using the new
queries.

Copy link
Copy Markdown

@scanoss-qg scanoss-qg left a comment

Choose a reason for hiding this comment

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

Adding a parameter could be interesting for those cases where mined data is not needed

Comment thread pkg/models/all_urls.go
" LEFT JOIN versions v ON u.version_id = v.id" +
" WHERE m.purl_type = $1 AND u.purl_name = $2 ORDER BY date DESC"
" WHERE m.purl_type = $1 AND u.purl_name = $2" +
" AND u.is_mined != false AND u.package_hash != ''" +
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Could is_mined flag be configurable throw a parameter?

@agustingroh agustingroh closed this Apr 6, 2026
@agustingroh agustingroh deleted the fix/SP-4237-add-filter-conditions-for-not-mined-urls branch April 30, 2026 14:06
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