{"id":22291332,"url":"https://github.com/maestroerror/area-17-care-exercise","last_synced_at":"2025-03-25T21:43:07.386Z","repository":{"id":213286597,"uuid":"733457332","full_name":"MaestroError/area-17-care-exercise","owner":"MaestroError","description":null,"archived":false,"fork":false,"pushed_at":"2023-12-19T20:03:52.000Z","size":743,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"maestro","last_synced_at":"2025-01-30T18:51:24.272Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MaestroError.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-12-19T11:22:28.000Z","updated_at":"2023-12-19T11:23:44.000Z","dependencies_parsed_at":"2024-02-03T04:45:21.047Z","dependency_job_id":null,"html_url":"https://github.com/MaestroError/area-17-care-exercise","commit_stats":null,"previous_names":["maestroerror/area-17-care-exercise"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaestroError%2Farea-17-care-exercise","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaestroError%2Farea-17-care-exercise/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaestroError%2Farea-17-care-exercise/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaestroError%2Farea-17-care-exercise/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MaestroError","download_url":"https://codeload.github.com/MaestroError/area-17-care-exercise/tar.gz/refs/heads/maestro","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245550588,"owners_count":20633871,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-03T17:16:47.196Z","updated_at":"2025-03-25T21:43:07.371Z","avatar_url":"https://github.com/MaestroError.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# A17 Blog\n\n## Requirements\n\nYou need to have PHP, NodeJS and MySQL to run this project. We recommend\nusing [Laravel Valet](https://laravel.com/docs/8.x/valet) in local development.\n\n### Installation\n\n```console\n$ cd exercise-repo\n$ composer install\n$ cp .env.example .env\n$ php artisan key:generate\n```\n\nNote: Do not forget to start your database!\n\nMake sure to update your `.env` file:\n\n```shell\nDB_DATABASE={your-database}\nAPP_URL={your-url}\n```\n\nOnce you're done, you can seed the database with data:\n\n```console\n$ php artisan migrate --seed\n```\n\n### Tests\n\nYou can run application tests with Artisan:\n\n```console\n$ php artisan test\n```\n\n## Specs\n\n### Important points\n\n-   Any user can sign up and create their own blog (back office)\n-   Any visitor can see all posts (front)\n\n### User\n\n#### Specificities\n\n-   Need to register, be logged in login.\n\n#### Model\n\n-   **email**, unique and valid\n-   **password**, 8 characters mini and some special characters\n-   **username**, unique with no special characters. Slug\n\n### Post\n\n#### Specificities\n\n-   Order by published_at, from now to older (reverse chronological)\n-   Need pagination (8 per page).\n-   Permalink page `\u003csite\u003e/\u003cusername\u003e/\u003cpost_unique_slug_from_title\u003e`.\n-   Each post view should include a link back to the user's author `\u003csite\u003e/\u003cusername\u003e`\n\n#### Model\n\n-   **title**, slug\n-   **author_id**, id of the user who has made the post\n-   **body**, text\n-   **published_at**, datetime (when a post is published)\n\n---\n\n### Process log\n\n-   Updated packages using `composer update`.\n-   Checked unit tests by running `php artisan test`. _(cmt: composer update and unit tests checked)_\n    -   fixed `could not find driver (SQL: PRAGMA foreign_keys = ON;)` issue by enabling the `pdo_sqlite` extension.\n-   Created an account and tested everything that is written down in the \"Initial requirements\" section. _(cmt: initial review of application)_\n    -   During this process, I was able to replicate the permission issue (#2) by replacing the post's slug in my post's edit page URL with other post slug created by another user.\n    -   The permission issue #1 doesn't exist - The user can't edit content without logging in.\n-   Strategy: While it is an existing project, I decided to maintain the existing style and make as few changes as I can.\n-   Issue #1: Stronger passwords. _(br: stronger-passwords-issue-1)_\n    -   Found the `PasswordValidationRules` trait with the method `passwordRules` used in password-related validations.\n    -   Updated rules, added: `'min:8'`, `'regex:/[^\\w]/'`.\n    -   Added a new method `passwordCustomMessages` for specifying that the regex error is related to special characters.\n    -   Passed custom messages (using unpacking `...` operator) as a second parameter in every action which uses the `passwordRules` method. _(cmt)_\n    -   Added the new `test_registration_fails_with_invalid_password` test case. _(cmt)_\n    -   Created [PR](https://github.com/MaestroError/area-17-care-exercise/pull/1) and merged.\n-   Issue #2: Permissions. _(br: post-permissions-fix)_\n    -   Found `PostPolicy` and post's update and store requests, which are used in the posts controller.\n    -   Registered `PostPolicy` in `AuthServiceProvider`.\n    -   Added try/catch block in PostController's `update` method to authorize the user and return an error message. _(cmt)_\n    -   Added the new `test_user_cannot_edit_other_users_post` test case. _(cmt)_\n    -   Created [PR](https://github.com/MaestroError/area-17-care-exercise/pull/2) and merged.\n-   Issue #3: Performance. _(br: performance-issues)_\n    -   Reviewed code and found out:\n        -   The `posts` query seems nice and could be optimized in some small details, but it isn't critical.\n        -   The `authors` query needs a lot of optimizations and has critical issues.\n    -   Optimizing `authors` query used in the sidebar component (\"Random authors\"):\n        -   Moved the take method before the `get` method in the query chain.\n        -   The method `with` was replaced with the `withCount` method and added `is_active = true` condition to replicate the logic used in the `authors.blade.php` template\n        -   Updated the `authors.blade.php` template to use `posts_count` property\n        -   Updated the `@include` directives - passing the authors variable to make obvious, which data is used by the component (increases readability)\n        -   Tested, worked - centralized the updated query as a scope to reuse in other controllers _(cmt)_\n    -   Considerations about the `posts` query:\n        -   Posts query is a pretty good one. I would consider with PM to disable the future publishing (`'published_at', '\u003c=', Carbon::now()`) check in the Post's `published` scope (if it isn't planned), because it is useful with publish scheduling feature and we haven't it in this project.\n        -   I would consider adding caching by pages here, but this change adds the \"delay\" in displaying new posts on the front, so it needs some discussion too.\n        -   Also, indexing some columns (author_id, published_at) could be helpful.\n    -   Created [PR](https://github.com/MaestroError/area-17-care-exercise/pull/3) and merged.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaestroerror%2Farea-17-care-exercise","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaestroerror%2Farea-17-care-exercise","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaestroerror%2Farea-17-care-exercise/lists"}