-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ideascale): Update fields for F11 params, saves JSON artifacts |…
… NPG-000 (#661) # Description Updates ideascale importer to use F11. Saves JSON artifacts to output directory. ## Type of change Please delete options that are not relevant. - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update ## How Has This Been Tested? - [x] Run `ideascale-importer ideascale import-all` for single network - [x] Run `ideascale-importer ideascale import-all` for `mainnet` and `preprod` ## Checklist - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published in downstream modules
- Loading branch information
1 parent
adb2c1c
commit 8eeba8c
Showing
10 changed files
with
410 additions
and
181 deletions.
There are no files selected for viewing
This file contains 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 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 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 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
94 changes: 94 additions & 0 deletions
94
utilities/ideascale-importer/ideascale_importer/ideascale/artifacts.py
This file contains 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,94 @@ | ||
from typing import Optional | ||
from ideascale_importer.db.models import Objective, Proposal | ||
from pydantic import BaseModel | ||
|
||
|
||
class ProposalJson(BaseModel): | ||
"""A proposal in JSON used for output artifacts.""" | ||
|
||
category_name: str | ||
chain_vote_options: str | ||
challenge_id: str | ||
challenge_type: str | ||
chain_vote_type: str | ||
internal_id: str | ||
proposal_funds: str | ||
proposal_id: str | ||
proposal_impact_score: str | ||
proposal_summary: str | ||
proposal_title: str | ||
proposal_url: str | ||
proposer_email: Optional[str] = None | ||
proposer_name: Optional[str] = None | ||
proposer_relevant_experience: Optional[str] = None | ||
proposer_url: Optional[str] = None | ||
proposal_solution: Optional[str] = None | ||
files_url: str | ||
|
||
|
||
class ChallengesJson(BaseModel): | ||
id: str | ||
internal_id: int | ||
title: str | ||
challenge_type: str | ||
challenge_url: str | ||
description: str | ||
fund_id: str | ||
rewards_total: str | ||
proposers_rewards: str | ||
|
||
|
||
def objective_to_challenge_json(obj: Objective, ideascale_url: str, idx: int = 0) -> ChallengesJson: | ||
c_url = f"{ideascale_url}/c/campaigns/{obj.id}/" | ||
return ChallengesJson.model_validate( | ||
{ | ||
"id": f"{idx}", | ||
"internal_id": obj.id, | ||
"title": obj.title, | ||
"challenge_type": obj.category.removeprefix("catalyst-"), | ||
"challenge_url": c_url, | ||
"description": obj.description, | ||
"fund_id": f"{obj.event}", | ||
"rewards_total": f"{obj.rewards_total}", | ||
"proposers_rewards": f"{obj.proposers_rewards}", | ||
} | ||
) | ||
|
||
|
||
def json_from_proposal(prop: Proposal, challenge: ChallengesJson, fund_id: int, idx: int = 0) -> ProposalJson: | ||
if prop.proposer_relevant_experience == "": | ||
experience = None | ||
else: | ||
experience = prop.proposer_relevant_experience | ||
if prop.extra is not None: | ||
solution = prop.extra.get("solution", None) | ||
else: | ||
solution = None | ||
return ProposalJson.model_validate( | ||
{ | ||
"category_name": f"Fund {fund_id}", | ||
"chain_vote_options": "blank,yes,no", | ||
"challenge_id": challenge.id, | ||
"challenge_type": challenge.challenge_type, | ||
"chain_vote_type": "private", | ||
"internal_id": f"{idx}", | ||
"proposal_funds": f"{prop.funds}", | ||
"proposal_id": f"{prop.id}", | ||
"proposal_impact_score": f"{prop.impact_score}", | ||
"proposal_summary": prop.summary, | ||
"proposal_title": prop.title, | ||
"proposal_url": prop.url, | ||
"proposer_name": prop.proposer_name, | ||
"proposer_relevant_experience": experience, | ||
"proposal_solution": solution, | ||
"files_url": prop.files_url, | ||
} | ||
) | ||
|
||
|
||
class FundsJson(BaseModel): | ||
"""Current Fund (Event) information in JSON used for output artifacts.""" | ||
id: int | ||
goal: str | ||
threshold: int | ||
rewards_info: str = "" |
This file contains 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
Oops, something went wrong.