Skip to content

Conversation

douglasduteil
Copy link
Contributor

@douglasduteil douglasduteil commented Sep 9, 2025


Refactors the moderations repository functions to use a consistent PascalCase factory pattern:

  • get_moderationGetModeration factory returning get_moderation handler
  • get_duplicate_moderationsGetDuplicateModerations factory
  • get_moderations_listGetModerationsList factory
  • Updated corresponding type names from get_*_dto to Get*Dto
  • Fixed type definitions to properly handle Promise return types
  • All imports and references updated throughout the codebase

The factory pattern provides better dependency injection and follows the established PascalCase naming convention used elsewhere in the codebase.

@github-actions github-actions bot added 🌐 api Global, connected routes handling requests. scope: moderations 📚 lib 🗄️ database labels Sep 9, 2025
@douglasduteil douglasduteil self-assigned this Sep 9, 2025
…pository

- Move get_moderation from context files to repository as specialized functions
- GetModerationWithDetails: returns full moderation with organization and user details
- GetModerationForEmail: returns minimal data for email context (ticket_id, user.email)
- Update all imports and references to use new repository functions
- Remove duplicate local functions from context files
@douglasduteil douglasduteil force-pushed the douglasduteil/-recycle-refactor-moderations-rename-repository-functions-to-PascalCase-factory-pattern branch from aafacb4 to b57177f Compare September 9, 2025 17:11
- Add test coverage for GetModeration, GetModerationWithDetails, GetModerationForEmail
- Add test coverage for GetDuplicateModerations and GetModerationsList
- Test success paths, error handling, and edge cases
- Fix database transaction usage in GetModerationsList
- Use proper beforeEach(empty_database) pattern for test isolation
- Create GetOrganizationMember factory function in organizations repository
- Update moderations context to use new repository function
- Remove local get_organization_member from context files
- Clean up unused imports
- Follows established PascalCase factory pattern
- Add GetOrganizationMember test with proper user-organization relationship setup
- Add get_organizations_by_user_id test with pagination and edge cases
- Add get_user_by_id test covering user retrieval and null handling
- Add find_users_by_name test with case-insensitive search validation
- All tests follow established patterns with proper database setup and cleanup
- Add GetDomainCount factory function with comprehensive test
- Add GetOrganizationsList factory function following established pattern
- Add GetUserById factory function for user retrieval
- Add FindUsersByName factory function for name-based search
- Update repository indexes to export new factory functions
- All functions follow consistent PascalCase factory pattern established in moderations
- Maintains backward compatibility while establishing new standard
…version

- Add GetOrganizationMembersCount factory function for member counting
- Add GetDomains factory function for organization domain retrieval
- Add GetUsersByOrganizationId factory function with pagination support
- Add GetEmailsByOrganizationId factory function with family name matching
- Update repository indexes to export all new factory functions
- Maintain consistent PascalCase factory pattern across all domains
- All functions provide proper TypeScript typing and handler interfaces
Replace old snake_case function imports with new PascalCase factory pattern imports:
- GetUsersByOrganizationId replaces get_users_by_organization_id
- GetOrganizationsList replaces get_organizations_list
- GetDomainCount replaces get_domain_count
- GetOrganizationMembersCount replaces get_organization_members_count

Update function calls to use factory pattern with database injection.
Update TypeScript types to use new PascalCase naming conventions.
Create PascalCase factory functions for organizations repository:
- GetOrganizationsByUserId replaces get_organizations_by_user_id
- AddMemberToOrganization replaces add_member_to_organization
- AddVerifiedDomain replaces add_verified_domain

Update repository index to export both old and new functions for backward compatibility.
Add comprehensive test coverage for all new factory functions.
Update test imports to use correct identite-proconnect database testing utilities:
- Replace @~/app.database/seed_data with @~/identite-proconnect.database/seed
- Add proper database migration and cleanup in beforeEach hooks
- Use create_adora_pony_user and create_unicorn_organization helpers

Tests need further debugging but core functionality verified.
Fix test implementations with proper setup and inline snapshots:
- GetOrganizationsByUserId: Use proper user-organization creation pattern
- AddMemberToOrganization: Fix empty columns selection, add id field
- AddVerifiedDomain: Update to async function and return statement
- Remove describe blocks to match coding style
- Add proper database setup with migrate/empty_database hooks
- Generate inline snapshots for all tests
- Fix TypeScript exports in repository index
Removed duplicate files after PascalCase migration:
- Organizations: removed 8 snake_case files with PascalCase equivalents
- Users: removed 4 snake_case files with PascalCase equivalents
- Removed all corresponding test files and snapshots

File renames for consistency:
- get_organization_by_id.ts → GetOrganizationById.ts
- get_member.ts → GetMember.ts
- Updated repository index exports

✅ All tests passing (10/10)
✅ TypeScript compilation successful
✅ Clean repository with consistent PascalCase factory pattern
@douglasduteil douglasduteil force-pushed the douglasduteil/-recycle-refactor-moderations-rename-repository-functions-to-PascalCase-factory-pattern branch from 04872db to 6b9e33b Compare September 9, 2025 19:42
@douglasduteil douglasduteil merged commit 09ff070 into master Sep 9, 2025
17 checks passed
@douglasduteil douglasduteil deleted the douglasduteil/-recycle-refactor-moderations-rename-repository-functions-to-PascalCase-factory-pattern branch September 9, 2025 20:08
Copy link

🚀 This pull request is included in v2025.9.0. See Release 2025.9.0 for release notes.

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.

1 participant