Skip to content

Commit

Permalink
Skip additional attributes when serializing JSON
Browse files Browse the repository at this point in the history
Even when the --no-users option is provided to rt-dump-initialdata, RT
can still serialize users required to maintain internal consistency of
data. These additional options to rt-dump-initialdata can help to
minimize the amount of data produced for these users:

    --no-dashboards
    --no-subscriptions
    --no-bookmarks
  • Loading branch information
Jason Crome committed Jan 21, 2024
1 parent b4de1a9 commit d66b0b7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/RT/Migrate/Serializer.pm
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ sub Init {
FollowTransactions => 1,
FollowACL => 0,
FollowAssets => 1,
FollowDashboards => 1,
FollowSubscriptions => 1,
FollowBookmarks => 1,

Clone => 0,
Incremental => 0,
Expand All @@ -95,6 +98,9 @@ sub Init {
FollowTransactions
FollowAssets
FollowACL
FollowDashboards
FollowSubscriptions
FollowBookmarks
Queues
CustomFields
HyperlinkUnmigrated
Expand Down
8 changes: 8 additions & 0 deletions lib/RT/Migrate/Serializer/JSON.pm
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ sub CanonicalizeUsers {
}

$user->{Privileged} = $object->Privileged ? JSON::true : JSON::false;
#$user->{Privileged} = $object->Privileged ? \1 : \0;
}
}

Expand Down Expand Up @@ -605,6 +606,13 @@ sub CanonicalizeAttributes {
delete $self->{Records}{'RT::Attribute'}{$key}
if $self->{Records}{'RT::Attribute'}{$key}{Name} =~
/^(?:UpgradeHistory|QueueCacheNeedsUpdate|CatalogCacheNeedsUpdate|CustomRoleCacheNeedsUpdate|RecentlyViewedTickets)$/;

delete $self->{Records}{'RT::Attribute'}{$key}
if $self->{Records}{'RT::Attribute'}{$key}{Name} =~ 'Dashboard' && !$self->{FollowDashboards};
delete $self->{Records}{'RT::Attribute'}{$key}
if $self->{Records}{'RT::Attribute'}{$key}{Name} eq 'Bookmarks' && !$self->{FollowBookmarks};
delete $self->{Records}{'RT::Attribute'}{$key}
if $self->{Records}{'RT::Attribute'}{$key}{Name} eq 'Subscription' && !$self->{FollowSubscriptions};
}
}

Expand Down
7 changes: 7 additions & 0 deletions sbin/rt-dump-initialdata.in
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ GetOptions(
"deleted!",
"disabled!",

"dashboards!",
"subscriptions!",
"bookmarks!",
"scrips!",
"acls!",
"assets!",
Expand Down Expand Up @@ -131,6 +134,10 @@ $args{FollowDisabled} = $OPT{disabled} if defined $OPT{disabled};
$args{FollowScrips} = $OPT{scrips} if defined $OPT{scrips};
$args{FollowACL} = $OPT{acls} if defined $OPT{acls};

$args{FollowDashboards} = $OPT{dashboards} if defined $OPT{dashboards};
$args{FollowSubscriptions} = $OPT{subscriptions} if defined $OPT{subscriptions};
$args{FollowBookmarks} = $OPT{bookmarks} if defined $OPT{bookmarks};

$args{FollowAssets} = $OPT{assets} if defined $OPT{assets};

$args{Sync} = 1 if $OPT{sync} || $OPT{base};
Expand Down

0 comments on commit d66b0b7

Please sign in to comment.