Commit Graph

71 Commits

Author SHA1 Message Date
69bb6b839a docs: Fix incorrect SQLite references - DEV uses PostgreSQL via Docker
The documentation incorrectly stated that DEV environment uses SQLite
when it actually uses PostgreSQL via Docker on localhost:5433.

Updated files:
- CLAUDE.md - main project instructions
- PROJECT_INFO.md - environment documentation
- deployment_checklist.md - deployment procedures
- SCRIPTS_INDEX.md - script usage commands
- .claude/commands/*.md - all slash command definitions
- tests/test_admin_seo_dashboard.py - test database URL

DEV environment:
- PostgreSQL via Docker: localhost:5433
- Container: nordabiz-postgres
- Database: nordabiz
- User: nordabiz_app

PROD environment:
- PostgreSQL: 10.22.68.249:5432

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 03:40:50 +01:00
def60a4b22 docs: fix database config - DEV uses PostgreSQL via Docker, not SQLite 2026-01-09 03:30:51 +01:00
3cea691fd4 fix(gbp): fix opening hours and photos data fetching
Add database migration to support opening hours and photos fields.
Update GBP audit service to properly fetch and validate these fields
from Google Business Profile API. Add comprehensive test coverage.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 03:27:38 +01:00
20359aa9de chore: ignore Auto-Claude metadata files 2026-01-09 03:12:15 +01:00
603c95c608 auto-claude: subtask-7-1 - Production verification for GBP audit
- Verified production health endpoint is running
- Confirmed code implementation is correct:
  - gbp_audit_service.py uses google_opening_hours for hours field
  - gbp_audit_service.py uses google_photos_count for photos field
  - gbp_audit_service.py uses google_rating/google_reviews_count for reviews
- Manual browser verification required (page requires authentication)
- Instructions documented in build-progress.txt

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 23:25:41 +01:00
de4cf264fa auto-claude: subtask-6-1 - Mark database migration ready for user action
Migration code complete:
- database/migrations/add_gbp_hours_photos_columns.sql
- run_migration.py helper script

SSH access to production (10.22.68.249) is blocked from sandbox.
User must run the documented command to complete migration.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 23:23:19 +01:00
0dde9bde77 auto-claude: subtask-6-1 - Add run_migration.py for production deployment
Added a Python migration script that can be run on the production server
to add the google_opening_hours and google_photos_count columns.

Script connects to localhost (127.0.0.1) as required by PostgreSQL config.

Usage on production server:
  cd /var/www/nordabiznes && python3 run_migration.py

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 23:21:19 +01:00
8945b79fcc auto-claude: subtask-5-2 - Test GBP audit service locally to verify field checks
- Created tests/test_gbp_audit_field_checks.py with comprehensive tests
- Tests verify _check_hours() correctly uses google_opening_hours field
- Tests verify _check_photos() correctly uses google_photos_count field
- Tests cover edge cases: null values, missing analysis, partial data
- All field check logic validated: complete/partial/missing status
- Field weights verified: hours=8, photos=15, total=100

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 23:10:16 +01:00
5ed97ac1dd auto-claude: subtask-5-1 - Fix opening_hours and photos data passing in audit_company
Fixed a bug where google_opening_hours and google_photos_count were being
fetched from the Google Places API but not passed through to the result
dictionary correctly:

- Changed 'opening_hours' key to 'google_opening_hours' to match what
  save_audit_result() expects
- Added 'google_photos_count' to the result dictionary

Verified with dry-run: INPI company now shows opening hours schedule
and 10 photos count from Google Business Profile.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 23:08:19 +01:00
5f18a228b1 auto-claude: subtask-4-1 - Create SQL migration script for new columns
Add database migration script to add google_opening_hours (JSONB) and
google_photos_count (INTEGER) columns to company_website_analysis table.

These columns are needed for storing GBP data from Google Places API:
- google_opening_hours: stores weekday_text, open_now, and periods data
- google_photos_count: stores count of photos from Google Business profile

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 23:04:25 +01:00
fd5a04c02c auto-claude: subtask-3-2 - Update _check_photos() to use google_photos_count
Changed _check_photos method to read from analysis.google_photos_count
instead of total_images. This provides actual GBP photo count rather
than estimated website images.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 23:02:49 +01:00
d84588c46b auto-claude: subtask-3-1 - Update _check_hours() method to read from google_opening_hours
Changed _check_hours() in GBP Audit Service to read opening hours from
google_opening_hours field instead of google_business_status. The method
now properly returns the actual hours value when available.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 23:01:28 +01:00
aacf2cf54b auto-claude: subtask-2-3 - Update save_audit_result() to store google_opening_hours and google_photos_count
- Added google_opening_hours and google_photos_count to INSERT column list
- Added corresponding placeholders to VALUES list
- Added to ON CONFLICT UPDATE SET clause
- Added to parameter dictionary reading from google_reviews result

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 23:00:22 +01:00
5f2cfa06fd auto-claude: subtask-2-2 - Update get_place_details() to return photos count
- Add google_photos_count to result dictionary initialization
- Extract photos count from API response using len(place['photos'])
- Update logging to include photos count in output

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 22:59:04 +01:00
5fa80f9efa auto-claude: subtask-2-1 - Add 'photos' to fields list in GooglePlacesSearcher
Added 'photos' field to the fields list in get_place_details() method
to enable fetching business photos from Google Places API.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 22:58:04 +01:00
41997a15e9 auto-claude: subtask-1-1 - Add google_opening_hours (JSONB) and google_photos_count (INTEGER) columns to CompanyWebsiteAnalysis model
- Added google_opening_hours Column(JSONB) for storing GBP opening hours
- Added google_photos_count Column(Integer) for storing GBP photos count
- Both columns added to GOOGLE BUSINESS section alongside existing google_* columns
2026-01-08 22:57:21 +01:00
115c1c1193 auto-claude: subtask-4-3 - Verify database has Google data for INPI company
BLOCKED: Cannot verify - dependencies not met:
- Local SQLite database empty (no tables initialized)
- Google Places API not enabled for current API key
- Previous subtask (4-2) was blocked, no audit ran

Documented blockers and options to unblock in build-progress.txt.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 20:52:14 +01:00
06c22539d7 auto-claude: subtask-4-2 - Add --company-slug support and dotenv loading
- Add --company-slug argument to social_media_audit.py for easier testing
- Add get_company_id_by_slug() method to SocialMediaAuditor class
- Add python-dotenv support to load .env file from project root
- Create verify_google_places.py script for direct API testing

Note: Full verification blocked - current API key (PageSpeed) doesn't have
Places API enabled. Requires enabling Places API in Google Cloud Console
for project NORDABIZNES (gen-lang-client-0540794446).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 20:49:59 +01:00
3d69d53550 auto-claude: subtask-3-4 - Run all tests and verify they pass
Fixed bug in social media exclusion logic that was too aggressive.
The substring check `any(ex in match.lower() for ex in excludes)`
was incorrectly excluding valid usernames containing exclusion
strings (e.g., 'testcompany' was excluded because it contained 'p').

Changed to exact match only to properly handle Instagram post URLs
(`instagram.com/p/...`) without false positives on valid usernames.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 20:41:54 +01:00
9cd5066afe auto-claude: subtask-3-3 - Add test_search_google_reviews_error for API error
Added test for search_google_reviews method to handle API errors gracefully.
The test mocks GooglePlacesSearcher to simulate a RequestException during
get_place_details and verifies that the method returns None values instead
of crashing.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 20:39:11 +01:00
ee6bc656ef auto-claude: subtask-3-2 - Add test_search_google_reviews for successful API response
Added test_search_google_reviews test in TestBraveSearcherGoogleReviews class
that verifies successful Google reviews retrieval via Google Places API:
- Mocks complete place lookup with realistic place_id
- Mocks full place details response including rating, reviews count,
  opening hours, and business status
- Verifies all expected fields are correctly returned
- Validates correct API calls are made with expected parameters

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 20:37:27 +01:00
c057794c64 auto-claude: subtask-3-1 - Create test file for social_media_audit with Google Places tests
Add comprehensive unit tests for social_media_audit.py:
- WebsiteAuditor tests: SSL checks, hosting detection, HTML parsing, social media extraction
- GooglePlacesSearcher tests: find_place, get_place_details, API error handling
- BraveSearcher tests: Google reviews search, fallback mechanisms
- SocialMediaAuditor tests: company auditing, result saving, integration tests
- Pattern tests: hosting providers, social media URL patterns, exclusion rules

Tests follow the same structure and patterns as test_seo_audit.py.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 20:35:27 +01:00
3bdbde1621 auto-claude: subtask-2-3 - Update SocialMediaAuditor to use GooglePlacesSearcher
- Add google_places_searcher attribute to SocialMediaAuditor
- Initialize GooglePlacesSearcher if GOOGLE_PLACES_API_KEY env var is set
- Update audit_company() to use Places API directly when available
- Fallback to Brave Search when API key not configured
- Log which data source is being used for reviews

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 20:31:22 +01:00
b389287697 auto-claude: subtask-2-2 - Replace placeholder search_google_reviews() method
Implemented actual Google reviews data collection in BraveSearcher class:
- Uses GooglePlacesSearcher to find company and get place details
- Returns google_rating, google_reviews_count, opening_hours, business_status
- Falls back to Brave Search API parsing when Google API key not available
- Added _search_brave_for_reviews() helper for fallback implementation
- Proper error handling and logging throughout

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 20:29:50 +01:00
4110ef63b5 auto-claude: subtask-2-1 - Add GooglePlacesSearcher class to social_media_audit.py
Implements GooglePlacesSearcher class with:
- find_place() method: searches for business by name and city
  using Google Places findplacefromtext API
- get_place_details() method: retrieves rating, review count,
  opening hours, business status, phone, and website

Features:
- Uses GOOGLE_PLACES_API_KEY environment variable
- Comprehensive error handling (timeout, request errors)
- Polish language locale support
- Follows existing BraveSearcher class pattern

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 20:27:49 +01:00
1426a73e0d auto-claude: subtask-1-2 - Document GOOGLE_PLACES_API_KEY in .env.example 2026-01-08 20:24:37 +01:00
c8d9d295af auto-claude: subtask-1-1 - Add googlemaps package to requirements.txt 2026-01-08 20:23:55 +01:00
6426f97831 auto-claude: Merge auto-claude/006-hej-znasz-ta-aplikacje-i-te-mechanizmy-https-www-f 2026-01-08 19:49:45 +01:00
61caea4903 fix: add navigation to GBP audit feature (qa-requested)
Fixes:
- Added GBP audit link to company profile contact bar
- Link visible to admins on all profiles
- Link visible to regular users only on their own company profile
- Styled consistently with contact bar design (Google blue)

Verified:
- Template syntax balanced (blocks, if, for)
- Route gbp_audit_dashboard exists in app.py

QA Fix Session: 1

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 19:27:28 +01:00
47c415a63b auto-claude: subtask-3-4 - Integrate AI recommendations using Gemini service
Added AI-powered recommendation generation to GBP audit service:

- Import gemini_service module for AI integration
- generate_ai_recommendations(): Main method to generate personalized
  recommendations using Gemini with proper cost tracking
- _build_ai_recommendation_prompt(): Builds context-aware prompt with
  company info, audit results, and field statuses in Polish
- _parse_ai_recommendations(): Parses JSON response from Gemini with
  robust error handling and fallback to static recommendations
- audit_with_ai(): Convenience method for running audit with AI
- audit_company_with_ai(): Module-level convenience function

Features:
- Recommendations are personalized to company industry/category
- Includes action_steps and expected_impact for each recommendation
- Graceful fallback to static recommendations if AI unavailable
- Cost tracking via 'gbp_audit_ai' feature tag
- Updated test runner with --ai flag for testing AI mode

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 19:20:25 +01:00
8fa23bc77e auto-claude: subtask-3-3 - Add GBP audit route accessible to logged-in users
Add user-facing GBP audit dashboard route at /audit/gbp/<company_slug>:
- Requires login (@login_required)
- Admin users can view audit for any company
- Regular users can only view audit for their own company
- Passes can_audit flag to template for run audit button visibility
- Gracefully handles missing audit data (template shows "no audit" state)
- Logs audit dashboard views for monitoring

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 19:17:32 +01:00
0bb6b718f5 auto-claude: subtask-3-2 - Create user-facing audit dashboard template
Creates templates/gbp_audit.html for GBP completeness audit display:

- Score circle with visual conic gradient showing completion percentage
- Field status cards (10 fields) with icons, badges, and progress bars
- Recommendations list sorted by priority (high/medium/low)
- Breadcrumb navigation and responsive mobile layout
- Loading overlay and info modal for audit operations
- Polish UI text matching existing platform conventions

Template follows patterns from admin_seo_dashboard.html and integrates
with the GBP audit API endpoints created in subtask-3-1.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 19:14:54 +01:00
a892626ebc auto-claude: subtask-3-1 - Create API endpoint for running GBP audit on a company
Added GBP (Google Business Profile) audit API endpoints:
- GET /api/gbp/audit/health - Health check for GBP audit service
- GET /api/gbp/audit - Fetch latest audit results by company_id or slug
- GET /api/gbp/audit/<slug> - Fetch audit results by slug path
- POST /api/gbp/audit - Run GBP audit for a company

Features:
- Health endpoint returns service status and version
- GET endpoints return completeness score, field status, and recommendations
- POST endpoint runs audit and saves results (configurable)
- Access control: members can audit own company, admins can audit any
- Rate limited to 20 requests per hour

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 19:11:26 +01:00
ecf811f168 auto-claude: subtask-2-3 - Create database migration script for GBP audit tab
- Create gbp_audits table with all required fields:
  - completeness_score (0-100)
  - fields_status and recommendations (JSONB)
  - Individual field flags (has_name, has_phone, etc.)
  - Photo and review metrics
  - Google Place integration fields
  - Audit metadata (source, version, errors)
- Add indexes for company_id, audit_date, and score
- Add update trigger for updated_at timestamp
- Create views: v_company_gbp_overview, v_gbp_audit_history
- Include GRANT statements for nordabiz_app user

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 19:08:05 +01:00
edb3d41f49 auto-claude: subtask-2-2 - Create GBP audit service with completeness scoring
Add GBPAuditService with:
- Field-by-field completeness checking (name, address, phone, website, hours, categories, photos, description, services, reviews)
- Weighted scoring algorithm (total 100 points)
- AuditResult and FieldStatus dataclasses for structured results
- Automatic recommendation generation with priority levels
- save_audit() to persist results to GBPAudit model
- Convenience functions: audit_company(), get_company_audit(), batch_audit_companies()

Scoring weights:
- Photos: 15 pts (highest impact on engagement)
- Description: 12 pts
- Name, Address, Categories: 10 pts each
- Reviews: 9 pts
- Phone, Website, Hours, Services: 8-10 pts each

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 19:05:35 +01:00
1c0680877b auto-claude: subtask-2-1 - Create GBPAudit database model for storing audit results
Add GBPAudit SQLAlchemy model for Google Business Profile audit tracking:
- Completeness score (0-100) with score category property
- Field-by-field status tracking (JSONB)
- AI-generated recommendations storage (JSONB)
- Individual field boolean flags (name, address, phone, etc.)
- Photo/review metrics
- Google Place ID integration
- Audit metadata and timestamps

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 19:02:21 +01:00
996e9cbe5c Dodaj informację o źródle danych w panelu SEO
Widoczny link do Google PageSpeed Insights (Lighthouse) w nagłówku panelu.
Użytkownik/admin wie skąd pochodzą metryki.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 16:06:14 +01:00
b7b95c9c11 Aktualizuj nazwę klucza API PageSpeed w dokumentacji 2026-01-08 16:03:51 +01:00
ca7888c325 Dodaj dokumentację audytu SEO do CLAUDE.md
- Konfiguracja Google PageSpeed Insights API
- Metryki i interpretacja wyników
- Skrypty uruchamiania audytów
- WAŻNE: połączenie z bazą przez localhost
- Tabela seo_metrics
- UI stylizowanych modali

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 16:03:01 +01:00
af003798a7 Napraw połączenie z bazą danych w skryptach SEO (localhost zamiast zewnętrznego IP) 2026-01-08 15:57:39 +01:00
90ca2bc618 Dodaj stylizowane modale i link Audyt SEO w menu admina
- Zamieniono natywne confirm/alert na ładne modale CSS
- Dodano link "Audyt SEO" w menu administracyjnym
- Modal z animacją slide-in, ikony ostrzeżenia/info
- Obsługa zamykania przez backdrop

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 15:34:06 +01:00
892cfcc39a Fix: Template url_for errors - use company_id instead of slug
Naprawia błędy BuildError w szablonach admin gdzie używano slug zamiast company_id.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 14:04:09 +01:00
8705a5b015 Fix: Admin SEO dashboard - use Category.name instead of relationship
Problem: /admin/seo zwracał błąd 500 z AttributeError: category
Przyczyna: Company.category jest relacją SQLAlchemy (obiektem), nie stringiem.
Rozwiązanie: Użycie Category.name.label('category_name') z właściwym JOIN.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 14:00:56 +01:00
174316a530 Przywróć logo firm na stronie głównej (katalog)
Naprawione błędy wprowadzone podczas synchronizacji:
- Przywrócono sekcję company-logo z obrazkiem w karcie firmy
- Przywrócono style CSS dla logo (100% szerokość, 80px wysokość)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 13:39:16 +01:00
ee495ce83e Przywróć logo firm i Social Media w profilu firmy
Naprawione błędy wprowadzone podczas synchronizacji:
- Przywrócono sekcję company-logo-header z obrazkiem
- Przywrócono style CSS dla logo (240x240px, shadow, border-radius)
- Przywrócono przyciski Social Media (Facebook, Instagram, LinkedIn, YouTube, X, TikTok)
- Przywrócono style kolorów dla platform social media
- Naprawiono pole website_url → website

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 13:31:13 +01:00
d5e6365d1e auto-claude: Merge auto-claude/005-badanie-jakosci-seo-stron-intrentowych-kazdego-z-c 2026-01-08 12:36:09 +01:00
6e4e7c2240 Sync: Current production state
- Added CompanyRecommendation system
- Made company pages public (removed @login_required)
- CSS refactor: inline styles instead of external fluent CSS
- Added release notes page
- Added admin recommendations panel
- Company logos (webp format)
- Docker compose configuration

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 12:26:22 +01:00
28efbfabce auto-claude: 8.3 - Test /admin/seo dashboard rendering, sorting, filt
Created comprehensive test suite for SEO admin dashboard functionality:
- tests/test_admin_seo_dashboard.py with 8 test functions
- Dashboard data query verification (SQLAlchemy joins)
- Statistics calculation (good/medium/poor/not_audited counts)
- Score color coding (green/yellow/red thresholds)
- Sorting logic (name, score, date)
- Filtering logic (category, score range, text search)
- Drill-down links validation
- API response structure verification
- Template data requirements verification

All 8 dashboard tests pass. All 64 existing SEO unit tests pass.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 09:29:47 +01:00
feaf5d5a49 auto-claude: 8.2 - Fix SQL ANY() to IN() for SQLite compatibility
- Changed PostgreSQL-specific ANY(:ids) to use IN clause with
  dynamic placeholders for SQLite/PostgreSQL compatibility
- Verified SEO audit dry-run extracts all metrics correctly:
  - HTTP status, load time, final URL
  - Meta title, H1 count, image analysis
  - Structured data detection
  - robots.txt, sitemap.xml, indexability
  - Overall SEO score calculation (95 for pixlab.pl)

Note: Company ID 26 has no website configured, tested with ID 1 instead.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 09:21:12 +01:00
92055bbe60 auto-claude: 8.1 - Create tests/test_seo_audit.py with tests for PageSpeed client, on-page analyzer, technical checker
Implemented comprehensive unit test suite for SEO audit functionality:

- TestPageSpeedScore: Dataclass creation and serialization
- TestCoreWebVitals: Core Web Vitals dataclass tests
- TestRateLimiter: Rate limiting and quota tracking (7 tests)
- TestGooglePageSpeedClient: API client with mocked responses (6 tests)
- TestOnPageSEOAnalyzer: HTML analysis including meta tags, headings, images, links, structured data, Open Graph, Twitter Cards (12 tests)
- TestTechnicalSEOChecker: robots.txt, sitemap.xml, redirects, canonical, indexability (13 tests)
- TestSEOAuditScoreCalculation: On-page and technical score calculation
- TestSEOAuditResultCategorization: Result categorization logic
- TestParseBatchArgument: CLI batch argument parsing
- TestConvenienceFunctions: Helper functions

Total: 64 tests, all passing

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 09:18:15 +01:00