-
Notifications
You must be signed in to change notification settings - Fork 0
[feat(backend)] Add GitHub contributions API endpoint #11
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
61a8997
fix: update GHCR_PAT variable description for clarity and add to clou…
nxdun 137c473
fix: add github_pat and github_username fields to AppConfig in test c…
nxdun eb8758b
feat: add contributions request templates for default and specific users
nxdun 1a29691
feat: integrate contributions service and update configuration for Gi…
nxdun 89ed622
feat: implement contributions service and related models, routes, and…
nxdun 6254fd8
feat: add contributions service initialization in test state with opt…
nxdun 555c58e
feat: enhance contributions service with color mapping and validation…
nxdun aa9e679
fix: correct syntax for GITHUB_PAT assignment in cloud-init template
nxdun b718893
feat: update dependencies and remove async-trait from Cargo.toml
nxdun 9423a8e
feat: add GitHub GraphQL URL configuration and update contributions s…
nxdun a4a56fe
fix: ensure proper formatting of order property in contributions requ…
nxdun 9cf1f44
fix: correct interval duration for cache cleaning in ContributionsSer…
nxdun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
postman/collections/Nadzu API/Contributions (Default User).request.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| $kind: http-request | ||
| name: Contributions (Default User) | ||
| url: "{{base_url}}/api/v1/contributions" | ||
| method: GET | ||
| scripts: | ||
| - type: afterResponse | ||
| code: >- | ||
| pm.test("Status is 200", function () { | ||
| pm.response.to.have.status(200); | ||
| }); | ||
|
|
||
| pm.test("Response matches expected schema", function () { | ||
| var jsonData = pm.response.json(); | ||
| pm.expect(jsonData.username).to.be.a('string'); | ||
| pm.expect(jsonData.meta.provider).to.eql('github'); | ||
| pm.expect(jsonData.meta.schemaVersion).to.eql(1); | ||
| pm.expect(jsonData.cells).to.be.an('array'); | ||
| pm.expect(jsonData.months).to.be.an('array'); | ||
| pm.expect(jsonData.summary).to.have.property('totalWeeks'); | ||
| }); | ||
| language: text/javascript | ||
| order: 3000 |
22 changes: 22 additions & 0 deletions
22
postman/collections/Nadzu API/Contributions (Specific User).request.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| $kind: http-request | ||
| name: Contributions (Specific User) | ||
| url: "{{base_url}}/api/v1/contributions?username=nxdun" | ||
| method: GET | ||
| scripts: | ||
| - type: afterResponse | ||
| code: >- | ||
| pm.test("Status is 200", function () { | ||
| pm.response.to.have.status(200); | ||
| }); | ||
|
|
||
| pm.test("Response matches expected schema and specific user", function () { | ||
| var jsonData = pm.response.json(); | ||
| pm.expect(jsonData.username).to.eql('nxdun'); | ||
| pm.expect(jsonData.meta.provider).to.eql('github'); | ||
| pm.expect(jsonData.meta.schemaVersion).to.eql(1); | ||
| pm.expect(jsonData.cells).to.be.an('array'); | ||
| pm.expect(jsonData.months).to.be.an('array'); | ||
| pm.expect(jsonData.summary).to.have.property('totalWeeks'); | ||
| }); | ||
| language: text/javascript | ||
| order: 3001 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| use axum::{ | ||
| Json, | ||
| extract::{Query, State}, | ||
| }; | ||
| use serde::Deserialize; | ||
|
|
||
| use crate::{error::AppError, models::contributions_model::ContributionsResponse, state::AppState}; | ||
|
|
||
| #[derive(Debug, Deserialize)] | ||
| pub struct ContributionsQuery { | ||
| pub username: Option<String>, | ||
| } | ||
|
|
||
| pub async fn get_contributions( | ||
| State(state): State<AppState>, | ||
| Query(query): Query<ContributionsQuery>, | ||
| ) -> Result<Json<ContributionsResponse>, AppError> { | ||
| let username = query | ||
| .username | ||
| .as_deref() | ||
| .map(str::trim) | ||
| .filter(|u| !u.is_empty()) | ||
| .map_or_else( | ||
| || { | ||
| state | ||
| .contributions_service | ||
| .get_default_username() | ||
| .to_string() | ||
| }, | ||
| ToOwned::to_owned, | ||
| ); | ||
|
|
||
| let resp = state | ||
| .contributions_service | ||
| .get_contributions(&username) | ||
| .await?; | ||
|
|
||
| Ok(Json(resp)) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| pub mod contributions_controller; | ||
| pub mod ytdlp_controller; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.