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

skip id segments option #16203

Closed
wants to merge 1 commit into from
Closed

Conversation

mikkeschiren
Copy link
Contributor

@mikkeschiren mikkeschiren commented Jul 13, 2020

No description provided.

$segments = $segmentEditorModel->getAllSegmentsAndIgnoreVisibility();

$segments = array_filter($segments, function ($segment) use ($idSegments) {
return (!in_array($segment['idsegment'], $idSegments));
Copy link
Member

Choose a reason for hiding this comment

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

@mikkeschiren looks good so far. The only thing I'm wondering if we could also filter by idSite?

eg

in_array($segment['idsegment'], $idSegments) && (empty($segment['enable_only_idsite']) || $idSite == $segment['enable_only_idsite'])

And then we could throw an exception if an idSegments were specified, but none matches any. This way it wouldn't by accident set no segments to force, and the user would be aware a wrong ID was set.

@tsteur tsteur added Needs Review PRs that need a code review not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. labels Jul 14, 2020
@sgiehl
Copy link
Member

sgiehl commented Jul 24, 2020

@mikkeschiren are you able to apply the changes suggested by @tsteur ?

@mikkeschiren
Copy link
Contributor Author

Yeah, sorry, been occupied will look into this and change.

@tsteur
Copy link
Member

tsteur commented Aug 31, 2020

@mikkeschiren sorry I have to close this issue. It cannot be merged as the logic changed quite a bit in Matomo 4. It will now need to be implemented in a so called ArchiveFilter similar to https://github.com/matomo-org/matomo/blob/4.x-dev/core/CronArchive/ArchiveFilter.php#L64-L68

Here is the method where it sets the segments https://github.com/matomo-org/matomo/blob/4.x-dev/core/CronArchive/ArchiveFilter.php#L124 and this is the code in the command: https://github.com/matomo-org/matomo/blob/4.x-dev/plugins/CoreConsole/Commands/CoreArchiver.php#L53-L56

It might be fairly easy to adopt the current code into this new way.

Generally I would maybe not set $this->segmentsToForce but another property eg ArchiveFilter::$segmentsToSkip and a method ArchiveFilter::setSegmentsToSkip just to make sure there won't be any side effects as skip should maybe not force all other segments except for the skipped one but really rather only skip any segment that matches the skipped ones.

@tsteur tsteur closed this Aug 31, 2020
@mattab mattab added this to the Backlog (Help wanted) milestone Sep 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review PRs that need a code review not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants