Skip to content
GitLab
Explorer
Connexion
S'inscrire
Navigation principale
Rechercher ou aller à…
Projet
S
stats-facil
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Déploiement
Releases
Registre de paquets
Registre de conteneur
Registre de modèles
Opération
Environnements
Modules Terraform
Surveillance
Incidents
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse CI/CD
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
facil
stats-facil
Validations
233c20b2
Valider
233c20b2
rédigé
il y a 9 ans
par
Thomas Steur
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
only ignore join when it was given with exact same match
parent
7fbea546
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
2
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
2 fichiers modifiés
core/DataAccess/LogQueryBuilder.php
+21
-0
21 ajouts, 0 suppression
core/DataAccess/LogQueryBuilder.php
tests/PHPUnit/Integration/SegmentTest.php
+47
-0
47 ajouts, 0 suppression
tests/PHPUnit/Integration/SegmentTest.php
avec
68 ajouts
et
0 suppression
core/DataAccess/LogQueryBuilder.php
+
21
−
0
Voir le fichier @
233c20b2
...
...
@@ -45,6 +45,21 @@ class LogQueryBuilder
}
private
function
hasJoinedTableAlreadyManually
(
$tableToFind
,
$joinToFind
,
$tables
)
{
foreach
(
$tables
as
$index
=>
$table
)
{
if
(
is_array
(
$table
)
&&
!
empty
(
$table
[
'table'
])
&&
$table
[
'table'
]
===
$tableToFind
&&
(
!
isset
(
$table
[
'tableAlias'
])
||
$table
[
'tableAlias'
]
===
$tableToFind
)
&&
isset
(
$table
[
'joinOn'
])
&&
$table
[
'joinOn'
]
===
$joinToFind
)
{
return
true
;
}
}
return
false
;
}
/**
* Generate the join sql based on the needed tables
* @param array $tables tables to join
...
...
@@ -113,6 +128,12 @@ class LogQueryBuilder
if
(
$linkVisitActionsTableAvailable
&&
$table
===
'log_action'
)
{
$join
=
"log_link_visit_action.idaction_url = log_action.idaction"
;
if
(
$this
->
hasJoinedTableAlreadyManually
(
$table
,
$join
,
$tables
))
{
$actionsTableAvailable
=
true
;
continue
;
}
}
elseif
(
$linkVisitActionsTableAvailable
&&
$table
==
"log_conversion"
)
{
// have actions, need conversions => join on idvisit
$join
=
"log_conversion.idvisit = log_link_visit_action.idvisit"
;
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
tests/PHPUnit/Integration/SegmentTest.php
+
47
−
0
Voir le fichier @
233c20b2
...
...
@@ -371,6 +371,53 @@ class SegmentTest extends IntegrationTestCase
$this
->
assertEquals
(
$this
->
removeExtraWhiteSpaces
(
$expected
),
$this
->
removeExtraWhiteSpaces
(
$query
));
}
public
function
test_getSelectQuery_whenJoinLogLinkVisitActionOnActionOnVisit_WithSameTableAlias
()
{
$actionType
=
3
;
$idSite
=
1
;
$select
=
'log_link_visit_action.custom_dimension_1,
log_action.name as url,
sum(log_link_visit_action.time_spent) as `13`,
sum(case log_visit.visit_total_actions when 1 then 1 when 0 then 1 else 0 end) as `6`'
;
$from
=
array
(
'log_link_visit_action'
,
array
(
'table'
=>
'log_visit'
,
'joinOn'
=>
'log_visit.idvisit = log_link_visit_action.idvisit'
),
array
(
'table'
=>
'log_action'
,
'joinOn'
=>
'log_link_visit_action.idaction_url = log_action.idaction'
)
);
$where
=
'log_link_visit_action.server_time >= ?
AND log_link_visit_action.server_time <= ?
AND log_link_visit_action.idsite = ?'
;
$bind
=
array
(
'2015-11-30 11:00:00'
,
'2015-12-01 10:59:59'
,
$idSite
);
$segment
=
'actionType=='
.
$actionType
;
$segment
=
new
Segment
(
$segment
,
$idSites
=
array
());
$query
=
$segment
->
getSelectQuery
(
$select
,
$from
,
$where
,
$bind
);
$logVisitTable
=
Common
::
prefixTable
(
'log_visit'
);
$logActionTable
=
Common
::
prefixTable
(
'log_action'
);
$logLinkVisitActionTable
=
Common
::
prefixTable
(
'log_link_visit_action'
);
$expected
=
array
(
"sql"
=>
"
SELECT log_link_visit_action.custom_dimension_1,
log_action.name as url,
sum(log_link_visit_action.time_spent) as `13`,
sum(case log_visit.visit_total_actions when 1 then 1 when 0 then 1 else 0 end) as `6`
FROM
$logLinkVisitActionTable
AS log_link_visit_action
LEFT JOIN
$logVisitTable
AS log_visit
ON log_visit.idvisit = log_link_visit_action.idvisit
LEFT JOIN
$logActionTable
AS log_action
ON log_link_visit_action.idaction_url = log_action.idaction
WHERE ( log_link_visit_action.server_time >= ?
AND log_link_visit_action.server_time <= ?
AND log_link_visit_action.idsite = ? )
AND ( log_action.type = ? )"
,
"bind"
=>
array
(
'2015-11-30 11:00:00'
,
'2015-12-01 10:59:59'
,
$idSite
,
$actionType
));
$this
->
assertEquals
(
$this
->
removeExtraWhiteSpaces
(
$expected
),
$this
->
removeExtraWhiteSpaces
(
$query
));
}
/**
* visit is joined on action, then conversion is joined
* make sure that conversion is joined on action not visit
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter