Skip to content

Commit

Permalink
Merge branch 'main' of github.com:kudos-ink/project-classification
Browse files Browse the repository at this point in the history
  • Loading branch information
leapalazzolo committed Oct 9, 2024
2 parents 240b329 + 75ea077 commit 6160f5a
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 47 deletions.
90 changes: 50 additions & 40 deletions .github/ISSUE_TEMPLATE/add_project.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,93 +33,103 @@ body:
validations:
required: true

- type: input
- type: textarea
id: websites
attributes:
label: Websites
description: "Enter website URLs separated by commas."
description: "On each new line write the website URLs"
placeholder: "https://morekudos.com"
validations:
required: true

- type: input
- type: textarea
id: documentation
attributes:
label: Documentation
description: "Enter documentation URLs separated by commas."
placeholder: "https://github.com/kudos-ink"
validations:
required: true
description: "On each new line write the documentation URLs"
placeholder: "https://github.com/kudos-ink/docs"

- type: input
- type: textarea
id: explorers
attributes:
label: Explorers
description: "Enter explorer URLs separated by commas."
validations:
required: true
description: "On each new line write the explorer URLs."
placeholder: "https://polkadot.subscan.io/"

- type: input
- type: textarea
id: repositories
attributes:
label: Repositories
description: "Enter repository URLs separated by commas."
placeholder: "https://github.com/kudos-ink/portal, https://github.com/kudos-ink/issues-api"
description: "On each new line write the repository URLs with front end friendly label."
placeholder: "Kudos Portal - https://github.com/kudos-ink/portal"
validations:
required: true

- type: input
id: socialMedia
- type: textarea
id: social
attributes:
label: Social Media
description: "Enter social media URLs separated by commas."
description: "On each new line write the social media URLs."
placeholder: "https://x.com/KudosPortal"
validations:
required: true

- type: input
- type: textarea
id: networks
attributes:
label: Networks
description: "Enter network names separated by commas."
validations:
required: true
description: "On each new line write the relevant networks."
placeholder: "Polkadot\nEthereum\nAstar"

- type: checkboxes
id: purposes
attributes:
label: Purposes
description: "Select the purposes."
options:
- label: Data
validations:
required: true
- label: ai
- label: bridge
- label: dao
- label: data
- label: defi
- label: evm
- label: gaming
- label: governance
- label: nft
- label: oracles
- label: rwa
- label: socialfi
- label: staking
- label: testing
- label: universal

- type: input
- type: checkboxes
id: stackLevels
attributes:
label: Stack Levels
description: "Enter stack levels separated by commas."
validations:
required: true
options:
- label: protocol
- label: runtime
- label: smart-contract
- label: messaging
- label: offchain

- type: checkboxes
- type: textarea
id: technologies
attributes:
label: Technologies
description: "Select the technologies used."
options:
- label: TypeScript
- label: Rust
validations:
required: true
description: "On each line write the technologies used."
placeholder: "Substrate\nInk!"

- type: checkboxes
id: types
attributes:
label: Types
description: "Select the types."
options:
- label: platform
- label: tool
- label: library
- label: client
- label: framework
- label: template
- label: mobile
- label: service
- label: dApp
validations:
required: true
19 changes: 14 additions & 5 deletions src/import/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,20 @@ async fn function_handler(event: Request) -> Result<Response<Body>, Error> {

let mut tx: sqlx::Transaction<'_, sqlx::Postgres> = pool.begin().await?;

// allow the import to be completely rerun by removing all data
sqlx::query("DELETE FROM projects WHERE slug = $1")
.bind(&project.slug)
.execute(&mut *tx)
.await?;
// delete all open issues related to a preexisting project
sqlx::query(
r#"
DELETE FROM issues
WHERE repository_id IN (
SELECT repositories.id
FROM repositories
JOIN projects ON repositories.project_id = projects.id
WHERE projects.slug = $1)
AND issues.open = true"#,
)
.bind(&project.slug)
.execute(&mut *tx)
.await?;

let project_id = insert_project(&project, &mut tx).await?;

Expand Down
56 changes: 54 additions & 2 deletions src/shared/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,56 @@ pub async fn import_repositories(

let repo_id: i32 = repo_row.get("id");

// let mut pages_remaining = true;
// let mut all_repo_issues: Vec<Issue> = vec![];
// let mut page_number: u32 = 1;

// info!("\n\n CURRENT REPO BEING IMPORTED: {}\n\n", repo_info.name);

// while pages_remaining {
// let page = octocrab
// .issues(&repo_info.owner, &repo_info.name)
// .list()
// .state(State::Open)
// .per_page(100)
// .page(page_number)
// .send()
// .await?;

// info!("\n\n NEXT PAGE ISSUES COUNT: {}\n\n", page.items.len());

// all_repo_issues.extend(page.items);
// pages_remaining = page.next.is_some();
// page_number += 1;
// tokio::time::sleep(tokio::time::Duration::from_millis(500)).await;
// }

// info!(
// "\n\nREPO NAME: {}, ALL REPO ISSUES/PULLS COUNT: {}\n\n",
// &repo_info.name,
// &all_repo_issues.len()
// );

// let filtered_issues: Vec<KudosIssue> = all_repo_issues
// .into_iter()
// .filter_map(|issue| {
// issue
// .pull_request
// .is_none()
// .then(|| KudosIssue::from(issue))
// })
// .collect();

// info!(
// "\n\nREPO NAME: {}, ALL FILTERED ISSUES COUNT: {}\n\n",
// &repo_info.name,
// &filtered_issues.len()
// );

let stream = octocrab
.issues(repo_info.owner, repo_info.name)
.issues(&repo_info.owner, &repo_info.name)
.list()
.state(State::All)
.state(State::Open)
.per_page(100)
.send()
.await?
Expand All @@ -123,6 +169,12 @@ pub async fn import_repositories(
.try_collect()
.await?;

info!(
"\n\nREPO NAME: {}, ALL FILTERED ISSUES COUNT: {}\n\n",
&repo_info.name,
&filtered_issues.len()
);

if filtered_issues.is_empty() {
continue;
}
Expand Down
13 changes: 13 additions & 0 deletions src/shared/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ impl Repository {
let query_string = r#"
INSERT INTO repositories (slug, name, url, language_slug, project_id)
VALUES ($1, $2, $3, $4, $5)
ON CONFLICT (url)
DO UPDATE SET
slug = EXCLUDED.slug,
name = EXCLUDED.name,
project_id = EXCLUDED.project_id,
language_slug = EXCLUDED.language_slug
RETURNING id;
"#;
query_string
Expand Down Expand Up @@ -106,6 +112,13 @@ impl Project {
let query_string = r#"
INSERT INTO projects (name, slug, types, purposes, stack_levels, technologies)
VALUES ($1, $2, $3, $4, $5, $6)
ON CONFLICT (slug)
DO UPDATE SET
name = EXCLUDED.name,
types = EXCLUDED.types,
purposes = EXCLUDED.purposes,
stack_levels = EXCLUDED.stack_levels,
technologies = EXCLUDED.technologies
RETURNING id;
"#;
query_string
Expand Down

0 comments on commit 6160f5a

Please sign in to comment.