Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
19e548b
Crypromus: бага с рублями
m1ndg8mer Feb 7, 2025
e242e8e
Cryptomus бага с рублями #2
m1ndg8mer Feb 7, 2025
45ca82e
Cryptomus бага с рублями #3
m1ndg8mer Feb 7, 2025
1cb89bd
Новая валюта: Тайский Бат (#54)
m1ndg8mer Feb 26, 2025
ddfc4ae
Уменьшил к-во записей на странице external_rate_snapshots
m1ndg8mer Mar 24, 2025
01b9852
Новый источник курсов: FF (#55)
m1ndg8mer Mar 26, 2025
445cb30
Новая валюта: Индонезийская Рупия (#56)
m1ndg8mer Mar 27, 2025
fe3c69f
Комиссия может быть < -10%
m1ndg8mer Apr 1, 2025
10ad584
ExchangeRate: новый скоуп
m1ndg8mer May 16, 2025
57df85f
Трекаем обновление ExchangeRate (#57)
anaumov May 24, 2025
e7f4143
Ускоряем обновление exchange_rates
anaumov Jun 15, 2025
4018302
Выставлять позицию ОТ, если выбран курс с запасом
m1ndg8mer Jul 25, 2025
6512806
Фикс автокурсом
m1ndg8mer Aug 4, 2025
ebe684a
Если есть несовпадения по настройкам - выставляем по Курс от
m1ndg8mer Aug 12, 2025
7341320
Модель exchange_rate_limit (#58)
anaumov Sep 13, 2025
a9d1cfb
Првязка exchange_rate_limit к exchange_rate
anaumov Sep 14, 2025
d5841e8
Оптимизация геры (#59)
m1ndg8mer Oct 14, 2025
b31480b
Remove rails and draper version lock
dapi Oct 15, 2025
b72c613
Bump rubu
dapi Oct 16, 2025
b8646b8
Fix enum
dapi Oct 19, 2025
5175428
Improve enum and upgrade rails
dapi Oct 19, 2025
7e90915
minor
dapi Oct 19, 2025
fe1e0a1
Improve ./spec/dummy
dapi Oct 19, 2025
6e96eb4
Fix specs
dapi Oct 19, 2025
cf4ca55
Add .github
dapi Oct 19, 2025
0b476f7
Merge pull request #60 from alfagen/chore/gems-version-lock
dapi Oct 30, 2025
70acc01
Merge pull request #61 from alfagen/chore/upgrade-rails-to-8
dapi Oct 30, 2025
5229098
Minor improve CI
dapi Nov 1, 2025
ef7645f
Bump 0.3.4
dapi Nov 8, 2025
cf276c2
Fix specs
dapi Nov 25, 2025
8d268d7
Update README.md
dapi Nov 25, 2025
babf9fe
Bump v0.3.5
dapi Nov 25, 2025
2565603
Update Gemfile.lock for version 0.3.5
dapi Nov 25, 2025
7b45d49
Bump version to 0.3.6
dapi Nov 25, 2025
b3046f7
Update .claude
dapi Nov 25, 2025
901d69b
Добавил больше тестов
dapi Nov 28, 2025
b027f38
Add dependency
dapi Nov 28, 2025
5733a9a
Bump v0.4.0
dapi Nov 28, 2025
592c551
Bump 0.4.0 (fix specs)
dapi Nov 28, 2025
09f4fdc
Migrate from Sidekiq to ActiveJob
dapi Dec 1, 2025
3b865c8
Fix limits_concurrency lambda to accept job argument
dapi Dec 1, 2025
36a7047
Replace sidekiq dependency with solid_queue
dapi Dec 2, 2025
81767b1
Remove sidekiq
dapi Dec 3, 2025
8c1c09e
Bump version to 1.0.0
dapi Dec 3, 2025
2ab64cd
Fix outdated log message: perform_async -> perform_later
dapi Dec 10, 2025
3e9de76
Fix open-uri deprecation: use Net::HTTP and URI.open
dapi Dec 10, 2025
8cffb79
Fix CryptomusFetcher and BybitFetcher - remove PaymentServices depend…
dapi Dec 10, 2025
d55199a
Bump version to 1.1.0
dapi Dec 10, 2025
b9a98aa
Fix limits_concurrency lambda arity for SolidQueue recurring tasks
dapi Dec 10, 2025
af100f1
Add includes(:exchange_rate) to DirectionRatesRepository#build_matrix
dapi Dec 18, 2025
c9fbc5d
Merge pull request #67 from alfagen/fix/1691-direction-rates-reposito…
dapi Dec 23, 2025
e69edc5
Use warning instead of error for missing currency rates
dapi Dec 25, 2025
6dfa812
Merge pull request #79 from alfagen/fix/1708-graceful-rate-not-found
dapi Dec 30, 2025
c569bd0
Merge pull request #62 from alfagen/chore/migrate-from-sidekiq-to-act…
dapi Dec 31, 2025
bd3ec35
Use Manul for external rates (#81)
dapi Jan 15, 2026
d66a12a
Add enable_direction_rate_history_intervals config option
dapi Jan 16, 2026
8b79180
Merge pull request #88 from alfagen/feature/optional-direction-rate-h…
dapi Jan 20, 2026
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
71 changes: 71 additions & 0 deletions .github/workflows/rspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: RSpec Tests

on:
push:
branches: [ master, main, develop ]
pull_request:
branches: [ master, main, develop ]

jobs:
test:
runs-on: ubuntu-latest

services:
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: gera_test
options: >-
--health-cmd="mysqladmin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=3
ports:
- 3306:3306

steps:
- uses: actions/checkout@v4

- name: Set up Ruby 3.4
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.4.7
bundler-cache: true
cache-version: 2

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y mysql-client
bundle install --jobs 4 --retry 3

- name: Setup database
env:
RAILS_ENV: test
MYSQL_HOST: localhost
MYSQL_USER: root
MYSQL_PASSWORD: root
MYSQL_DATABASE: gera_test
run: |
cd spec/dummy
bundle exec rake db:create
bundle exec rake db:schema:load

- name: Run RSpec tests
env:
RAILS_ENV: test
MYSQL_HOST: localhost
MYSQL_USER: root
MYSQL_PASSWORD: root
MYSQL_DATABASE: gera_test
run: |
bundle exec rspec

- name: Upload coverage reports
uses: codecov/codecov-action@v3
with:
file: ./coverage/coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ spec/dummy/tmp/
*.log
.yardoc/
.byebug_history
.claude/settings.local.json
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.4.7
106 changes: 106 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Project Overview

Gera is a Rails engine for generating and managing currency exchange rates for crypto changers and markets. It collects rates from external sources, builds currency rate matrices, and calculates final rates for payment systems with commissions.

## Core Architecture

### Rate Flow Hierarchy
1. **ExternalRate** - Raw rates from external sources (EXMO, Bitfinex, Binance, CBR, etc.)
2. **CurrencyRate** - Basic currency rates calculated from external rates using different modes (direct, inverse, cross)
3. **DirectionRate** - Final rates for specific payment system pairs with commissions applied
4. **ExchangeRate** - Configuration for commissions between payment systems

### Key Models
- **RateSource** - External rate providers with STI subclasses (RateSourceExmo, RateSourceBitfinex, etc.)
- **PaymentSystem** - Payment systems with currencies and commissions
- **CurrencyPair** - Utility class for currency pair operations
- **Universe** - Central repository pattern for accessing rate data

### Worker Architecture
- **RatesWorker** concern for fetching external rates
- Individual workers for each rate source (ExmoRatesWorker, BitfinexRatesWorker, etc.)
- **CurrencyRatesWorker** - Builds currency rate matrix from external rates
- **DirectionsRatesWorker** - Calculates final direction rates with commissions
- **CreateHistory_intervalsWorker** - Aggregates historical data

## Development Commands

### Running Tests
```bash
# Run all tests
bundle exec rake spec

# Run specific test file
bundle exec rspec spec/models/gera/currency_rate_spec.rb

# Run with focus
bundle exec rspec --tag focus
```

### Building and Development
```bash
# Install dependencies
bundle install

# Run dummy app for testing
cd spec/dummy && rails server

# Generate documentation
bundle exec yard

# Clean database between tests (uses DatabaseRewinder)
```

### Code Quality
```bash
# Lint code
bundle exec rubocop

# Auto-correct linting issues
bundle exec rubocop -a
```

## Configuration

Create `./config/initializers/gera.rb`:
```ruby
Gera.configure do |config|
config.cross_pairs = { kzt: :rub, eur: :rub }
config.default_cross_currency = :usd
end
```

## Key Business Logic

### Rate Calculation Modes
- **direct** - Direct rate from external source
- **inverse** - Inverted rate (1/rate)
- **same** - Same currency (rate = 1)
- **cross** - Calculated through intermediate currency

### Supported Currencies
RUB, USD, BTC, LTC, ETH, DSH, KZT, XRP, ETC, XMR, BCH, EUR, NEO, ZEC

### External Rate Sources
- EXMO, Bitfinex, Binance, GarantexIO
- Russian Central Bank (CBR)
- Manual rates and FF (fixed/float) sources

## Testing Notes

- Uses dummy Rails app in `spec/dummy/`
- Factory Bot for test data in `factories/`
- VCR for HTTP request mocking
- Database Rewinder for fast test cleanup

## File Organization

- `app/models/gera/` - Core domain models
- `app/workers/gera/` - Background job workers
- `lib/gera/` - Core engine logic and utilities
- `lib/builders/` - Rate calculation builders
- `spec/` - Test suite with dummy app
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
# development dependencies will be added by default to the :development group.
gemspec

gem 'rails', '~> 6.0.6'
gem 'rails', '~> 8.0'
gem 'dapi-archivable', '~> 0.1.2', require: 'archivable'
gem 'active_link_to', github: 'BrandyMint/active_link_to'
gem 'noty_flash', github: 'BrandyMint/noty_flash'
Expand Down
Loading