-
Notifications
You must be signed in to change notification settings - Fork 0
Refactor sync with new models api #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…c with the new resource names used throughout the API.
…th a new Map<Enum, Set<String>>. This map uses the AppUserRole and DashboardUserRole enums as keys, directly linking the new user model structure to the RBAC system
- Fixed typo in DashboardUserRole enum value - Changed 'DashboardUser-Role.admin' to 'DashboardUserRole.admin' - This correction ensures proper mapping of admin permissions to the correct role
- Update hasPermission method to consider both appRole and dashboardRole - Modify isAdmin method to check dashboardRole directly - Improve documentation to reflect new logic and role separation
- Replace 'roles' claim with 'appRole' and 'dashboardRole' claims - Use enum .name property for role string values - Keep 'email' claim for convenience
- Update user creation flow for both registered and anonymous users - Enhance user object with additional properties and default values - Improve error handling and validation for account linking process - Replace role checks with more specific appRole comparisons
- Change role check to use dashboardRole instead of roles list - Update new user creation output to show appRole instead of roles - Improve code readability by using separate lines for output messages
…ervice - Update DashboardSummaryService to use HtDataRepository<Topic> instead of HtDataRepository<Category> - Modify the service to fetch topics instead of categories - Update the returned DashboardSummary to use topicCount instead of categoryCount
…encies - Replace AppConfig with RemoteConfig for fetching user preference limits - Remove unused UserContentPreferencesRepository dependency - Simplify user role checking by using dashboardRole instead of roles - Update error handling and messaging - Rename `followedCategories` to `followedTopics` in error message
- Rename tables and columns to better reflect their content and usage - Add new columns for upcoming features like ad config and account action config - Remove unused columns to simplify the schema - Adjust foreign key relationships to match new table names """ Changed database schema to support new features and improve data organization. Here are the key changes: - Renamed 'app_config' to 'remote_config' to clarify its purpose - Renamed 'categories' to 'topics' to better reflect the content - Removed 'type' columns from multiple tables as they were no longer used - Added new columns to 'remote_config' for ad config, account action config, and app status - Changed 'categories' to 'topics' in the 'headlines' table - Removed 'last_engagement_shown_at' from 'users' table - Updated table and column names to align with new feature requirements
- Rename 'categories' to 'topics' in seeding process - Remove 'type' field from countries, sources, and headlines tables - Remove 'category' and 'event_country' objects from headlines seeding - Update SQL queries to reflect schema changes
- Replace AppConfig with RemoteConfig to accommodate multiple JSONB columns - Update admin user seeding to reflect new User model structure - Improve error handling and logging - Refactor JSONB data insertion to ensure proper encoding
- Extract timestamp conversion to shared function - Simplify foreign key handling in serializers - Rename category to topic for better clarity - Update repository names and configurations - Refactor user and content preferences handling - Rename and expand remote config functionality
- Rename 'category' to 'topic' in model registry - Update permission names for consistency - Correct permission type for remote config read access - Update user preference permissions to content preference - Rename 'app_config' to 'remote_config' for clarity
- Add log dependency to DefaultUserPreferenceLimitService constructor - Improve error tracking and debugging for user preference operations
- Adjust line breaks and indentation for better readability - Add missing log parameter in JwtAuthTokenService and UserPreferenceService - Remove unnecessary blank lines and comments
- Add logging dependency and integrate Logger into InMemoryTokenBlacklistService - Replace all print statements with appropriate log levels - Update constructor to require Logger instance - Adjust log messages to follow consistent formatting
- Inject log service into InMemoryTokenBlacklistService for better error tracking and debugging
…kenService - Inject Logger into SimpleAuthTokenService - Replace print statements with appropriate log levels - Update log messages to use logging conventions - Remove unnecessary print statements and use logging for all output
…arity - Improve authentication description: passwordless email sign-in and role-aware login - Refine RBAC explanation: dual-role system for app features and admin functions - Expand user preferences: include followed topics - Enhance data management: add topics to core news data - Update dashboard summary: include topics in key data points
Adds a `Logger` dependency to the `DefaultUserPreferenceLimitService` and replaces `print` statements with structured logging. This resolves the `undefined_named_parameter` error in `app_dependencies.dart`.
Corrects several issues in `app_dependencies.dart`: - Adds missing documentation comments for all public repository and service members. - Refactors simple `toJson` handlers to use cascade notation to resolve linter warnings. - Injects the `Logger` into `InMemoryTokenBlacklistService` to fix a compile error.
Refactors the `JwtAuthTokenService` to use a `Logger` instance for structured logging, replacing all previous `print()` calls.
- Replace lambda functions with direct method references for improved readability - Update userAppSettingsRepository and userContentPreferencesRepository initializers
- Fixes a bug where `UserAppSettings` and `UserContentPreferences` were created without required default values for new and anonymous users. - Implements the account deletion cleanup logic. Deleting a user from the `users` table now correctly cascades to delete their associated settings and preferences, and any pending verification codes are cleared.
Resolves several issues in `DatabaseSeedingService`: - Fixes multiple `argument_type_not_assignable` errors by correctly calling `.toJson()` on model objects before passing them as parameters to the database driver. - Imports fixture data correctly to resolve an `undefined_identifier` error. - Fixes `undefined_operator` errors by converting model objects to maps before attempting to add properties. - Cleans up code by using cascade notation to resolve linter warnings.
Resolves several issues in `DatabaseSeedingService`: - Fixes multiple `argument_type_not_assignable` errors by correctly calling `.toJson()` on model objects before passing them
- Change JSON key from 'user_preference_limits' to 'user_preference_config' - Update 'user_preference_limits' references to 'user_preference_config' in SQL queries - Replace 'remoteConfig' variable with 'remoteConfigFixtureData' constant - Update 'limits' retrieval from 'userPreferenceLimits' to 'userPreferenceConfig' - Change 'headlineDensity' from 'normal' to 'standard' in auth service These changes improve consistency and accuracy in database schema and code references.
Replaces all references to 'category' with 'topic' and 'app_config' with 'remote_config' in the item-specific data handler at `/api/v1/data/[id].dart`. This change ensures the GET, PUT, and DELETE operations for individual items correctly use the updated `Topic` and `RemoteConfig` models and their corresponding repositories.
Standardizes the success response for the anonymous sign-in endpoint by including the `ResponseMetadata` object, which contains the `requestId` and a timestamp. This ensures that all successful authentication responses that return a body are structured consistently, improving API uniformity.
Standardizes the success response for the verify-code endpoint by including the `ResponseMetadata` object, which contains the `requestId` and a timestamp. This ensures that all successful authentication responses that return a body are structured consistently, improving API uniformity.
Standardizes the success response for the verify-link-email endpoint by including the `ResponseMetadata` object, which contains the `requestId` and a timestamp. This ensures that all successful authentication responses that return a body are structured consistently, improving API uniformity.
Removes the unnecessary and incorrect try-catch block around reading the `requestId` from the context in the `/api/v1/auth/me` handler. The `requestId` is guaranteed to be provided by the global middleware, so reading it directly resolves the `String?` to `String` type assignment error and aligns this handler's implementation with other authentication routes.
Replaces all occurrences of 'Category' with 'Topic' and 'categories' with 'topics' in the generic data collection route handler (/api/v1/data). This change aligns the route's logic, query parameter handling, and comments with the recent model refactoring where the Category model was renamed to Topic, resolving multiple type errors.
Replaces all occurrences of 'AppConfig' with 'RemoteConfig' and 'app_config' with 'remote_config' in the generic data collection route handler (/api/v1/data). This change aligns the route's logic with the recent model refactoring where the AppConfig model was renamed to RemoteConfig, resolving multiple type errors.
Corrects an outdated comment in the test case documentation within `routes/api/v1/data/index.dart`. The comment incorrectly stated that searching for a country via the `q` parameter only checked the name field. The implementation correctly searches both the `name` and `isoCode` fields. This change updates the comment to accurately reflect the code's behavior.
Updates the `_mapExceptionToCodeString` function in the error handler middleware to use `camelCase` for all generated error codes (e.g., `INVALID_INPUT` becomes `invalidInput`). This change ensures that all API error responses are fully compliant with the project's strict `camelCase` convention for JSON payloads.
…nd invalidateToken methods - Replace multiple _log method calls with chained calls using .. operator - Consolidate log statements in JwtAuthTokenService class - Improve code readability and reduce line count for better maintainability
Removes the iteration over `_env.map` to resolve an `invalid_use_of_visible_for_testing_member` warning. The `.map` getter in the `dotenv` package is intended for testing only. This change respects the dependency's API contract, making the configuration loading more robust and removing the lint warning. The error message for a missing `DATABASE_URL` remains clear and actionable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @fulleni, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request introduces significant refactoring to the application's core data models and user role management. It replaces existing Category
and AppConfig
models with Topic
and RemoteConfig
respectively, and overhauls the user role system to support distinct application and dashboard roles. These changes necessitate updates across the database schema, data repositories, authentication services, permission checks, and API endpoint logic, while also integrating structured logging for improved system visibility.
Highlights
- Core Model Refactoring: The
Category
model has been replaced by a newTopic
model, andAppConfig
has been replaced byRemoteConfig
. This involves schema changes, repository updates, and adjustments across various services and API endpoints. - Enhanced Role-Based Access Control (RBAC): The user role system has been refactored from a single list of roles to a dual-role system, introducing
appRole
(for application features) anddashboardRole
(for administrative functions). This impacts user creation, authentication, and permission checks. - Standardized Logging: Numerous
print()
statements across the codebase have been replaced with structured logging using theLogger
class, improving observability and debugging capabilities. - Centralized Timestamp Handling: A new private utility function
_convertTimestampsToString
has been introduced inAppDependencies
to centralize the conversion ofDateTime
objects (returned by the Postgres driver) to ISO 8601 strings, ensuring consistency for model deserialization. - API Endpoint and Data Query Updates: API endpoints for data access (
/api/v1/data
and/api/v1/data/[id]
) have been updated to reflect the newTopic
andRemoteConfig
models, including changes to filtering parameters and internal data handling. - Error Code Standardization: HTTP error codes returned by the
errorHandler
middleware have been standardized fromSCREAMING_SNAKE_CASE
tocamelCase
for better API consistency.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request is a significant and well-executed refactoring to align the API with new data models and a dual-role (app/dashboard) permission system. The changes are consistent across services, repositories, and route handlers. Logging has been substantially improved by replacing print
statements with a structured logger, which will greatly aid in debugging.
I've found a couple of issues: one critical issue regarding a missing timestamp conversion that could lead to runtime errors, and one medium-severity issue in the README with a duplicated section. Once these are addressed, the PR should be in excellent shape.
* 💾 **Robust Data Management:** Securely manage core news data (headlines, | ||
topics, sources) through a well-structured API that supports flexible | ||
querying and sorting for dynamic content presentation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Status
READY/IN DEVELOPMENT/HOLD
Description
Type of Change