Skip to content

Improve segments query (and debugging tools)#553

Merged
irees merged 5 commits intomainfrom
segments-debug
Jan 13, 2026
Merged

Improve segments query (and debugging tools)#553
irees merged 5 commits intomainfrom
segments-debug

Conversation

@irees
Copy link
Copy Markdown
Contributor

@irees irees commented Jan 9, 2026

This PR adds debugging capabilities and improvements to the Transitland server, particularly around authorization and segment queries.

Changes

New --disable-auth Server Flag

  • Adds a --disable-auth command-line flag to the transitland server command
  • When enabled, disables all feed authorization checks by treating all feeds as public
  • Useful for local development and debugging scenarios
  • Implements a globalAdminChecker that always returns true for CheckGlobalAdmin

Query Logger Enhancement

  • Enables trace-level logging in the QueryLogger when the log level is set to TraceLevel
  • Adds Trace: true parameter for more detailed query logging

Segment Query Improvements

  • Refactors SegmentsByFeedVersionIDs to use a more efficient subquery with ROW_NUMBER() window function
    • Uses PARTITION BY feed_version_id to properly limit results per feed version
    • Replaces the previous lateralWrap approach
  • Adds a new segmentSelect helper function for consistent segment queries
  • Updates SegmentsByIDs to use the new segmentSelect function instead of quickSelect

@github-actions
Copy link
Copy Markdown

github-actions bot commented Jan 9, 2026

Generated Code Check ✅

All generated code is up to date.

@irees irees changed the title Segments debug Improve segments query (and improve debugging tools) Jan 13, 2026
@irees irees changed the title Improve segments query (and improve debugging tools) Improve segments query (and debugging tools) Jan 13, 2026
@irees irees marked this pull request as ready for review January 13, 2026 03:00
Copilot AI review requested due to automatic review settings January 13, 2026 03:00
Copy link
Copy Markdown
Contributor

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 adds debugging capabilities and improves segment query performance in the Transitland server, with a focus on development tools and query optimization.

Changes:

  • Adds a --disable-auth server flag to bypass authorization checks for local development
  • Enables trace-level logging in QueryLogger when log level is set to TraceLevel
  • Refactors SegmentsByFeedVersionIDs to use a more efficient window function approach with ROW_NUMBER() instead of LATERAL joins
  • Introduces a segmentSelect helper function for consistent segment queries

Reviewed changes

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

File Description
server/finders/dbfinder/segment.go Refactors segment queries to use window functions and adds a new segmentSelect helper for better maintainability
cmds/server_cmd.go Adds DisableAuth flag and globalAdminChecker implementation, enables trace logging in QueryLogger
doc/cli/transitland_server.md Documents the new --disable-auth flag

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

@irees irees merged commit 40c610b into main Jan 13, 2026
12 checks passed
@irees irees deleted the segments-debug branch January 13, 2026 03:21
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