Skip to content
Next
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Minds Backend - Engine
Project
Project
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
228
Issues
228
List
Boards
Labels
Service Desk
Milestones
Merge Requests
32
Merge Requests
32
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Security & Compliance
Security & Compliance
Dependency List
Packages
Packages
List
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Minds
Minds Backend - Engine
Commits
d66a1ef5
Commit
d66a1ef5
authored
7 minutes ago
by
Mark Harding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(feat): multiple changes to aid with frontend
parent
db7b4fc6
feat/entity-centric-metrics
1 merge request
!343
WIP: Analytics Dashboard
Pipeline
#87882057
failed with stages
in 4 minutes and 21 seconds
Changes
12
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
128 additions
and
12 deletions
+128
-12
Controllers/api/v2/analytics/dashboards.php
Controllers/api/v2/analytics/dashboards.php
+1
-1
Core/Analytics/Dashboards/Filters/AbstractFilter.php
Core/Analytics/Dashboards/Filters/AbstractFilter.php
+4
-0
Core/Analytics/Dashboards/Filters/ChannelFilter.php
Core/Analytics/Dashboards/Filters/ChannelFilter.php
+36
-0
Core/Analytics/Dashboards/Filters/FilterOptionsOption.php
Core/Analytics/Dashboards/Filters/FilterOptionsOption.php
+4
-0
Core/Analytics/Dashboards/Filters/PlatformFilter.php
Core/Analytics/Dashboards/Filters/PlatformFilter.php
+8
-2
Core/Analytics/Dashboards/Filters/ViewTypeFilter.php
Core/Analytics/Dashboards/Filters/ViewTypeFilter.php
+10
-3
Core/Analytics/Dashboards/Metrics/AbstractMetric.php
Core/Analytics/Dashboards/Metrics/AbstractMetric.php
+8
-0
Core/Analytics/Dashboards/Metrics/ActiveUsersMetric.php
Core/Analytics/Dashboards/Metrics/ActiveUsersMetric.php
+4
-1
Core/Analytics/Dashboards/Metrics/SignupsMetric.php
Core/Analytics/Dashboards/Metrics/SignupsMetric.php
+4
-1
Core/Analytics/Dashboards/Metrics/ViewsMetric.php
Core/Analytics/Dashboards/Metrics/ViewsMetric.php
+41
-1
Core/Analytics/Dashboards/Metrics/Visualisations/ChartVisualisation.php
.../Dashboards/Metrics/Visualisations/ChartVisualisation.php
+5
-1
Core/Analytics/Dashboards/TrafficDashboard.php
Core/Analytics/Dashboards/TrafficDashboard.php
+3
-2
No files found.
Controllers/api/v2/analytics/dashboards.php
View file @
d66a1ef5
...
...
@@ -25,7 +25,7 @@ class dashboards implements Interfaces\Api, Interfaces\ApiIgnorePam
$dashboard
->
setTimespanId
(
$_GET
[
'timespan'
]);
}
if
(
isset
(
$_GET
[
'filter
s
'
]))
{
if
(
isset
(
$_GET
[
'filter'
]))
{
$filterIds
=
explode
(
','
,
$_GET
[
'filters'
]);
$dashboard
->
setFilterIds
(
$filterIds
);
}
...
...
This diff is collapsed.
Click to expand it.
Core/Analytics/Dashboards/Filters/AbstractFilter.php
View file @
d66a1ef5
...
...
@@ -13,6 +13,9 @@ abstract class AbstractFilter
/** @var string */
protected
$label
;
/** @var string */
protected
$description
;
/** @var FilterOptions */
protected
$options
;
...
...
@@ -45,6 +48,7 @@ abstract class AbstractFilter
return
[
'id'
=>
(
string
)
$this
->
id
,
'label'
=>
(
string
)
$this
->
label
,
'description'
=>
(
string
)
$this
->
description
,
'options'
=>
(
array
)
$this
->
options
->
export
(),
];
}
...
...
This diff is collapsed.
Click to expand it.
Core/Analytics/Dashboards/Filters/ChannelFilter.php
0 → 100644
View file @
d66a1ef5
<?php
namespace
Minds\Core\Analytics\Dashboards\Filters
;
class
ChannelFilter
extends
AbstractFilter
{
/** @var string */
protected
$id
=
"channel"
;
/** @var string */
protected
$label
=
"Channel"
;
/** @var string */
protected
$description
=
"Filter by channels or by the full site"
;
/** @var string */
protected
$selectedOption
=
"all"
;
public
function
__construct
()
{
$this
->
options
=
(
new
FilterOptions
())
->
setOptions
(
(
new
FilterOptionsOption
())
->
setId
(
"all"
)
->
setLabel
(
"All"
)
->
setDescription
(
"Global, site-wide metrics"
),
(
new
FilterOptionsOption
())
->
setId
(
"self"
)
->
setLabel
(
"Me"
)
->
setDescription
(
"Your currently logged in user"
),
(
new
FilterOptionsOption
())
->
setId
(
"custom"
)
->
setLabel
(
"Custom (Search)"
)
->
setDescription
(
"Search for a channel to view their metrics"
)
);
}
}
This diff is collapsed.
Click to expand it.
Core/Analytics/Dashboards/Filters/FilterOptionsOption.php
View file @
d66a1ef5
...
...
@@ -16,6 +16,9 @@ class FilterOptionsOption
/** @var string */
private
$label
;
/** @var string */
private
$description
;
/** @var bool */
private
$available
=
true
;
...
...
@@ -32,6 +35,7 @@ class FilterOptionsOption
return
[
'id'
=>
$this
->
id
,
'label'
=>
$this
->
label
,
'description'
=>
$this
->
description
,
'available'
=>
(
bool
)
$this
->
available
,
'selected'
=>
(
bool
)
$this
->
selected
,
];
...
...
This diff is collapsed.
Click to expand it.
Core/Analytics/Dashboards/Filters/PlatformFilter.php
View file @
d66a1ef5
...
...
@@ -9,19 +9,25 @@ class PlatformFilter extends AbstractFilter
/** @var string */
protected
$label
=
"Platform"
;
/** @var string */
protected
$description
=
"Filter by device types"
;
public
function
__construct
()
{
$this
->
options
=
(
new
FilterOptions
())
->
setOptions
(
(
new
FilterOptionsOption
())
->
setId
(
"all"
)
->
setLabel
(
"All"
),
->
setLabel
(
"All"
)
->
setDescription
(
"Browsers, Mobile and APIs"
),
(
new
FilterOptionsOption
())
->
setId
(
"browser"
)
->
setLabel
(
"Browser"
),
->
setLabel
(
"Browser"
)
->
setDescription
(
"Browsers"
),
(
new
FilterOptionsOption
())
->
setId
(
"mobile"
)
->
setLabel
(
"Mobile"
)
->
setDescription
(
"Native mobile applications"
)
);
}
}
This diff is collapsed.
Click to expand it.
Core/Analytics/Dashboards/Filters/ViewTypeFilter.php
View file @
d66a1ef5
...
...
@@ -9,22 +9,29 @@ class ViewTypeFilter extends AbstractFilter
/** @var string */
protected
$label
=
"View types"
;
/** @var string */
protected
$description
=
"Filter by the breakdown of views"
;
public
function
__construct
()
{
$this
->
options
=
(
new
FilterOptions
())
->
setOptions
(
(
new
FilterOptionsOption
())
->
setId
(
"total"
)
->
setLabel
(
"Total"
),
->
setLabel
(
"Total"
)
->
setDescription
(
"All views recorded on assets"
),
(
new
FilterOptionsOption
())
->
setId
(
"organic"
)
->
setLabel
(
"Organic"
),
->
setLabel
(
"Organic"
)
->
setDescription
(
"Views on assets that excludes boosted impressions"
),
(
new
FilterOptionsOption
())
->
setId
(
"boosted"
)
->
setLabel
(
"Boosted"
),
->
setLabel
(
"Boosted"
)
->
setDescription
(
"Views recorded on assets that were boosted"
),
(
new
FilterOptionsOption
())
->
setId
(
"single"
)
->
setLabel
(
"Single"
)
->
setDecription
(
"Views recorded on single pages, not in feeds"
)
);
}
}
This diff is collapsed.
Click to expand it.
Core/Analytics/Dashboards/Metrics/AbstractMetric.php
View file @
d66a1ef5
...
...
@@ -22,6 +22,12 @@ abstract class AbstractMetric
/** @var string */
protected
$label
;
/** @var string */
protected
$description
;
/** @var string */
protected
$unit
=
'number'
;
/** @var string[] */
protected
$permissions
;
...
...
@@ -47,6 +53,8 @@ abstract class AbstractMetric
return
[
'id'
=>
(
string
)
$this
->
id
,
'label'
=>
(
string
)
$this
->
label
,
'description'
=>
(
string
)
$this
->
description
,
'unit'
=>
(
string
)
$this
->
unit
,
'permissions'
=>
(
array
)
$this
->
permissions
,
'summary'
=>
$this
->
summary
?
(
array
)
$this
->
summary
->
export
()
:
null
,
'visualisation'
=>
$this
->
visualisation
?
(
array
)
$this
->
visualisation
->
export
()
:
null
,
...
...
This diff is collapsed.
Click to expand it.
Core/Analytics/Dashboards/Metrics/ActiveUsersMetric.php
View file @
d66a1ef5
...
...
@@ -13,7 +13,10 @@ class ActiveUsersMetric extends AbstractMetric
protected
$id
=
'active_users'
;
/** @var string */
protected
$label
=
'active users'
;
protected
$label
=
'Active Users'
;
/** @var string */
protected
$description
=
'Users who make at least one single request to Minds'
;
/** @var array */
protected
$permissions
=
[
'admin'
];
...
...
This diff is collapsed.
Click to expand it.
Core/Analytics/Dashboards/Metrics/SignupsMetric.php
View file @
d66a1ef5
...
...
@@ -13,7 +13,10 @@ class SignupsMetric extends AbstractMetric
protected
$id
=
'signups'
;
/** @var string */
protected
$label
=
'signups'
;
protected
$label
=
'Signups'
;
/** @var string */
protected
$description
=
'New accounts registered'
;
/** @var array */
protected
$permissions
=
[
'admin'
];
...
...
This diff is collapsed.
Click to expand it.
Core/Analytics/Dashboards/Metrics/ViewsMetric.php
View file @
d66a1ef5
...
...
@@ -2,6 +2,7 @@
namespace
Minds\Core\Analytics\Dashboards\Metrics
;
use
Minds\Core\Di\Di
;
use
Minds\Core\Session
;
use
Minds\Core\Data\Elasticsearch
;
class
ViewsMetric
extends
AbstractMetric
...
...
@@ -13,7 +14,10 @@ class ViewsMetric extends AbstractMetric
protected
$id
=
'views'
;
/** @var string */
protected
$label
=
'views'
;
protected
$label
=
'Views'
;
/** @var string */
protected
$description
=
'Views on channel assets'
;
/** @var array */
protected
$permissions
=
[
'admin'
];
...
...
@@ -59,6 +63,14 @@ class ViewsMetric extends AbstractMetric
],
];
if
(
$userGuid
=
$this
->
getUserGuid
())
{
$must
[]
=
[
'term'
=>
[
'owner_guid'
=>
$userGuid
,
],
];
}
$query
=
[
'index'
=>
'minds-entitycentric-*'
,
'size'
=>
0
,
...
...
@@ -128,6 +140,14 @@ class ViewsMetric extends AbstractMetric
],
];
if
(
$userGuid
=
$this
->
getUserGuid
())
{
$must
[]
=
[
'term'
=>
[
'owner_guid'
=>
$userGuid
,
],
];
}
// Do the query
$query
=
[
'index'
=>
'minds-entitycentric-*'
,
...
...
@@ -183,4 +203,24 @@ class ViewsMetric extends AbstractMetric
return
$this
;
}
private
function
getUserGuid
()
:
?
string
{
$filters
=
$this
->
filtersCollection
->
getSelected
();
$channelFilter
=
$filters
[
'channel'
];
if
(
!
$channelFilter
)
{
return
""
;
}
if
(
$channelFilter
->
getSelectedOption
()
===
'self'
)
{
return
Session
::
getLoggedInUserGuid
();
}
if
(
$channelFilter
->
getSelectedOption
()
===
'all'
)
{
return
""
;
}
// TODO: check permissions first
return
$channelFilter
->
getSelectedOption
();
}
}
This diff is collapsed.
Click to expand it.
Core/Analytics/Dashboards/Metrics/Visualisations/ChartVisualisation.php
View file @
d66a1ef5
...
...
@@ -36,7 +36,11 @@ class ChartVisualisation extends AbstractVisualisation
{
return
[
'type'
=>
$this
->
type
,
'buckets'
=>
(
array
)
$this
->
buckets
,
'segments'
=>
[
[
'buckets'
=>
(
array
)
$this
->
buckets
,
],
]
];
}
}
This diff is collapsed.
Click to expand it.
Core/Analytics/Dashboards/TrafficDashboard.php
View file @
d66a1ef5
...
...
@@ -64,7 +64,8 @@ class TrafficDashboard implements DashboardInterface
->
setSelectedIds
(
$this
->
filterIds
)
->
addFilters
(
new
Filters\PlatformFilter
(),
new
Filters\ViewTypeFilter
()
new
Filters\ViewTypeFilter
(),
new
Filters\ChannelFilter
()
);
$this
->
metricsCollection
->
setTimespansCollection
(
$this
->
timespansCollection
)
...
...
@@ -92,7 +93,7 @@ class TrafficDashboard implements DashboardInterface
'category'
=>
'traffic'
,
'timespan'
=>
$this
->
timespansCollection
->
getSelected
()
->
getId
(),
'timespans'
=>
$this
->
timespansCollection
->
export
(),
'metric'
=>
$this
->
metricsCollection
->
getSelected
()
->
export
(),
'metric'
=>
$this
->
metricsCollection
->
getSelected
()
->
getId
(),
'metrics'
=>
$this
->
metricsCollection
->
export
(),
'filter'
=>
$this
->
filtersCollection
->
getSelectedIds
(),
'filters'
=>
$this
->
filtersCollection
->
export
(),
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment