diff --git a/CHANGELOG.md b/CHANGELOG.md index 0373b6f..642c18b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,21 @@ All notable changes to this project will be documented in this file. +## [1.0.0-alpha.48] - 2023-10-09 + +### Refactor + +- Update logging for error handling +- Combine ProposalQuery and VoteQuery into single struct for lil nouns + +### Documentation + +- Update social media follow badge in README + +### Miscellaneous Tasks + +- Combine ProposalQuery and VoteQuery for lil nouns + ## [1.0.0-alpha.47] - 2023-10-08 ### Bug Fixes diff --git a/Cargo.lock b/Cargo.lock index 33e36ed..23a26f5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1553,7 +1553,7 @@ checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" [[package]] name = "lilnouns-bots" -version = "1.0.0-alpha.47" +version = "1.0.0-alpha.48" dependencies = [ "anyhow", "async-trait", diff --git a/Cargo.toml b/Cargo.toml index ec1efdc..8199c13 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "lilnouns-bots" -version = "1.0.0-alpha.47" +version = "1.0.0-alpha.48" authors = ["Milad Nekofar "] edition = "2021" description = "Our bots are designed to keep the Lil Nouns DAO community informed and engaged." diff --git a/README.md b/README.md index db4cb1f..7a74172 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![GitHub release (latest SemVer including pre-releases)](https://img.shields.io/github/v/release/lilnouns/lilnouns-bots?include_prereleases)](https://github.com/lilnouns/lilnouns-bots/releases) [![GitHub Workflow Status (branch)](https://img.shields.io/github/actions/workflow/status/lilnouns/lilnouns-bots/build.yml)](https://github.com/lilnouns/lilnouns-bots/actions/workflows/build.yml) [![GitHub](https://img.shields.io/github/license/lilnouns/lilnouns-bots)](https://github.com/lilnouns/lilnouns-bots/blob/master/LICENSE) -[![Twitter Follow](https://img.shields.io/badge/follow-%40nekofar-1DA1F2?logo=twitter&style=flat)](https://twitter.com/nekofar) +[![X (formerly Twitter) Follow](https://img.shields.io/badge/follow-%40nekofar-ffffff?logo=x&style=flat)](https://x.com/nekofar) [![Donate](https://img.shields.io/badge/donate-nekofar.crypto-a2b9bc?logo=ko-fi&logoColor=white)](https://ud.me/nekofar.crypto) diff --git a/graphql/queries/lil_nouns_query.graphql b/graphql/queries/lil_nouns_query.graphql index 995aac3..219745a 100644 --- a/graphql/queries/lil_nouns_query.graphql +++ b/graphql/queries/lil_nouns_query.graphql @@ -1,4 +1,4 @@ -query ProposalQuery { +query ProposalAndVoteQuery { proposals( orderBy: createdTimestamp orderDirection: desc @@ -29,9 +29,6 @@ query ProposalQuery { maxQuorumVotesBPS quorumCoefficient } -} - -query VoteQuery { votes(orderBy: blockNumber, orderDirection: desc) { id support diff --git a/src/lil_nouns/fetcher.rs b/src/lil_nouns/fetcher.rs index 86995ee..05a6cf0 100644 --- a/src/lil_nouns/fetcher.rs +++ b/src/lil_nouns/fetcher.rs @@ -12,21 +12,10 @@ type BigInt = String; #[graphql( schema_path = "graphql/schemas/lil_nouns_schema.graphql", query_path = "graphql/queries/lil_nouns_query.graphql", - response_derives = "Clone", skip_serializing_none, deprecated = "warn" )] -struct ProposalQuery; - -#[derive(GraphQLQuery)] -#[graphql( - schema_path = "graphql/schemas/lil_nouns_schema.graphql", - query_path = "graphql/queries/lil_nouns_query.graphql", - response_derives = "Clone", - skip_serializing_none, - deprecated = "warn" -)] -struct VoteQuery; +struct ProposalAndVoteQuery; pub struct GraphQLFetcher { graphql_url: String, @@ -66,9 +55,9 @@ impl GraphQLFetcher { } pub async fn fetch_proposals(&self) -> Option> { - let variables = proposal_query::Variables {}; + let variables = proposal_and_vote_query::Variables {}; - let response = self.fetch::(variables).await?; + let response = self.fetch::(variables).await?; let proposals = response .proposals @@ -84,9 +73,9 @@ impl GraphQLFetcher { } pub async fn fetch_votes(&self) -> Option> { - let variables = vote_query::Variables {}; + let variables = proposal_and_vote_query::Variables {}; - let response = self.fetch::(variables).await?; + let response = self.fetch::(variables).await?; let votes = response .votes diff --git a/src/lil_nouns/mod.rs b/src/lil_nouns/mod.rs index dc91e27..ffb1730 100644 --- a/src/lil_nouns/mod.rs +++ b/src/lil_nouns/mod.rs @@ -1,5 +1,5 @@ use handler::{discord::DiscordHandler, farcaster::FarcasterHandler}; -use log::{debug, info, warn}; +use log::{debug, error, info, warn}; use serde::{Deserialize, Serialize}; use worker::{Env, Result}; @@ -113,7 +113,7 @@ impl LilNouns { info!("Handling a new proposal... ({:?})", proposal.id); for handler in &self.handlers { if let Err(err) = handler.handle_new_proposal(proposal).await { - log::error!("Failed to handle new proposal: {:?}", err); + error!("Failed to handle new proposal: {:?}", err); } else { debug!("Successfully handled new proposal: {:?}", proposal.id); } @@ -148,7 +148,7 @@ impl LilNouns { info!("Handling a new vote..."); for handler in &self.handlers { if let Err(err) = handler.handle_new_vote(vote).await { - log::error!("Failed to handle new vote: {:?}", err); + error!("Failed to handle new vote: {:?}", err); } else { debug!("Successfully handled new vote: {:?}", vote.id); }