Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add time till voting ends to reports #7

Merged
merged 1 commit into from
Sep 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions report_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,12 @@ func (g *ReportGenerator) GenerateReport() Report {
Str("wallet", wallet).
Msg("Wallet hasn't voted now - sending an alert")
entries = append(entries, ReportEntry{
Chain: chain,
Wallet: wallet,
ProposalID: proposal.ProposalID,
ProposalTitle: proposal.Content.Title,
ProposalDescription: proposal.Content.Description,
Chain: chain,
Wallet: wallet,
ProposalID: proposal.ProposalID,
ProposalTitle: proposal.Content.Title,
ProposalDescription: proposal.Content.Description,
ProposalVoteEndingTime: proposal.VotingEndTime,
})
}

Expand All @@ -119,12 +120,13 @@ func (g *ReportGenerator) GenerateReport() Report {
Msg("Wallet hasn't voted before but voted now - closing an alert")

entries = append(entries, ReportEntry{
Chain: chain,
Wallet: wallet,
ProposalID: proposal.ProposalID,
ProposalTitle: proposal.Content.Title,
ProposalDescription: proposal.Content.Description,
Vote: vote.Option,
Chain: chain,
Wallet: wallet,
ProposalID: proposal.ProposalID,
ProposalTitle: proposal.Content.Title,
ProposalDescription: proposal.Content.Description,
ProposalVoteEndingTime: proposal.VotingEndTime,
Vote: vote.Option,
})
}
}
Expand Down
6 changes: 6 additions & 0 deletions telegram.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ func (reporter *TelegramReporter) SerializeReportEntry(e ReportEntry) string {
e.ProposalTitle,
))

sb.WriteString(fmt.Sprintf(
"Voting ends at: %s (in %s)\n\n",
e.ProposalVoteEndingTime.Format(time.RFC3339Nano),
time.Until(e.ProposalVoteEndingTime).Round(time.Second),
))

if e.Chain.KeplrName != "" {
sb.WriteString(fmt.Sprintf(
"<a href='%s'>Keplr</a>\n",
Expand Down
20 changes: 11 additions & 9 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import (

// RPC response types.
type Proposal struct {
ProposalID string `json:"proposal_id"`
Status string `json:"status"`
Content *ProposalContent `json:"content"`
ProposalID string `json:"proposal_id"`
Status string `json:"status"`
Content *ProposalContent `json:"content"`
VotingEndTime time.Time `json:"voting_end_time"`
}

type ProposalContent struct {
Expand Down Expand Up @@ -40,12 +41,13 @@ func (r *Report) Empty() bool {
}

type ReportEntry struct {
Chain Chain
Wallet string
ProposalID string
ProposalTitle string
ProposalDescription string
Vote string
Chain Chain
Wallet string
ProposalID string
ProposalTitle string
ProposalDescription string
ProposalVoteEndingTime time.Time
Vote string
}

func (e *ReportEntry) HasVoted() bool {
Expand Down