hackclub / hackclub/hcb

Rewrite logic for listing an Org's transactions

Open
#3,419 1 comment 1 reaction 1 assignee Claimed by @garyhtou View on GitHub
TX Engine Rewrite 2026
Dominant language
Ruby
Stars
870
Forks
138
Avg merge
1d 14h
Merged PRs (30d)
208

Description

The current logic/services for listing an Organization's transaction is wonky:
- Partially written in SQL (hard to maintain)
- Order of transactions is not strictly defined (see below)

Let's rewrite it.

# Requirements

## Functional Requirements

- Define a strict order
- TX dates alone don't have enough granularity. We only have the date (not datetime) for some linked objects. Multiple tx can happen in one day; duh!
- This is important because varying query plans (such as from conditional filtering) may shift the order of equally ranked results
- The goal is for no two objects to have the same rank, otherwise ordering will be ambiguous.
- Support the following filters:
- Date range
- related issue https://github.com/hackclub/bank/issues/3176
- tags
- memo
- type (invoice, donation, disbursement, etc.)
- Handles `Event#can_front_balance?` and fronted CanonicalPendingTransactions
- Will be used by both UI and API

Bonus

- Allow multiple events
- There may be a use case where we want a single list of transactions from all HQ-related events

## Non-functional requirements

- Prioritize performance
- Ideally under 1 second for HQ (just throwing a number out there; not sure if this is reasonable)
- Ensure values are safely escaped (no SQL injection)
- Use active record as much as possible (no more walls of SQL :smile:)

# Design (rough thoughts atm)

- Replace `CanonicalTransactionGrouped` with `HcbCode`
- I'm not too sure why `CanonicalTransactionGrouped` exists
- Query for pending and settled transactions should be united
- Then provide an option to exclude either pending or settled
- Will require `HcbCode`s to be associated with other models such as `Event`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.