Skip to content

Commit

Permalink
feat: display proposal voting left time on /proposals (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
freak12techno authored Mar 19, 2023
1 parent 906e3bb commit c9fec6b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pkg/reporters/telegram/list_proposals.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package telegram

import (
"bytes"
"main/pkg/state"
statePkg "main/pkg/state"

tele "gopkg.in/telebot.v3"
)
Expand All @@ -13,7 +13,7 @@ func (reporter *TelegramReporter) HandleProposals(c tele.Context) error {
Str("text", c.Text()).
Msg("Got proposals list query")

state := reporter.StateGenerator.GetState(state.NewState())
state := reporter.StateGenerator.GetState(statePkg.NewState())
template, _ := reporter.GetTemplate("proposals")
var buffer bytes.Buffer
if err := template.Execute(&buffer, state); err != nil {
Expand Down
4 changes: 4 additions & 0 deletions pkg/types/responses.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ type Proposal struct {
VotingEndTime time.Time `json:"voting_end_time"`
}

func (p Proposal) GetTimeLeft() string {
return utils.FormatDuration(time.Until(p.VotingEndTime).Round(time.Second))
}

type ProposalContent struct {
Title string `json:"title"`
Description string `json:"description"`
Expand Down
2 changes: 1 addition & 1 deletion templates/telegram/proposals.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{{- end }}
{{- range .ProposalVotes }}
{{- $proposalLink := $chain.GetProposalLink .Proposal }}
Proposal #{{ .Proposal.ProposalID }}: {{ SerializeLink $proposalLink }}
Proposal #{{ .Proposal.ProposalID }}: {{ SerializeLink $proposalLink }} (voting ends in {{ .Proposal.GetTimeLeft }})
{{- range $wallet, $vote := .Votes }}
{{- $walletLink := $chain.GetWalletLink $vote.Wallet -}}
{{- if $vote.IsError }}
Expand Down

0 comments on commit c9fec6b

Please sign in to comment.