Introduces NormalizedMergeRequest transformer and updates discussion
normalization to handle both issue and MR discussions polymorphically.
New transformers:
- NormalizedMergeRequest: Transforms API MergeRequest to database row,
extracting labels/assignees/reviewers into separate collections for
junction table insertion. Handles draft detection, detailed_merge_status
preference over deprecated merge_status, and merge_user over merged_by.
Discussion transformer updates:
- NormalizedDiscussion now takes noteable_type ("Issue" | "MergeRequest")
and noteable_id for polymorphic FK binding
- normalize_discussions_for_issue(): Convenience wrapper for issues
- normalize_discussions_for_mr(): Convenience wrapper for MRs
- DiffNote position fields (type, line_range, SHA triplet) now extracted
from API position object for code review context
Design decisions:
- Transformer returns (normalized_item, labels, assignees, reviewers)
tuple for efficient batch insertion without re-querying
- Timestamps converted to ms epoch for SQLite storage consistency
- Optional fields use map() chains for clean null handling
The polymorphic discussion approach allows reusing the same discussions
and notes tables for both issues and MRs, with noteable_type + FK
determining the parent relationship.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
15 lines
498 B
Rust
15 lines
498 B
Rust
//! Transformers for converting GitLab API responses to local schema.
|
|
|
|
pub mod discussion;
|
|
pub mod issue;
|
|
pub mod merge_request;
|
|
|
|
pub use discussion::{
|
|
NormalizedDiscussion, NormalizedNote, NoteableRef, transform_discussion,
|
|
transform_mr_discussion, transform_notes, transform_notes_with_diff_position,
|
|
};
|
|
pub use issue::{IssueRow, IssueWithMetadata, MilestoneRow, transform_issue};
|
|
pub use merge_request::{
|
|
MergeRequestWithMetadata, NormalizedMergeRequest, transform_merge_request,
|
|
};
|