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

Resolve Duplicate Activity Logs for Imports #14172

Merged
merged 6 commits into from
Feb 15, 2024

Conversation

spencerrlongg
Copy link
Collaborator

Description

Resolves the issue with duplicate activity logs for items that were created using the importer by setting an attribute on the Loggable trait and removing the specific log point on the importer classes, setting the attribute at import time, and then checking for it on the observer to set the note correctly.

Also added a sample CSV for Components.

Fixes SC:23514

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Tested each of the import types to make sure no more duplicates and that they were logged correctly.

Test Configuration:

  • PHP version: 8.1
  • MySQL version 8.1

Checklist:

Copy link

This pull request has been linked to Shortcut Story #23514: Newly imported assets appear twice in Activity report.

Copy link

what-the-diff bot commented Jan 26, 2024

PR Summary

  • Added imported Attribute in Loggable trait
    An additional characteristic imported has been introduced which would keep a record of if an item has been imported.

  • Updated Importer Files (AccessoryImporter.php, AssetImporter.php, ComponentImporter.php, ConsumableImporter.php, LicenseImporter.php)
    The model validation disabling lines have been removed from these files, ensuring that all data is validated before importing for consistent data quality.
    Also, individual log entries creation process has been removed as this is now replaced by the imported attribute. This attribute is set to true whenever an item is imported.

  • Updated Observer Files (AccessoryObserver.php, AssetObserver.php, ComponentObserver.php, ConsumableObserver.php, LicenseObserver.php)
    To keep a consistent and easy tracking mechanism, conditions have been added to check if the imported attribute is set to true. If it is, the log note is adjusted accordingly. This helps in effectively monitoring the import process and quickly identifying newly imported items.

  • Added Sample CSV File for Components
    A new CSV file components-sample.csv has been added in the sample_csvs directory. This would help to understand the format and provide examples for component data that needs to be imported.

Copy link
Collaborator

@marcusmoore marcusmoore left a comment

Choose a reason for hiding this comment

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

I dig it 👍🏾 nice solution 😄

@spencerrlongg
Copy link
Collaborator Author

Changed this to set the action_source instead of a note.

@spencerrlongg
Copy link
Collaborator Author

@snipe quick poke on this

@snipe snipe merged commit b871813 into snipe:develop Feb 15, 2024
8 checks passed
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.

3 participants