twill icon indicating copy to clipboard operation
twill copied to clipboard

Items can go missing from dashboard activity log

Open adam-jones-net opened this issue 5 years ago • 7 comments

Some events in my activity_log table are prefixed with a backslash, some are not.

The dashboard only finds events that seem to be identical to the path specified in the twill config file.

So for example, if my config file refers to

'dashboard' => [
        'modules' => [
              '\App\Models\Property' => [

then any activity_log entry that is defined as \App\Models\Property will appear, however if they are logged as App\Models\Property they won't appear.

Can this be made a bit more flexible to catch both.

adam-jones-net avatar Mar 27 '20 11:03 adam-jones-net

This may be a little more complex than I thought because it seems that on a live site I have, I am definitely referring to modules in the twill config file with a leading backslash, yet still recent records in the activity log are without that and hence there are missing items from the activity log.

adam-jones-net avatar Jul 22 '20 14:07 adam-jones-net

Why are there 2 different style of activity causer in your database though? If you setup a morphmap on a model you ensure they always have the same value, but if you don't, it is supposed to save the FQCN of the model class.

ifox avatar Jul 22 '20 14:07 ifox

So to clarify @ifox , you'd expect as standard that twill is creating activity log records with a prefixing backslash or that it doesn't?

I see in front of me from a database tool that the latest records in this site are being created in the activity_log table without an initial backslash.

As my dashboard configuration is defined WITH a prefixing backslash thats why I don't see the records appear in the activity log.

Naturally I can alter my twill.php config and remove that initial backslash, I just thought that this difference of a single character is making the activity log either work or fail and it seemed a little too picky.

BTW; why/where would I define the morph map, I thought that was for just specific relations between multiple models ?

adam-jones-net avatar Jul 22 '20 15:07 adam-jones-net

I would expect no backslash, as the FQCN of your model should be App\Models\Model.php.

For morph maps, check this out, as I don't think I can explain it better: https://laravel.com/docs/7.x/eloquent-relationships#custom-polymorphic-types

By default, Laravel will use the fully qualified class name to store the type of the related model. For instance, given the one-to-many example above where a Comment may belong to a Post or a Video, the default commentable_type would be either App\Post or App\Video, respectively. However, you may wish to decouple your database from your application's internal structure. In that case, you may define a "morph map" to instruct Eloquent to use a custom name for each model instead of the class name:

use Illuminate\Database\Eloquent\Relations\Relation;

Relation::morphMap([
    'posts' => 'App\Post',
    'videos' => 'App\Video',
]);

You may register the morphMap in the boot function of your AppServiceProvider or create a separate service provider if you wish.

ifox avatar Jul 22 '20 16:07 ifox

One thing that might be confusing you might be a bug I recently spotted in the activity log UI: Activities that are not displayed count towards the 20 items displayed limit.

ifox avatar Jul 22 '20 16:07 ifox

Thanks for all the clarification, I will ensure that the initial backslash is removed from my twill configs from now on.

Is there any chance of making the activities log code left trim a backslash in case someone silly like me adds it by accident?

adam-jones-net avatar Jul 22 '20 16:07 adam-jones-net

One thing that might be confusing you might be a bug I recently spotted in the activity log UI: Activities that are not displayed count towards the 20 items displayed limit.

It's possible I've seen that in the past as well but certainly this initial backslash is the root of a lot of the issues I've had and twill not finding valid logs as a result.

adam-jones-net avatar Jul 22 '20 16:07 adam-jones-net