Skip to content

Add opencode AI assistant workflow and merchant management improvements#1

Merged
joemarct merged 4 commits intomainfrom
feature/export-to-sheets
Mar 19, 2026
Merged

Add opencode AI assistant workflow and merchant management improvements#1
joemarct merged 4 commits intomainfrom
feature/export-to-sheets

Conversation

@joemarct
Copy link
Copy Markdown
Member

@joemarct joemarct commented Mar 19, 2026

Summary

This PR introduces automated AI-assisted code reviews and adds merchant management enhancements.

Changes

🤖 GitHub Actions Workflow

  • New: Added .github/workflows/opencode.yml
    • Triggers on PR events (open, sync, ready for review)
    • Supports manual trigger via /oc or /opencode commands in comments
    • Provides AI-assisted code review using opencode/kimi-k2.5 model
    • Helps identify potential issues, suggest improvements, and ensure code quality

📊 Google Sheets Integration

  • Previous commits on this branch:
    • Added Google Sheets export functionality for merchant data
    • Introduced active field to merchant model for better management
    • Enhanced merchant status tracking capabilities

Testing

  • Workflow triggers correctly on PR events
  • Manual /oc command works in PR comments
  • Google Sheets integration exports data properly
  • Merchant active/inactive status updates work correctly

Checklist

  • New workflow file added
  • Workflow permissions configured (PR write, issues read, id-token write)
  • Node.js 20 setup with npm caching
  • Secrets configured (OPENCODE_API_KEY)

Notes

The opencode workflow requires the OPENCODE_API_KEY secret to be configured in repository settings before it can function.

@opencode-agent
Copy link
Copy Markdown

Pull Request Review

Positive Aspects

  1. Good Architecture: The Google Sheets integration is well-structured with proper separation of concerns
  2. Environment Security: Using config() for sensitive settings is correct
  3. Proper Filtering: Views correctly filter by the new active field
  4. Migration Safety: Adding active with default=True is non-breaking

⚠️ Issues Found

1. Logic Bug - sync_to_sheets.py:112

display = 1 if merchant.verified and merchant.last_transaction_date else 1

Problem: Always returns 1. The else clause should return 0:

display = 1 if merchant.verified and merchant.last_transaction_date else 0

2. Missing Update - update_merchants.py:65-110

The _update_merchant function doesn't update the verified field, but _save_merchant captures it. Add:

merchant.verified = merchant_data.get("verified", False)

3. Redundant Parsing - update_merchants.py:148-149

if last_transaction_date:
    last_transaction_date = parser.parse(last_transaction_date_str)  # Already parsed!

4. Orphaned Script - update_merchant_urls.py

This standalone script references Merchant without proper Django setup. Consider converting to a management command or adding proper setup:

import django
django.setup()
from main.models import Merchant

5. Minor Style - views.py:155

Extra blank line before test_merchants assignment.

📋 Recommendations

  1. Fix the display logic bug (critical)
  2. Add verified update in _update_merchant
  3. Remove redundant date parsing
  4. Fix the orphaned script or make it a proper management command
  5. The opencode workflow looks good with proper permissions

🎯 Summary

The PR is well-structured and the Sheets integration is solid. The main issues are a logic bug in the display field calculation and missing field updates. These should be fixed before merging.

New%20session%20-%202026-03-19T14%3A39%3A47.405Z
opencode session  |  github run

@opencode-agent
Copy link
Copy Markdown

Code Review Summary

Issues Fixed from Previous Review

All issues from the previous review have been addressed in commit b526590:

  1. Logic bug fixed - sync_to_sheets.py:112 now correctly returns 0 when merchant is not verified or has no transactions
  2. Missing verified field added - update_merchants.py:105 now updates the verified field in _update_merchant()
  3. Django setup fixed - update_merchant_urls.py now includes proper Django setup with django.setup()

Positive Aspects

  • Google Sheets integration is well-architected with proper credential handling via config()
  • Migration safety - Adding active field with default=True is non-breaking for existing data
  • Proper filtering - All views correctly filter by active=True
  • Admin improvements - Good field organization in admin with active, test_shop, verified filters
  • Supervisor configuration - Clean separation of concerns with dedicated sheets_sync program running hourly
  • Workflow - GitHub Actions workflow properly configured with minimal permissions

⚠️ Minor Observations

  • Line 145-149 in update_merchants.py: The date parsing logic is actually correct - it parses the date then checks if the result is not None before comparing. This is proper error handling, not redundancy.

  • Line 155 in views.py: The blank line between class definitions follows PEP 8 (two blank lines between top-level classes), so this is fine.

🎯 Verdict

Approve - The PR is well-structured, all identified bugs have been fixed, and the code follows Django best practices. The Google Sheets integration is solid and properly secured via environment configuration.

New%20session%20-%202026-03-19T14%3A42%3A13.558Z
opencode session  |  github run

@joemarct joemarct merged commit d341ab3 into main Mar 19, 2026
1 check passed
@joemarct joemarct deleted the feature/export-to-sheets branch March 19, 2026 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant