Skip to content
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

Change user_id to created_by #15519

Merged
merged 36 commits into from
Sep 20, 2024
Merged

Change user_id to created_by #15519

merged 36 commits into from
Sep 20, 2024

Conversation

snipe
Copy link
Owner

@snipe snipe commented Sep 17, 2024

Hooboy. This is a big one but it's been on my list for forever. We previously (foolishly) used user_id since literally v0.1-alpha, and then for consistency's sake, we kept going down that path. This touches an assload of files, and we're likely have to keep the admin value in the API responses for another version or two, but I think this makes a lot more sense in the bigger picture.

This also standardizes the scopeOrderByAdmin() and adminuser() methods.

Copy link

what-the-diff bot commented Sep 17, 2024

PR Summary

  • Renamed 'admin' to 'adminuser' and 'user_id' to 'created_by' for Consistency
    The developers have updated various parts of the codebase, replacing the term 'admin' with 'adminuser' and 'user_id' with 'created_by'. This change was made for better consistency and standardization across the code.

  • Enhanced Data Retrieval in the 'Api/AssetsController'
    The system's method of retrieving data in the 'Api/AssetsController' has been improved to include ‘adminuser’ and other relevant models.

  • Updated Index Methods for New 'Created_by' Field
    The indexing methods in various areas of the code have been updated to work with the new 'created_by' field instead of the old 'user_id'. This update should improve the system's filtering and data display capabilities.

  • Updated Action tracking
    Tracking of various actions in the application has been altered to use 'adminuser' instead of 'admin'. The ‘actionlogs’ relation has been updated accordingly, and the change would also aide in accurate action tracking.

  • Updated Authorization Checks and Added New Relationships
    The developers have updated the authorization checks in the 'OauthClients.php' to verify against 'created_by' instead of 'user_id', and a new relationship 'adminuser' has been added in 'Accessory.php' - this connects accessories to their creator using 'created_by'.

  • Renamed Relationships and Updated log actions
    Relationships were renamed from 'admin' to 'adminuser' in multiple models to reflect changes in how users are associated with records. Log actions in observers were updated to set 'created_by' instead of 'user_id' when logging actions.

  • Upgraded User-Entity Associations
    Multiple files related to logging and tracking changes for User, Accessory, Asset, Company, Component, Consumable, and License factories were updated, with 'user_id' changed to 'created_by'. This improved the standard way the creating user is referenced.

  • Improved Layout for Data Tables
    Fields such as 'created_by', 'created_at', and 'updated_at' have been added across various presenters, enhancing capabilities for searching, sorting, and displaying data.

  • Refactored Code for Database Migration and Seeder Consistency
    The code was refactored to change 'user_id' to 'created_by' in the definition of multiple factories, including Department, Depreciation, License, Manufacturer, and Statuslabel. Moreover, seeders were updated to consistently use 'created_by' across varied models.

  • Updated Assertions for Accuracy in tests
    The requirements specified in various tests have been updated, replacing 'admin' with 'adminuser', and 'user_id' with 'created_by'. This updates ensure test accuracy in light of the changes made in the application.

Signed-off-by: snipe <[email protected]>
Signed-off-by: snipe <[email protected]>
commit dddbf27
Author: snipe <[email protected]>
Date:   Wed Sep 18 14:18:52 2024 +0100

    Updated language strings

    Signed-off-by: snipe <[email protected]>

commit fcefcc8
Merge: 04bb3ee 3519a82
Author: snipe <[email protected]>
Date:   Wed Sep 18 13:44:44 2024 +0100

    Merge pull request #15512 from marcusmoore/testing/fmcs

    Added tests for delete methods in api

commit 04bb3ee
Merge: 154d5d8 f963b9a
Author: snipe <[email protected]>
Date:   Wed Sep 18 13:41:37 2024 +0100

    Merge pull request #15521 from uberbrady/improve_country_selector

    Fix selected-index of Countries drop-down [fd-44144]

commit f963b9a
Author: Brady Wetherington <[email protected]>
Date:   Wed Sep 18 13:24:26 2024 +0100

    Fix selected-index of Countries drop-down

commit 154d5d8
Merge: 6c996b7 9e5f6d6
Author: snipe <[email protected]>
Date:   Tue Sep 17 23:40:25 2024 +0100

    Merge pull request #15491 from uberbrady/numeric_prefixes_add_multiple_assets

    [Fixes fd-43940] Improve multi-asset create when using numeric prefixes to asset_tags

commit 3519a82
Author: Marcus Moore <[email protected]>
Date:   Mon Sep 16 16:55:20 2024 -0700

    Fix name: TestsFullMultipleCompaniesSupport

commit a629df0
Author: Marcus Moore <[email protected]>
Date:   Mon Sep 16 14:49:08 2024 -0700

    Implement interfaces on existing test classes

commit 9a13fca
Author: Marcus Moore <[email protected]>
Date:   Mon Sep 16 14:38:38 2024 -0700

    Pluralize

commit f5705a1
Author: Marcus Moore <[email protected]>
Date:   Mon Sep 16 14:34:55 2024 -0700

    More unification

commit f325c4a
Author: Marcus Moore <[email protected]>
Date:   Mon Sep 16 14:32:38 2024 -0700

    Unify assertion method

commit 1fddacd
Author: Marcus Moore <[email protected]>
Date:   Mon Sep 16 14:25:11 2024 -0700

    Re-order test methods

commit 4af893d
Author: Marcus Moore <[email protected]>
Date:   Mon Sep 16 14:20:24 2024 -0700

    Improve assertions

commit b8b3f91
Author: Marcus Moore <[email protected]>
Date:   Mon Sep 16 13:55:18 2024 -0700

    Formatting

commit 7f40f55
Author: Marcus Moore <[email protected]>
Date:   Mon Sep 16 13:52:02 2024 -0700

    Add tests for delete supplier endpoint

commit b06e8d4
Author: Marcus Moore <[email protected]>
Date:   Mon Sep 16 13:37:08 2024 -0700

    Add tests for delete status label endpoint

commit c269184
Author: Marcus Moore <[email protected]>
Date:   Mon Sep 16 13:29:41 2024 -0700

    Add tests for delete predefined kit endpoint

commit 53c673d
Author: Marcus Moore <[email protected]>
Date:   Mon Sep 16 13:13:12 2024 -0700

    Add tests for delete manufacturer endpoint

commit 50730fc
Author: Marcus Moore <[email protected]>
Date:   Mon Sep 16 12:37:18 2024 -0700

    Add tests for delete location endpoint

commit 60a54ce
Author: Marcus Moore <[email protected]>
Date:   Mon Sep 16 12:33:30 2024 -0700

    Add tests for delete license endpoint

commit 446e962
Author: Marcus Moore <[email protected]>
Date:   Mon Sep 16 10:38:51 2024 -0700

    Add tests for delete group endpoint

commit 79a4bb7
Author: Marcus Moore <[email protected]>
Date:   Mon Sep 16 10:35:44 2024 -0700

    Add tests for delete depreciation endpoint

commit 2f76c1b
Author: Marcus Moore <[email protected]>
Date:   Mon Sep 16 10:33:21 2024 -0700

    Add assertion

commit 38b9f4a
Author: Marcus Moore <[email protected]>
Date:   Mon Sep 16 10:29:20 2024 -0700

    Add tests for delete departments endpoint

commit 3105f53
Author: Marcus Moore <[email protected]>
Date:   Thu Sep 12 16:54:29 2024 -0700

    Add tests for delete custom fieldsets endpoint

commit 2047cfe
Author: Marcus Moore <[email protected]>
Date:   Thu Sep 12 16:20:32 2024 -0700

    Add tests for delete custom fields endpoint

commit e3268d3
Author: Marcus Moore <[email protected]>
Date:   Thu Sep 12 16:00:02 2024 -0700

    Add tests for delete consumable endpoint

commit 6df8b0a
Author: Marcus Moore <[email protected]>
Date:   Thu Sep 12 15:52:07 2024 -0700

    Add tests for delete component endpoint

commit 910f13c
Author: Marcus Moore <[email protected]>
Date:   Thu Sep 12 15:38:30 2024 -0700

    Add tests for delete companies endpoint

commit 8ce2512
Author: Marcus Moore <[email protected]>
Date:   Thu Sep 12 13:54:44 2024 -0700

    Add tests for delete category endpoint

commit 0ec415d
Author: Marcus Moore <[email protected]>
Date:   Thu Sep 12 13:46:22 2024 -0700

    Clean up

commit 2044570
Author: Marcus Moore <[email protected]>
Date:   Thu Sep 12 13:39:36 2024 -0700

    Add tests for delete asset model endpoint

commit b336c62
Author: Marcus Moore <[email protected]>
Date:   Thu Sep 12 13:32:42 2024 -0700

    Pluralize test classes

commit 5299b3e
Author: Marcus Moore <[email protected]>
Date:   Thu Sep 12 13:29:44 2024 -0700

    Remove code handled by CompanyableChildTrait

commit 872b76b
Author: Marcus Moore <[email protected]>
Date:   Thu Sep 12 13:29:10 2024 -0700

    Add tests for delete asset maintenance endpoint

commit 275cf46
Author: Marcus Moore <[email protected]>
Date:   Thu Sep 12 13:16:37 2024 -0700

    Add tests for delete asset endpoint

commit 5c2660b
Author: Marcus Moore <[email protected]>
Date:   Thu Sep 12 13:02:32 2024 -0700

    Introduce interface

commit c7ae9d9
Author: Marcus Moore <[email protected]>
Date:   Thu Sep 12 12:58:47 2024 -0700

    Add tests for delete accessory endpoint

commit 9e5f6d6
Author: Brady Wetherington <[email protected]>
Date:   Wed Sep 11 15:45:01 2024 +0100

    Improve multi-asset create when using numeric prefixes to asset_tags

Signed-off-by: snipe <[email protected]>
Signed-off-by: snipe <[email protected]>
Signed-off-by: snipe <[email protected]>
@snipe snipe changed the title WIP: Change user_id to created_by Change user_id to created_by Sep 19, 2024
@snipe snipe marked this pull request as ready for review September 19, 2024 17:38
@snipe snipe requested a review from marcusmoore September 19, 2024 18:57
@snipe snipe merged commit b83d1a0 into develop Sep 20, 2024
8 of 9 checks passed
@snipe snipe deleted the features/add_created_at_created_by branch September 20, 2024 12:47
Copy link
Collaborator

@uberbrady uberbrady left a comment

Choose a reason for hiding this comment

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

Once I got into the meat of this change, it started to seem very obviously superior to how we were doing it before - it's crystal-clear what the 'created_by' means and 'user_id' is still a little obtuse. So I think it's a great change! I did see a few other changes mixed in with this, and I still have to mention that it's much cleaner if we can have a big change like this just be the big change like this, and the other smaller changes be separated out. It's just 10x easier to review when we have that. I also still wonder if having 'createdBy' as the method name (which contains the relationship) corresponding to created_at as the column might be simpler? But, regardless of those nits, this is a great change and should really improve the "Developer Experience" (DX) on the product, as well as us from the support side being able to more quickly identify what various column names mean. Great job - a little scary, yes - but great!

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