nisnevich / discord-consensus-bot

A Discord bot for a consensus in decentralised organisations (e.g. DAO). Implements a lazy consensus and full consensus models.
MIT License
5 stars 4 forks source link

Replace heavyweight "filters" in voting.py with simple in-memory search #7

Closed nisnevich closed 1 year ago

nisnevich commented 1 year ago

voting.py has several expressions like this:

await db.filter( GrantProposals, GrantProposals.message_id == payload.message_id or GrantProposals.bot_response_message_id == payload.message_id, )

At the same time, all proposals are loaded from DB in advance and stored in grant_proposals dict (grant_utils.py).

Instead of ORM filters there should be simple traversing of grant_proposals.