Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
A
addcpm-json
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Александр Чаплыгин
addcpm-json
Commits
869f80ec
Commit
869f80ec
authored
Jan 17, 2019
by
Александр Чаплыгин
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Завел статистику по запрсам API
parent
f1e25e72
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
52 additions
and
66 deletions
+52
-66
feeds.global.php
src/config/autoload/feeds.global.php
+5
-0
script-feeds-stat-charts.js
src/public/js/script-feeds-stat-charts.js
+8
-4
script-feeds-stat.js
src/public/js/script-feeds-stat.js
+8
-4
Cabinet.php
src/src/App/Action/User/Cabinet.php
+29
-56
Statistics.php
src/src/App/Model/Statistics.php
+0
-0
cabinet-feed.phtml
src/templates/app/user/cabinet-feed.phtml
+2
-2
No files found.
src/config/autoload/feeds.global.php
View file @
869f80ec
...
@@ -18,6 +18,11 @@ return [
...
@@ -18,6 +18,11 @@ return [
'transactions'
=>
'#1F77B4'
,
'transactions'
=>
'#1F77B4'
,
'salemoney'
=>
'#FF7F0E'
,
'salemoney'
=>
'#FF7F0E'
,
'admoney'
=>
'#9467BD'
,
'admoney'
=>
'#9467BD'
,
'Views'
=>
'#2CA02C'
,
'Clicks'
=>
'#D62728'
,
'Orders'
=>
'#1F77B4'
,
'OrderSum'
=>
'#FF7F0E'
,
'AdMoney'
=>
'#9467BD'
,
]
]
]
]
];
];
src/public/js/script-feeds-stat-charts.js
View file @
869f80ec
...
@@ -7,6 +7,7 @@ $(document).ready(function(){
...
@@ -7,6 +7,7 @@ $(document).ready(function(){
//selectorActiveDays = '.b-filter__switch.days .m-filter__switch-item_active',
//selectorActiveDays = '.b-filter__switch.days .m-filter__switch-item_active',
//selectorActiveData = '.b-filter__switch.metric-data .m-filter__switch-item_active',
//selectorActiveData = '.b-filter__switch.metric-data .m-filter__switch-item_active',
activeLine
=
$
(
selectorActiveLine
).
data
(
'filter-category'
),
activeLine
=
$
(
selectorActiveLine
).
data
(
'filter-category'
),
activeLines
,
//activeTime,
//activeTime,
activeDays
,
activeDays
,
toggelDates
=
[],
toggelDates
=
[],
...
@@ -92,11 +93,14 @@ $(document).ready(function(){
...
@@ -92,11 +93,14 @@ $(document).ready(function(){
$
.
extend
({
$
.
extend
({
ChartStat
:
{
ChartStat
:
{
DateStat
:
function
(
dataLineChartStat
)
{
DateStat
:
function
(
dataLineChartStat
)
{
console
.
log
(
'AAA DateStat: '
,
dataLineChartStat
);
var
activeLines
=
[
'shows'
,
'clicks'
,
'transactions'
,
'salemoney'
,
'admoney'
];
//activeLines = ['shows', 'clicks', 'transactions', 'salemoney', 'admoney'];
activeLine
=
'shows'
;
//activeLine = 'shows';
if
(
dataLineChartStat
.
report
==
'common'
)
{
//console.log('AAA DateStat: ', dataLineChartStat);
activeLines
=
[
'Views'
,
'Clicks'
,
'Orders'
,
'OrderSum'
,
'AdMoney'
];
activeLine
=
'Views'
;
}
// Диапазон дат:
// Диапазон дат:
if
(
dataLineChartStat
.
type
==
'interval'
)
{
if
(
dataLineChartStat
.
type
==
'interval'
)
{
...
...
src/public/js/script-feeds-stat.js
View file @
869f80ec
...
@@ -47,7 +47,7 @@ $(document).ready(function(){
...
@@ -47,7 +47,7 @@ $(document).ready(function(){
$chartStatError
=
$
(
'.chart-graph-stat-error'
),
$chartStatError
=
$
(
'.chart-graph-stat-error'
),
$chartStatErrorMessage
=
$
(
'.chart-graph-stat-error .message'
),
$chartStatErrorMessage
=
$
(
'.chart-graph-stat-error .message'
),
periodStatsData
,
periodStatsData
,
campaignStatsData
,
//
campaignStatsData,
dataLineChartStat
;
dataLineChartStat
;
...
@@ -61,9 +61,11 @@ $(document).ready(function(){
...
@@ -61,9 +61,11 @@ $(document).ready(function(){
if
(
$
(
'#period-stats'
).
val
())
{
if
(
$
(
'#period-stats'
).
val
())
{
periodStatsData
=
JSON
.
parse
(
$
(
'#period-stats'
).
val
());
periodStatsData
=
JSON
.
parse
(
$
(
'#period-stats'
).
val
());
}
}
/*
if ($('#campaign-stats').val()) {
if ($('#campaign-stats').val()) {
campaignStatsData = JSON.parse($('#campaign-stats').val());
campaignStatsData = JSON.parse($('#campaign-stats').val());
}
}
*/
// Устанавливаем данные по периоду в качестве стартовых:
// Устанавливаем данные по периоду в качестве стартовых:
dataLineChartStat
=
periodStatsData
;
dataLineChartStat
=
periodStatsData
;
//console.log('AAA dataLineChartStat = ', dataLineChartStat);
//console.log('AAA dataLineChartStat = ', dataLineChartStat);
...
@@ -143,7 +145,8 @@ $(document).ready(function(){
...
@@ -143,7 +145,8 @@ $(document).ready(function(){
$this
.
addClass
(
'selected'
).
toggleClass
(
'desc'
);
$this
.
addClass
(
'selected'
).
toggleClass
(
'desc'
);
if
(
$this
.
hasClass
(
'main-cat'
))
{
if
(
$this
.
hasClass
(
'main-cat'
))
{
dataLineChartStat
=
(
$this
.
hasClass
(
'date'
))
?
periodStatsData
:
campaignStatsData
;
//dataLineChartStat = ($this.hasClass('date')) ? periodStatsData : campaignStatsData;
dataLineChartStat
=
periodStatsData
;
$tableHeadColsChecks
.
attr
(
"disabled"
,
$this
.
hasClass
(
'campaign'
));
$tableHeadColsChecks
.
attr
(
"disabled"
,
$this
.
hasClass
(
'campaign'
));
}
}
renderHourTable
();
renderHourTable
();
...
@@ -197,8 +200,9 @@ $(document).ready(function(){
...
@@ -197,8 +200,9 @@ $(document).ready(function(){
//console.log("AAA requestDataStat SUCCESS res: ", res);
//console.log("AAA requestDataStat SUCCESS res: ", res);
ShowChartData
();
ShowChartData
();
periodStatsData
=
res
.
period
;
//periodStatsData = res.period;
campaignStatsData
=
res
.
campaign
;
//campaignStatsData = res.campaign;
periodStatsData
=
res
;
dataLineChartStat
=
periodStatsData
;
dataLineChartStat
=
periodStatsData
;
$
(
'.main-cat'
).
removeClass
(
'selected'
);
$
(
'.main-cat'
).
removeClass
(
'selected'
);
$
(
'.main-cat.date'
).
addClass
(
'selected'
);
$
(
'.main-cat.date'
).
addClass
(
'selected'
);
...
...
src/src/App/Action/User/Cabinet.php
View file @
869f80ec
...
@@ -109,12 +109,20 @@ class Cabinet extends Common
...
@@ -109,12 +109,20 @@ class Cabinet extends Common
switch
(
$report_type
)
{
switch
(
$report_type
)
{
case
'common'
:
case
'common'
:
/** @var \App\Model\Feeds $statDaysModel */
/** @var \App\Model\Feeds $statDaysModel */
$statsDaysModel
=
$this
->
container
->
get
(
StatsDays
::
class
);
//
$statsDaysModel = $this->container->get(StatsDays::class);
//$stats = $statsDaysModel->findAll(['FeedID' => $feed_id_list])->toArray();
//$stats = $statsDaysModel->findAll(['FeedID' => $feed_id_list])->toArray();
$periodStats
=
$statsDaysModel
->
getStatsByDate
(
$feed_id_list
,
$dates
);
//$periodStats = $statsDaysModel->getStatsByDate($feed_id_list, $dates);
$stat
=
$stats
->
getStatData
(
$metric
,
$type
);
$periodStats
=
$stats
->
getStatData
(
$report_type
,
$feed_id_list
,
$dates
);
//$campaignStats = $statsDaysModel->getStatsByFeeds($feed_id_list, $dates);
$cats
=
[
'Views'
=>
'Показы'
,
'Clicks'
=>
'Клики'
,
'Orders'
=>
'Заказы'
,
'OrderSum'
=>
'Сумма по заказам'
,
'AdMoney'
=>
'Стоимость заказа'
];
/*
$cats = [
$cats = [
'shows' => 'Показы',
'shows' => 'Показы',
'clicks' => 'Клики',
'clicks' => 'Клики',
...
@@ -123,7 +131,7 @@ class Cabinet extends Common
...
@@ -123,7 +131,7 @@ class Cabinet extends Common
'admoney' => 'admoney'
'admoney' => 'admoney'
];
];
/*
$campaignStats = $statsDaysModel->getStatsByFeeds($feed_id_list, $dates);
if ($campaignStats || count($campaignStats['period'])>0) {
if ($campaignStats || count($campaignStats['period'])>0) {
$feeds_names = [];
$feeds_names = [];
foreach($campaignStats['period'] as $feed_id) {
foreach($campaignStats['period'] as $feed_id) {
...
@@ -159,21 +167,20 @@ class Cabinet extends Common
...
@@ -159,21 +167,20 @@ class Cabinet extends Common
break
;
break
;
}
}
//return new JsonResponse($companyStats);
/*
$periodStats['type'] = 'interval';
$periodStats['type'] = 'interval';
$periodStats['report'] = $report_type;
$periodStats['report'] = $report_type;
$campaignStats['type'] = 'interval';
$campaignStats['type'] = 'interval';
$campaignStats['report'] = $report_type;
$campaignStats['report'] = $report_type;
$data['campaignStats'] = $campaignStats;
*/
$data
[
'feeds'
]
=
$feeds
;
$data
[
'feeds'
]
=
$feeds
;
$data
[
'report'
]
=
$report_type
;
$data
[
'report'
]
=
$report_type
;
$data
[
'current_period'
]
=
$current_period
;
$data
[
'current_period'
]
=
$current_period
;
$data
[
'dates'
]
=
$dates
;
$data
[
'dates'
]
=
$dates
;
$data
[
'stat'
]
=
$stat
;
$data
[
'periodStats'
]
=
$periodStats
;
$data
[
'periodStats'
]
=
$periodStats
;
//$data['campaignStats'] = $campaignStats;
$data
[
'cats'
]
=
$cats
;
$data
[
'cats'
]
=
$cats
;
$data
[
'periods_list'
]
=
$this
->
container
->
get
(
'config'
)[
'feed_conf'
][
'periods_list'
];
$data
[
'periods_list'
]
=
$this
->
container
->
get
(
'config'
)[
'feed_conf'
][
'periods_list'
];
$data
[
'colors_active_lines'
]
=
$this
->
container
->
get
(
'config'
)[
'feed_conf'
][
'colors_active_lines'
];
$data
[
'colors_active_lines'
]
=
$this
->
container
->
get
(
'config'
)[
'feed_conf'
][
'colors_active_lines'
];
...
@@ -187,50 +194,6 @@ class Cabinet extends Common
...
@@ -187,50 +194,6 @@ class Cabinet extends Common
return $response;
return $response;
*/
*/
/*
$allDomains = $listDomains;
$subdomains = true;
$allStat = false;
$group = false;
$summaryReport = $stats->getSummuryReport($allDomains, $user->getCurrencyCode(), $subdomains, $allStat, $group);
list($periodStats, $periodDates) = $stats->getPeriodReport(date('Y-m'), $allDomains, $user->getCurrencyCode(), $subdomains, $allStat, $group);
$dateIterval = new \DateInterval('P1M');
$dateStart = \DateTime::createFromFormat('Y-m-d', $periodDates['min'] ?: date('Y-m-01'));
$dateEnd = \DateTime::createFromFormat('Y-m-d', $periodDates['max'] ?: date('Y-m-01'));
$dateRange = array();
if($dateStart != $dateEnd) {
$_dateRange = new \DatePeriod($dateStart, $dateIterval, $dateEnd);
foreach($_dateRange as $dt) {
$dateRange[] = $dt;
}
}
$dateRange[] = $dateEnd;
$dateRange = array_reverse($dateRange);
$currencyModel = $this->container->get(\App\Model\Currencies::class);
$currencies = array();
foreach($currencyModel->findAll() as $currency) {
$currencies[$currency->getCode()] = $currency->getName();
}
$currentCurencyCode = $user->getCurrencyCode();
$data['sites'] = $listSites;
$data['accessSites'] = $listAccessSites;
$data['summaryStats'] = $summaryStats;
$data['periodStats'] = $periodStats;
$data['summaryReport'] = $summaryReport;
$data['listDomains'] = $listDomains;
$data['dateRange'] = $dateRange;
$data['currencies'] = $currencies;
$data['currency'] = ['code' => $currentCurencyCode, 'name' => $currencies[$currentCurencyCode]];
$data['userId'] = $userId;
*/
}
catch
(
\Exception
$e
)
{
}
catch
(
\Exception
$e
)
{
$data
[
'error'
]
=
_t
(
'Извините, статистика временно не работает'
);
$data
[
'error'
]
=
_t
(
'Извините, статистика временно не работает'
);
}
}
...
@@ -251,6 +214,9 @@ class Cabinet extends Common
...
@@ -251,6 +214,9 @@ class Cabinet extends Common
$auth
=
$this
->
container
->
get
(
UserService
::
class
);
$auth
=
$this
->
container
->
get
(
UserService
::
class
);
$userId
=
$auth
->
getIdentity
()
->
getId
();
$userId
=
$auth
->
getIdentity
()
->
getId
();
/** @var \App\Model\Statistics $stats */
$stats
=
$this
->
container
->
get
(
Statistics
::
class
);
// Выводим стр. по фидам, если за пользователем закреплен фид:
// Выводим стр. по фидам, если за пользователем закреплен фид:
/** @var \App\Model\Feeds $feedsModel */
/** @var \App\Model\Feeds $feedsModel */
$feedsModel
=
$this
->
container
->
get
(
Feeds
::
class
);
$feedsModel
=
$this
->
container
->
get
(
Feeds
::
class
);
...
@@ -272,8 +238,10 @@ class Cabinet extends Common
...
@@ -272,8 +238,10 @@ class Cabinet extends Common
switch
(
$report_type
)
{
switch
(
$report_type
)
{
case
'common'
:
case
'common'
:
/** @var \App\Model\Feeds $statDaysModel */
/** @var \App\Model\Feeds $statDaysModel */
$statsDaysModel
=
$this
->
container
->
get
(
StatsDays
::
class
);
//$statsDaysModel = $this->container->get(StatsDays::class);
$periodStats
=
$statsDaysModel
->
getStatsByDate
(
$feed_id_list
,
$dates
);
//$periodStats = $statsDaysModel->getStatsByDate($feed_id_list, $dates);
$periodStats
=
$stats
->
getStatData
(
$report_type
,
$feed_id_list
,
$dates
);
/*
$campaignStats = $statsDaysModel->getStatsByFeeds($feed_id_list, $dates);
$campaignStats = $statsDaysModel->getStatsByFeeds($feed_id_list, $dates);
if ($campaignStats || count($campaignStats['period'])>0) {
if ($campaignStats || count($campaignStats['period'])>0) {
...
@@ -284,7 +252,7 @@ class Cabinet extends Common
...
@@ -284,7 +252,7 @@ class Cabinet extends Common
}
}
$campaignStats['period'] = $feeds_names;
$campaignStats['period'] = $feeds_names;
}
}
*/
break
;
break
;
case
'transaction'
:
case
'transaction'
:
/** @var \App\Model\Feeds $transactionsModel */
/** @var \App\Model\Feeds $transactionsModel */
...
@@ -311,6 +279,7 @@ class Cabinet extends Common
...
@@ -311,6 +279,7 @@ class Cabinet extends Common
return
new
JsonResponse
(
null
);
return
new
JsonResponse
(
null
);
}
}
/*
$periodStats['type'] = 'interval';
$periodStats['type'] = 'interval';
$periodStats['report'] = $report_type;
$periodStats['report'] = $report_type;
...
@@ -325,6 +294,10 @@ class Cabinet extends Common
...
@@ -325,6 +294,10 @@ class Cabinet extends Common
} else {
} else {
$data = null;
$data = null;
}
}
*/
$data
=
$periodStats
;
return
new
JsonResponse
(
$data
);
return
new
JsonResponse
(
$data
);
}
}
...
...
src/src/App/Model/Statistics.php
View file @
869f80ec
This diff is collapsed.
Click to expand it.
src/templates/app/user/cabinet-feed.phtml
View file @
869f80ec
...
@@ -55,7 +55,7 @@ $src = $sxml['src'];
...
@@ -55,7 +55,7 @@ $src = $sxml['src'];
$error
=
$this
->
error
;
$error
=
$this
->
error
;
$periodStats
=
$this
->
periodStats
;
$periodStats
=
$this
->
periodStats
;
$campaignStats
=
$this
->
campaignStats
;
//
$campaignStats = $this->campaignStats;
$current_period
=
$this
->
current_period
;
$current_period
=
$this
->
current_period
;
$dates
=
$this
->
dates
;
$dates
=
$this
->
dates
;
$cats
=
$this
->
cats
;
$cats
=
$this
->
cats
;
...
@@ -152,7 +152,7 @@ $system_link = $this->url('adm.system.actions');
...
@@ -152,7 +152,7 @@ $system_link = $this->url('adm.system.actions');
<div
id=
"chart-graph-stat"
style=
"height: 370px;"
data-colors=
<?=
(
$colors_active_lines
?
json_encode
(
$colors_active_lines
)
:
''
)
?>
>
</div
>
<div
id=
"chart-graph-stat"
style=
"height: 370px;"
data-colors=
<?=
(
$colors_active_lines
?
json_encode
(
$colors_active_lines
)
:
''
)
?>
>
</div
>
<?php
endif
?>
<?php
endif
?>
<?php
print_r
(
$stat
);
?>
<?php
// print_r($periodStats
); ?>
<?
php
/* Таблица */
?>
<?
php
/* Таблица */
?>
<div
id=
"table-stat"
class=
"b-table_wrapp"
>
<div
id=
"table-stat"
class=
"b-table_wrapp"
>
...
...
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