Skip to content

Add the CRUD endpoints to manage code references against a given feature #5730

Description

@matthewelwell

Task list

  • Define the data model to store code references in the database.
    Recommendation:
    FeatureFlagCodeReferencesScan:
        project: Project
        created_at: datetime
        repository_url: str
        revision: str
        code_references:
          - feature_name: <str>
            file_path: <str>
            line_number: <int>
          - ...
        ...
    
  • Implement view to submit code references (from CI).
    # /api/v1/projects/{project_pk}/feature-code-references/
    repository_url: https://github.com/Flagsmith/flagsmith
    revision: <commit_hash>
    code_references:
      - feature_name: segment_cloning
        file_path: api/something/foo/bar.py
        line_number: 32
      - feature_name: <str>
        file_path: <str>
        line_number: <int>
      - ...
  • Fetch code references for one feature flag (for the feature detail UI).
    # /api/v1/projects/{project_pk}/features/{feature_pk}/code-references/
    - repository_url: <str>
      last_successful_repository_scanned_at: <timestamp>
      last_feature_found_at: <timestamp>
      code_references:
        - file_path: <str>
          line_number: <int>
          permalink: <str>  # For now only GitHub
          vcs_revision: <str>
        - ...
    - 
  • Add code reference counts to the feature list endpoint (for the list UI).
    # /api/v1/projects/{project_pk}/features/
    ...
    results:
      - id: <int>
        name: <str>
        ...
        code_references_counts:
          - repository_url: <str>
            count: <int>
            last_successful_repository_scanned_at: <timestamp>
            last_feature_found_at: <timestamp>
          - ...
      - ...
  • POST to the new endpoint from the CI job (Build the github action logic to run on a crontab to identify code references for each feature in a given project #5731).

Note

  • URLs and schemas above were aligned between @Zaimwa9 and @emyller in effort to keep things simple though flexible for extension after the PoC.
  • JSON is suggested as to avoid flooding the database with a multi-table spamming of tuples.
  • We might need indexes to help filtering in JSON blobs by "feature_name", "created_at".

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions