feat: Support incremental mode:
- Support incremental mode in heromodels - Updated the example to refelct the changes - Updated the tests to reflect the changes
This commit is contained in:
@@ -75,7 +75,14 @@ pub struct Ballot {
|
||||
}
|
||||
|
||||
impl Ballot {
|
||||
pub fn new(id: u32, user_id: u32, vote_option_id: u8, shares_count: i64) -> Self {
|
||||
/// Create a new ballot
|
||||
///
|
||||
/// # Arguments
|
||||
/// * `id` - Optional ID for the ballot. If None, the ID will be auto-generated.
|
||||
/// * `user_id` - ID of the user who cast this ballot
|
||||
/// * `vote_option_id` - ID of the vote option chosen
|
||||
/// * `shares_count` - Number of shares/tokens/voting power
|
||||
pub fn new(id: Option<u32>, user_id: u32, vote_option_id: u8, shares_count: i64) -> Self {
|
||||
Self {
|
||||
base_data: BaseModelData::new(id),
|
||||
user_id,
|
||||
@@ -107,7 +114,16 @@ pub struct Proposal {
|
||||
}
|
||||
|
||||
impl Proposal {
|
||||
pub fn new(id: u32, creator_id: impl ToString, title: impl ToString, description: impl ToString, vote_start_date: DateTime<Utc>, vote_end_date: DateTime<Utc>) -> Self {
|
||||
/// Create a new proposal
|
||||
///
|
||||
/// # Arguments
|
||||
/// * `id` - Optional ID for the proposal. If None, the ID will be auto-generated.
|
||||
/// * `creator_id` - ID of the user who created the proposal
|
||||
/// * `title` - Title of the proposal
|
||||
/// * `description` - Description of the proposal
|
||||
/// * `vote_start_date` - Date when voting starts
|
||||
/// * `vote_end_date` - Date when voting ends
|
||||
pub fn new(id: Option<u32>, creator_id: impl ToString, title: impl ToString, description: impl ToString, vote_start_date: DateTime<Utc>, vote_end_date: DateTime<Utc>) -> Self {
|
||||
Self {
|
||||
base_data: BaseModelData::new(id),
|
||||
creator_id: creator_id.to_string(),
|
||||
@@ -128,8 +144,8 @@ impl Proposal {
|
||||
self.options.push(new_option);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn cast_vote(mut self, ballot_id: u32, user_id: u32, chosen_option_id: u8, shares: i64) -> Self {
|
||||
|
||||
pub fn cast_vote(mut self, ballot_id: Option<u32>, user_id: u32, chosen_option_id: u8, shares: i64) -> Self {
|
||||
if self.vote_status != VoteEventStatus::Open {
|
||||
eprintln!("Voting is not open for proposal '{}'", self.title);
|
||||
return self;
|
||||
|
Reference in New Issue
Block a user