Skip to content
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

feat: Add semver_range to dependency processing and improve logging #33

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions core/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def _process_version(self, item: Dict[str, str]):

license_id = self.license_cache.get(item["license"])
if not license_id:
self.logger.log(f"creating an entry for {item['license']}")
self.logger.log(f"License {item['license']} not found, creating entry.")
license_id = self.select_license_by_name(item["license"], create=True)
self.license_cache[item["license"]] = license_id

Expand Down Expand Up @@ -201,11 +201,22 @@ def insert_dependencies(self, dependency_generator: Iterable[dict[str, str]]):
self._insert_batch(DependsOn, dependencies)

def _process_depends_on(self, item: Dict[str, str]):
return DependsOn(
version_id=self.version_cache[item["version_id"]],
dependency_id=self.package_cache[item["crate_id"]],
semver_range=item["semver_range"],
).to_dict()
dependency_id = self.package_cache.get(item["crate_id"])
version_id = self.version_cache.get(item["version_id"])

if not dependency_id:
Copy link
Member

Choose a reason for hiding this comment

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

indent start

self.logger.log(f"Dependency package {item['crate_id']} not found, skipping.")
return None

if not version_id:
self.logger.log(f"Version {item['version_id']} not found, skipping dependency.")
return None

return DependsOn(
version_id=version_id,
dependency_id=dependency_id,
semver_range=item.get("semver_range"), # Add semver_range
).to_dict()
Copy link
Member

Choose a reason for hiding this comment

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

indent end


def insert_users(self, user_generator: Iterable[dict[str, str]], source_id: UUID):
def process_user(item: Dict[str, str]):
Expand Down