Commit Graph

33 Commits

Author SHA1 Message Date
shokollm
5e6a5f16b1 Add CLI unit tests for jigaido issue #11
- Tests mock dependencies and verify command existence, flag processing, and output format
- Tests use --group-id=-1001 format (equals sign) to avoid argparse treating -1001 as a flag
- All 17 tests passing
2026-04-03 13:18:48 +00:00
shokollm
7202eeb1d2 feat(cli): implement CLI for jigaido bounty tracker
Create cli/main.py with the following commands:
- add <text> [--link url] [--due date] - Add a new bounty
- list - List all bounties in room
- my - List tracked bounties for user
- update <id> [text] [--link url] [--due date] [--clear-link] [--clear-due]
- delete <id> - Delete a bounty
- track <id> - Track a bounty
- untrack <id> - Untrack a bounty

Context flags:
- --group-id <id> - Group context
- --user-id <id> - User context

Requires either --group-id or --user-id for all commands.

Fixes #11
2026-04-03 12:37:55 +00:00
edbc924b98 Merge pull request 'feat(adapter): implement JSON file storage adapter for issue #9' (#27) from fix/issue-9 into main 2026-04-03 14:24:06 +02:00
2a9795a0c3 Merge pull request 'feat(core): implement services for issue #8' (#26) from fix/issue-8 into main 2026-04-03 14:23:32 +02:00
shokollm
d889d0e8ab fix(adapter): add unit tests + reorganize data directories
- Add tests/test_json_file.py with unit tests for JsonFileRoomStorage and JsonFileTrackingStorage
- Reorganize data directories per han's feedback:
  - Rooms: ~/.jigaido/data/room/<room_id>.json (was ~/.jigaido/data/<room_id>.json)
  - Tracking: ~/.jigaido/data/tracking/<room_id>_<user_id>.json (was ~/.jigaido/tracking/...)
- Note: duplicate tracking is handled at TrackingService layer (returns False if already tracking), adapter allows duplicates by design
2026-04-03 11:38:42 +00:00
shokollm
3feab1d469 test(services): add unit tests for BountyService and TrackingService
- Test BountyService: add_bounty, list_bounties, get_bounty, update_bounty, delete_bounty
- Test TrackingService: track_bounty, untrack_bounty, get_tracked_bounties
- Test edge cases: permission errors, not found, duplicate tracking
2026-04-03 11:36:07 +00:00
shokollm
e79fbaddc5 feat(adapter): implement JSON file storage adapter for issue #9
Implements RoomStorage and TrackingStorage ports using JSON file persistence:
- JsonFileRoomStorage: Stores room data at ~/.jigaido/data/<room_id>.json
- JsonFileTrackingStorage: Stores tracking data at ~/.jigaido/tracking/<room_id>_<user_id>.json

Features:
- Atomic writes using tempfile + rename for data safety
- Automatic directory creation
- Implements all methods from ports.py protocols
2026-04-03 09:36:31 +00:00
shokollm
920fb70257 feat(core): implement services for issue #8
- Add BountyService for room bounty operations (group and personal)
- Add TrackingService for tracking bounty operations
- Uses RoomStorage and TrackingStorage ports
- PermissionError raised when non-creator edits/deletes
- ValueError raised when bounty not found in tracking
2026-04-03 09:26:48 +00:00
shokollm
e691abce60 Revert "Merge feat/issue-6-storage-ports: JSON file storage adapter for issue #9"
This reverts commit 9e3641a850, reversing
changes made to 8aebb763ee.
2026-04-03 08:36:04 +00:00
shokollm
9e3641a850 Merge feat/issue-6-storage-ports: JSON file storage adapter for issue #9 2026-04-03 08:26:10 +00:00
shokollm
af8eb90563 feat(adapter): implement JSON file storage adapter
Add JsonFileRoomStorage and JsonFileTrackingStorage implementations
that implement the RoomStorage and TrackingStorage ports.

- Stores room data at ~/.jigaido/data/<room_id>.json
- Stores tracking data at ~/.jigaido/tracking/<room_id>_<user_id>.json
- Implements all port methods: load, save, add_bounty, update_bounty,
  delete_bounty, get_bounty for rooms; load, save, track_bounty,
  untrack_bounty for tracking

Fixes #9
2026-04-03 08:06:51 +00:00
8aebb763ee Merge pull request 'Add core/ports.py - Storage interfaces' (#20) from feat/issue-6-storage-ports into main 2026-04-03 08:58:30 +02:00
shokollm
a237810dd2 Remove ensure_room/ensure_tracking from Protocol - tests prove not needed
Tests with SimpleRoomStorage and SimpleTrackingStorage (without ensure_*)
show that add_bounty() and track_bounty() work fine without explicit
ensure methods - they create rooms/tracking internally.

This simplifies the Protocol to only essential methods.
2026-04-03 06:48:52 +00:00
shokollm
43603659de Address PR #20 feedback:
- Removed PersonalStorage (redundant - RoomStorage handles both via room_id)
- Added ensure_room() and ensure_tracking() methods for explicit creation
- Added @runtime_checkable to Protocols for isinstance checks
- Added tests/test_ports.py with 11 unit tests for storage protocols
2026-04-02 23:57:49 +00:00
shokollm
5450d12400 Add core/ports.py - Storage interfaces
Define abstract storage interfaces (Protocols):
- RoomStorage: for room/group bounties (load, save, add/update/delete/get_bounty)
- PersonalStorage: same operations for personal/DM bounties
- TrackingStorage: for tracking data (load, save, track/untrack_bounty)
2026-04-02 22:40:11 +00:00
ddd44cb593 Merge pull request 'feat(core): implement domain dataclasses for issue #5' (#19) from feat/issue-5-core-models into main 2026-04-03 00:37:30 +02:00
shokollm
b2854393ae Address PR #19 review feedback round 3:
- TrackingData.group_id renamed to room_id (works for both group and DM)
- Removed room_id from TrackedBounty (it's just a lightweight pointer)
2026-04-02 22:34:19 +00:00
shokollm
330203e6ef Address PR #19 review feedback round 2:
- Bounty.created_by_user_id is now non-optional (always required)
- Removed is_group from RoomData (negative room_id is self-documenting)
- Added room_id to TrackedBounty to track which room bounty was tracked from
- Added clarifying docstrings explaining TrackingData vs TrackedBounty
- Updated tests to match new model structure
2026-04-02 22:24:12 +00:00
shokollm
f1ef33451c Address PR #19 review feedback: simplify models
- Remove GroupBounty/PersonalBounty subclasses, use Bounty with optional created_by_user_id
- Combine UserData/GroupData into RoomData with room_id and is_group fields
- Add group_id field to TrackingData (supports negative Telegram group IDs)
- Add test_bounty_comparison_not_equal for verifying different bounties are not equal
- Update core/__init__.py exports
2026-04-02 21:47:26 +00:00
5aebb5a814 Merge pull request 'feat(config): implement configuration management' (#18) from feat/issue-7-config into main 2026-04-02 23:43:56 +02:00
shokollm
9b8b15414f feat(config): implement configuration management for issue #7
- Create config.py with Config class
- Config precedence: ENV > config file > defaults
- data_dir: JIGAIDO_DATA_DIR env or ~/.jigaido/config.json or default
- bot_token: JIGAIDO_BOT_TOKEN env var
- ensure_data_dir() method to create data directory
- Add tests/test_config.py with 7 passing tests

Fixes #7
2026-04-02 20:16:41 +00:00
shokollm
db09a518d1 feat(core): implement domain dataclasses for issue #5
- Create core/__init__.py
- Create core/models.py with all domain dataclasses:
  - Bounty (base class)
  - GroupBounty (extends Bounty)
  - PersonalBounty (extends Bounty)
  - TrackedBounty
  - GroupData
  - TrackingData
  - UserData
- Create tests/test_models.py with 15 passing tests

Fixes #5
2026-04-02 20:15:41 +00:00
98a8c4d173 Merge pull request 'feat: Replace SQLite with per-user JSON storage (fixes #2)' (#3) from fix/issue-2-json-storage into main 2026-04-02 17:44:08 +02:00
shokollm
7c2bd09ada feat: implement new storage design per issue #2
- Storage: Change from per-user to per-group JSON files
- Data location: ~/.jigaido/ instead of apps/telegram-bot/data/
- Group bounties: data/{group_id}/group.json
- User tracking: data/{group_id}/{user_id}.json
- Personal bounties: data/{user_id}/user.json
- Update commands.py for new storage model
- Update bot.py to remove admin handlers
- Update tests to reflect created_by_user_id field
- Update SPEC.md with new design

Addresses user feedback from issue #2
2026-04-02 14:56:42 +00:00
shokollm
332d7fc60a Update issue #2 storage design with new file structure 2026-04-01 21:31:51 +00:00
shokollm
2e7b20ed81 Update issue #2 storage design with new file structure
Changed from per-user flat files to group/DM directory structure:
- data/{group_id}/group.json — group bounties
- data/{group_id}/{user_id}.json — user tracking in group
- data/{user_id}/user.json — user personal bounties (DM)
- Groups isolated, no cross-group access
- Tracking is per-group-per-user
2026-04-01 21:31:34 +00:00
shokollm
8bb964fdd0 feat: Replace SQLite with per-user JSON storage (fixes #2)
- Add storage.py with load_user(), save_user(), next_bounty_id()
- Rewrite commands.py to use JSON storage (simplified)
- Remove db.py, schema.sql, cron.py, test_db.py
- Update SPEC.md to reflect new architecture
- Admin model removed (anyone can add, creator only can edit/delete)
- No reminders in v1
2026-04-01 10:02:51 +00:00
shokollm
8647f2f4b8 Add issue template for v2 storage simplification 2026-04-01 09:53:38 +00:00
shokollm
d6f98c9163 Fix db.py connection handling and test isolation
db.py:
- Add conn.isolation_level = None to get_conn() — fixes row_factory +
  autocommit conflict. row_factory disables implicit transactions,
  so we need explicit autocommit mode.
- Remove all conn.commit() calls (unnecessary with autocommit)

pyproject.toml:
- Move pytest + pytest-asyncio to main dependencies (uv run pytest
  uses ephemeral env with main deps only)

tests/test_db.py:
- Fix test_upsert_user_updates_username to not chain upsert_user()
  calls in assert expressions (test isolation issue)
2026-04-01 09:35:17 +00:00
shokollm
965c84379b Add uv support, systemd service, and deployment tooling
- pyproject.toml: uv-native project definition (replaces requirements.txt for uv users)
- requirements.txt: kept for pip compatibility
- deploy/jigaido-bot.service: systemd service file (copy to /etc/systemd/system/)
- deploy/setup.sh: automated deployment script
- README.md: updated with uv instructions, tmux, and systemd setup
2026-04-01 09:15:41 +00:00
shokollm
7957947a04 Add tests + fix db.py SQLite commit pattern
Tests:
- tests/test_commands.py: parse_args, extract_args, format_bounty
- tests/test_db.py: full CRUD + tracking + reminders
- tests/conftest.py: temp DB fixture
- requirements-dev.txt: pytest + pytest-asyncio

db.py fixes:
- Explicit conn.commit() after every write (SQLite row_factory
  disables implicit transaction management)
- fetchone() before commit() (can't commit while cursor open)
- Functions return dict instead of sqlite3.Row
2026-04-01 08:41:44 +00:00
shokollm
9f0ad2d404 Refactor to apps/ structure
JIGAIDO is now a platform with apps/ as the container.
All telegram-bot files moved to apps/telegram-bot/:
- bot.py, commands.py, cron.py, db.py, schema.sql
- requirements.txt, .env.example, README.md
- Root now holds SPEC.md, README.md, CONTRIBUTING.md only.

Structure:
jigaido/
├── apps/
│   └── telegram-bot/
└── SPEC.md, README.md, CONTRIBUTING.md
2026-04-01 08:05:10 +00:00
shokollm
be5fe04a90 Initial commit: project scaffold, full spec, database schema, bot and cron
- SPEC.md: full project specification from design discussion
- schema.sql: SQLite database schema
- db.py: database wrapper with all query functions
- bot.py: telegram bot entrypoint
- commands.py: all command handlers with admin/creator guards
- cron.py: daily reminder job
- requirements.txt: python-telegram-bot, dateparser
- README.md, CONTRIBUTING.md
- .gitignore
2026-04-01 07:38:18 +00:00