Skip to content

feat: use public api for github metrics#26

Merged
artob merged 1 commit into
masterfrom
feat/use-public-api-for-stats
Jul 4, 2025
Merged

feat: use public api for github metrics#26
artob merged 1 commit into
masterfrom
feat/use-public-api-for-stats

Conversation

@shelegdmitriy

Copy link
Copy Markdown
Member

This pull request introduces significant changes to the codebase, primarily focused on migrating from GitHub API-based data fetching to a new public API, simplifying environment setup, and improving data handling and organization. Key updates include removing the dependency on GitHub tokens, introducing new API endpoints, and enhancing the metadata processing logic.

Migration to Public API:

  • src/lib/config.ts: Added ZUPLO_API_BASE and ASIMOV_PLATFORM_ORG_NAME constants to support the new public API endpoints for fetching module and platform data. [1] [2]
  • src/lib/github.ts: Replaced GitHub API-based methods with new methods (fetchMetricsData and fetchPlatformData) to retrieve data from the public API. Removed token-based authentication and rate limit handling. [1] [2]

Environment Setup Simplification:

  • .env.example: Removed the GITHUB_TOKEN placeholder since environment variables are no longer required.
  • README.md: Updated setup instructions to reflect the removal of GitHub token requirements and clarified the data source as the ASIMOV Platform API. [1] [2]

Metadata and Data Handling Enhancements:

  • src/lib/github.ts: Enhanced module metadata parsing and introduced deduplication logic for data sources using unique identifiers. Added support for handling URL patterns in addition to URL prefixes. [1] [2]
  • src/lib/types.ts: Added id field to the DataSource interface for uniquely identifying data sources.

Updates to Components:

Removal of Legacy Code:

@shelegdmitriy
shelegdmitriy requested a review from Copilot July 2, 2025 15:19
@shelegdmitriy shelegdmitriy added the enhancement New feature or request label Jul 2, 2025
@shelegdmitriy
shelegdmitriy temporarily deployed to feat/use-public-api-for-stats - asimov.directory PR #26 July 2, 2025 15:20 — with Render Destroyed

This comment was marked as outdated.

@shelegdmitriy
shelegdmitriy requested a review from artob July 2, 2025 15:24
@artob artob self-assigned this Jul 4, 2025
@artob
artob requested a review from Copilot July 4, 2025 03:10
@artob
artob merged commit f04aab1 into master Jul 4, 2025
1 check passed
@artob
artob deleted the feat/use-public-api-for-stats branch July 4, 2025 03:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 migrates data fetching from the GitHub API to a new public API, removes GitHub token requirements, and enhances metadata parsing with deduplication logic.

  • Switched all repository and stats endpoints to use ZUPLO_API_BASE public API
  • Simplified server routes and removed token/rate-limit handling
  • Added unique IDs, URL pattern support, and updated Svelte components to use source.id

Reviewed Changes

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

Show a summary per file
File Description
src/lib/github.ts Replaced GitHub API calls with public API methods; added parsing, hashing, and dedupe logic
src/lib/types.ts Added id to DataSource and created_at to GitHubModule
src/routes/api/sources/+server.ts Updated import to use githubApi singleton
src/routes/api/modules/+server.ts Removed token instantiation and rate-limit code; updated githubApi usage
src/components/SourceCard.svelte Switched iteration key to source.id and updated imports
src/components/GitHubStats.svelte Updated org URLs to use asimovModulesOrgUrl and asimovPlatformOrgUrl
src/lib/config.ts Added ZUPLO_API_BASE and ASIMOV_PLATFORM_ORG_NAME constants
README.md Removed token setup instructions; updated numbering and API description
.env.example Removed GITHUB_TOKEN placeholder
Comments suppressed due to low confidence (3)

README.md:53

  • [nitpick] The step numbering jumps (the original steps were removed), which may confuse readers. Renumber the steps sequentially (e.g., change this from '3.' to '1.') or adjust the formatting for clarity.
3. **Start the development server**

src/lib/github.ts:36

  • This new public API method (fetchMetricsData) isn’t covered by existing tests. Consider adding unit or integration tests with mocked fetch responses to validate success and error paths.
	private async fetchMetricsData(): Promise<ApiMetricsResponse> {

Comment thread src/lib/github.ts
const metadata = this.parseModuleMetadata(apiModule.manifestYAML || null);

return {
id: Math.abs(this.hashCode(apiModule.name)),

Copilot AI Jul 4, 2025

Copy link

Choose a reason for hiding this comment

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

The convertApiModuleToGitHubModule method adds an id property to the returned object, but the GitHubModule interface in types.ts isn’t updated to include id. This mismatch will break your TypeScript checks; either add id to the GitHubModule interface or remove it here.

Copilot uses AI. Check for mistakes.
Comment thread src/lib/types.ts
}

export interface DataSource {
id: string; // Unique identifier for the data source

Copilot AI Jul 4, 2025

Copy link

Choose a reason for hiding this comment

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

The DataSource interface defines id but missing other fields (module_name, module_label, flows, rdf) that are pushed in github.ts. This leads to type mismatches and runtime errors. Update the interface to include these properties.

Copilot uses AI. Check for mistakes.
{#each endpointSources as source (source.module_name)}
{#each endpointSources as source (source.id)}
<a
href="https://github.com/asimov-modules/{source.module_name}"

Copilot AI Jul 4, 2025

Copy link

Choose a reason for hiding this comment

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

The link references source.module_name, but after migrating to use source.id, many data sources (from URL prefixes) no longer have module_name defined. This will result in broken links. Ensure each DataSource includes module_name or update the template to use the correct field.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants