Skip to content

Commit

Permalink
Merge branch 'release/1.0.0-alpha.48'
Browse files Browse the repository at this point in the history
  • Loading branch information
nekofar committed Oct 9, 2023
2 parents 9c7be26 + 8e228b4 commit 0357f58
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 26 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "lilnouns-bots"
version = "1.0.0-alpha.47"
version = "1.0.0-alpha.48"
authors = ["Milad Nekofar <milad@nekofar.com>"]
edition = "2021"
description = "Our bots are designed to keep the Lil Nouns DAO community informed and engaged."
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
5 changes: 1 addition & 4 deletions graphql/queries/lil_nouns_query.graphql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
query ProposalQuery {
query ProposalAndVoteQuery {
proposals(
orderBy: createdTimestamp
orderDirection: desc
Expand Down Expand Up @@ -29,9 +29,6 @@ query ProposalQuery {
maxQuorumVotesBPS
quorumCoefficient
}
}

query VoteQuery {
votes(orderBy: blockNumber, orderDirection: desc) {
id
support
Expand Down
21 changes: 5 additions & 16 deletions src/lil_nouns/fetcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -66,9 +55,9 @@ impl GraphQLFetcher {
}

pub async fn fetch_proposals(&self) -> Option<Vec<Proposal>> {
let variables = proposal_query::Variables {};
let variables = proposal_and_vote_query::Variables {};

let response = self.fetch::<ProposalQuery>(variables).await?;
let response = self.fetch::<ProposalAndVoteQuery>(variables).await?;

let proposals = response
.proposals
Expand All @@ -84,9 +73,9 @@ impl GraphQLFetcher {
}

pub async fn fetch_votes(&self) -> Option<Vec<Vote>> {
let variables = vote_query::Variables {};
let variables = proposal_and_vote_query::Variables {};

let response = self.fetch::<VoteQuery>(variables).await?;
let response = self.fetch::<ProposalAndVoteQuery>(variables).await?;

let votes = response
.votes
Expand Down
6 changes: 3 additions & 3 deletions src/lil_nouns/mod.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 0357f58

Please sign in to comment.