Skip to content

Improve demo-import: ORM-only group import, demo config import, feature toggles#7633

Merged
DawoudIO merged 13 commits intomasterfrom
feature/group-import
Nov 24, 2025
Merged

Improve demo-import: ORM-only group import, demo config import, feature toggles#7633
DawoudIO merged 13 commits intomasterfrom
feature/group-import

Conversation

@DawoudIO
Copy link
Contributor

@DawoudIO DawoudIO commented Nov 24, 2025

What Changed

Refactors and hardens the demo-data import flow and demo dataset to be more self-contained and robust.
Adds automatic import of demo system configuration from config.json.
Ensures feature toggles for Sunday School and Finance are set according to API flags passed to the demo import endpoint.
Reworks group import to use Propel ORM directly (no external GroupService dependency), respect group types, and only create roles explicitly defined in the demo data.
Updates the Cypress demo test wait timeout for more stable CI runs.

Type

  • ✨ Feature
  • 🐛 Bug fix
  • ♻️ Refactor
  • 🏗️ Build/Infrastructure
  • 🔒 Security

Testing

Screenshots

Security Check

  • Introduces new input validation
  • Modifies authentication/authorization
  • Affects data privacy/GDPR

Code Quality

  • Database: Propel ORM only, no raw SQL
  • No deprecated attributes (align, valign, nowrap, border, cellpadding, cellspacing, bgcolor)
  • Bootstrap CSS classes used
  • All CSS bundled via webpack

Pre-Merge

  • Tested locally
  • No new warnings
  • Build passes
  • Backward compatible (or migration documented)

@DawoudIO DawoudIO added this to the 6.1.0 milestone Nov 24, 2025
Copilot AI review requested due to automatic review settings November 24, 2025 05:34
@DawoudIO DawoudIO requested a review from a team as a code owner November 24, 2025 05:34
@DawoudIO DawoudIO requested review from respencer and removed request for a team November 24, 2025 05:34
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the demo data import system to be more robust and self-contained. It introduces automatic system configuration import from a new config.json file, adds feature toggle support for Sunday School and Finance modules based on API flags, and reimplements group import using Propel ORM directly without external service dependencies. The refactoring removes event and financial import logic (keeping only core congregation data), fixes duplicate email addresses in demo data, and increases the Cypress test timeout for more stable CI runs.

Key Changes

  • ORM-only group import: Refactored importGroups() to use Propel ORM directly, removing dependency on GroupService and implementing explicit role creation based on peopleTypes definitions
  • System configuration import: Added importSystemConfig() method to automatically load demo settings from config.json and set feature toggles (bEnabledSundaySchool, bEnabledFinance) based on API parameters
  • Streamlined import flow: Removed event, calendar, pledge, and financial import methods, focusing exclusively on families, people, groups, and notes

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
src/admin/routes/api/demo.php Added includeSundaySchool parameter, fixed typo on line 20 where $includeEvents was incorrectly assigned to $force, improved logging
src/admin/demo/people.json Fixed 6 duplicate email addresses (dorothy.johnson2, mary.williams2, kenneth.lee2, david.rodriguez2, sarah.hall2, mary.hernandez2) to prevent database constraint violations
src/admin/demo/groups.json New comprehensive group definitions file with 12 groups (6 Sunday School classes, 6 regular groups) including member rosters and role definitions
src/admin/demo/config.json New demo system configuration file with church details, location coordinates, timezone, and contact information
src/ChurchCRM/Service/GroupService.php Added addUserToGroupInternal() method for auth-bypass group membership creation (unused in current implementation)
src/ChurchCRM/Service/DemoDataService.php Major refactoring: added constructor with logger, new importSystemConfig() and importGroups() methods, renamed importFromSimplified() to importCongregation(), removed event/financial imports, consolidated warning handling
locale/messages.po Updated translation strings for demo import UI and removed obsolete entries
cypress/e2e/xReset/admin.system-demo.spec.js Added includeSundaySchool: true parameter and increased wait timeout from 3s to 15s for CI stability

private function importFromSimplified(string $filePath): void
private function importCongregation(): array
{
$logger = LoggerUtils::getAppLogger();
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The importCongregation method creates a local $logger variable on line 170, but the class already has $this->logger initialized in the constructor. This local variable should be removed and all references to $logger in this method should use $this->logger instead for consistency.

Copilot uses AI. Check for mistakes.
$force = isset($body['force']) ? (bool)$body['force'] : false;

if (!$force) {
$peopleCount = PersonQuery::create()->count();
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent indentation: line 23 has incorrect indentation (should be indented to match line 24). The opening statement $peopleCount = PersonQuery::create()->count(); should be indented with 4 more spaces to align with the code inside the if (!$force) block.

Suggested change
$peopleCount = PersonQuery::create()->count();
$peopleCount = PersonQuery::create()->count();

Copilot uses AI. Check for mistakes.
private function importSystemConfig(bool $includeSundaySchool, bool $includeFinancial): void
{
$this->importResult['startTime'] = microtime(true);
$logger = LoggerUtils::getAppLogger();
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The importSystemConfig method creates a local $logger variable on line 111, but the class already has $this->logger initialized in the constructor (line 45). This local variable should be removed and all references to $logger in this method should use $this->logger instead for consistency.

Copilot uses AI. Check for mistakes.
Comment on lines +430 to +431
if ($isSS && isset($this->importResult['imported']['sunday_schools'])) {
$this->importResult['imported']['sunday_schools']++;
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code attempts to increment $this->importResult['imported']['sunday_schools'] on line 431, but this counter is never initialized in the $importResult array (see lines 23-35). The isset() check will always fail, and this counter will never be incremented. Either add 'sunday_schools' => 0 to the initialization array on line 26-29, or remove this conditional increment if the counter is not needed.

Copilot uses AI. Check for mistakes.
@DawoudIO DawoudIO merged commit 50ba5c5 into master Nov 24, 2025
7 checks passed
@DawoudIO DawoudIO deleted the feature/group-import branch November 24, 2025 06:56
@DawoudIO DawoudIO modified the milestones: 6.1.0, 6.2.0 Nov 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants