-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#1193: Optimisation du stockage des avis - migration des avis existants
- Loading branch information
Showing
7 changed files
with
278 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
INSERT IGNORE INTO avis | ||
SELECT | ||
xwikiobjects.XWO_ID AS xwo_id, | ||
sessionId.XWS_VALUE AS avis_session_id, | ||
apiKey.XWS_VALUE AS avis_api_key, | ||
dem.XWS_VALUE AS avis_demarche, | ||
modalite.XWS_VALUE AS avis_modalite, | ||
score.XWI_VALUE AS avis_score, | ||
vote.XWS_VALUE AS avis_vote, | ||
voteInput.XWL_VALUE AS avis_vote_input, | ||
facile.XWI_VALUE AS avis_facile, | ||
comprehensible.XWI_VALUE AS avis_comprehensible, | ||
autreDifficulte.XWS_VALUE AS avis_autre_difficulte, | ||
autreAide.XWS_VALUE AS avis_autre_aide, | ||
autre.XWL_VALUE AS avis_autre, | ||
email.XWS_VALUE AS avis_email, | ||
src.XWS_VALUE AS avis_source, | ||
doc.XWD_CREATION_DATE AS avis_date, | ||
doc.XWD_NAME AS avis_id | ||
FROM | ||
xwoids, xwikiobjects | ||
JOIN xwikistrings AS dem ON | ||
( xwikiobjects.XWO_ID = dem.XWS_ID | ||
AND dem.XWS_NAME = 'demarche') | ||
LEFT OUTER JOIN xwikistrings AS apiKey ON | ||
( xwikiobjects.XWO_ID = apiKey.XWS_ID | ||
AND apiKey.XWS_NAME = 'apiKey') | ||
LEFT OUTER JOIN xwikistrings AS sessionId ON | ||
( xwikiobjects.XWO_ID = sessionId.XWS_ID | ||
AND sessionId.XWS_NAME = 'sessionId') | ||
LEFT OUTER JOIN xwikistrings AS modalite ON | ||
( xwikiobjects.XWO_ID = modalite.XWS_ID | ||
AND modalite.XWS_NAME = 'modalite') | ||
LEFT OUTER JOIN xwikiintegers AS score ON | ||
( xwikiobjects.XWO_ID = score.XWI_ID | ||
AND score.XWI_NAME = 'score') | ||
LEFT OUTER JOIN xwikistrings AS vote ON | ||
( xwikiobjects.XWO_ID = vote.XWS_ID | ||
AND vote.XWS_NAME = 'vote') | ||
LEFT OUTER JOIN xwikistrings AS src ON | ||
( xwikiobjects.XWO_ID = src.XWS_ID | ||
AND src.XWS_NAME = 'source') | ||
LEFT OUTER JOIN xwikilargestrings AS voteInput ON | ||
( xwikiobjects.XWO_ID = voteInput.XWL_ID | ||
AND voteInput.XWL_NAME = 'voteInput') | ||
LEFT OUTER JOIN xwikiintegers AS facile ON | ||
( xwikiobjects.XWO_ID = facile.XWI_ID | ||
AND facile.XWI_NAME = 'facile') | ||
LEFT OUTER JOIN xwikiintegers AS comprehensible ON | ||
( xwikiobjects.XWO_ID = comprehensible.XWI_ID | ||
AND comprehensible.XWI_NAME = 'comprehensible') | ||
LEFT OUTER JOIN xwikistrings AS autreDifficulte ON | ||
( xwikiobjects.XWO_ID = autreDifficulte.XWS_ID | ||
AND autreDifficulte.XWS_NAME = 'autreDifficulte') | ||
LEFT OUTER JOIN xwikistrings AS autreAide ON | ||
( xwikiobjects.XWO_ID = autreAide.XWS_ID | ||
AND autreAide.XWS_NAME = 'autreAide') | ||
LEFT OUTER JOIN xwikilargestrings AS autre ON | ||
( xwikiobjects.XWO_ID = autre.XWL_ID | ||
AND autre.XWL_NAME = 'autre') | ||
LEFT OUTER JOIN xwikistrings AS email ON | ||
( xwikiobjects.XWO_ID = email.XWS_ID | ||
AND email.XWS_NAME = 'email') | ||
LEFT OUTER JOIN xwikidoc AS doc ON | ||
( xwikiobjects.XWO_NAME = doc.XWD_FULLNAME) | ||
WHERE | ||
XWO_CLASSNAME = 'Avis.Code.AvisClass' | ||
AND xwikiobjects.XWO_ID = xwoids.XWO_ID | ||
AND xwoids.month=@MONTH; | ||
INSERT IGNORE INTO avis_difficultes | ||
SELECT | ||
difficulte.XWL_ID AS avis_id, | ||
difficulte.XWL_VALUE AS value, | ||
difficulte.XWL_NUMBER As idx | ||
FROM | ||
xwoids, | ||
xwikilistitems AS difficulte | ||
JOIN xwikistrings AS dem ON | ||
( difficulte.XWL_ID = dem.XWS_ID | ||
AND dem.XWS_NAME = 'demarche') | ||
WHERE | ||
difficulte.XWL_NAME = 'difficultes' | ||
AND difficulte.XWL_ID = xwoids.XWO_ID | ||
AND xwoids.month=@MONTH; | ||
INSERT IGNORE INTO avis_aide | ||
SELECT | ||
aide.XWL_ID AS avis_id, | ||
aide.XWL_VALUE AS value, | ||
aide.XWL_NUMBER As idx | ||
FROM | ||
xwoids, | ||
xwikilistitems AS aide | ||
JOIN xwikistrings AS dem ON | ||
( aide.XWL_ID = dem.XWS_ID | ||
AND dem.XWS_NAME = 'demarche') | ||
WHERE | ||
aide.XWL_NAME = 'aide' | ||
AND aide.XWL_ID = xwoids.XWO_ID | ||
AND xwoids.month=@MONTH; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
SELECT | ||
count(*) | ||
FROM | ||
xwoids, xwikiobjects | ||
JOIN xwikistrings AS dem ON | ||
( xwikiobjects.XWO_ID = dem.XWS_ID | ||
AND dem.XWS_NAME = 'demarche') | ||
LEFT OUTER JOIN xwikistrings AS apiKey ON | ||
( xwikiobjects.XWO_ID = apiKey.XWS_ID | ||
AND apiKey.XWS_NAME = 'apiKey') | ||
LEFT OUTER JOIN xwikistrings AS sessionId ON | ||
( xwikiobjects.XWO_ID = sessionId.XWS_ID | ||
AND sessionId.XWS_NAME = 'sessionId') | ||
LEFT OUTER JOIN xwikistrings AS modalite ON | ||
( xwikiobjects.XWO_ID = modalite.XWS_ID | ||
AND modalite.XWS_NAME = 'modalite') | ||
LEFT OUTER JOIN xwikiintegers AS score ON | ||
( xwikiobjects.XWO_ID = score.XWI_ID | ||
AND score.XWI_NAME = 'score') | ||
LEFT OUTER JOIN xwikistrings AS vote ON | ||
( xwikiobjects.XWO_ID = vote.XWS_ID | ||
AND vote.XWS_NAME = 'vote') | ||
LEFT OUTER JOIN xwikistrings AS src ON | ||
( xwikiobjects.XWO_ID = src.XWS_ID | ||
AND src.XWS_NAME = 'source') | ||
LEFT OUTER JOIN xwikilargestrings AS voteInput ON | ||
( xwikiobjects.XWO_ID = voteInput.XWL_ID | ||
AND voteInput.XWL_NAME = 'voteInput') | ||
LEFT OUTER JOIN xwikiintegers AS facile ON | ||
( xwikiobjects.XWO_ID = facile.XWI_ID | ||
AND facile.XWI_NAME = 'facile') | ||
LEFT OUTER JOIN xwikiintegers AS comprehensible ON | ||
( xwikiobjects.XWO_ID = comprehensible.XWI_ID | ||
AND comprehensible.XWI_NAME = 'comprehensible') | ||
LEFT OUTER JOIN xwikistrings AS autreDifficulte ON | ||
( xwikiobjects.XWO_ID = autreDifficulte.XWS_ID | ||
AND autreDifficulte.XWS_NAME = 'autreDifficulte') | ||
LEFT OUTER JOIN xwikistrings AS autreAide ON | ||
( xwikiobjects.XWO_ID = autreAide.XWS_ID | ||
AND autreAide.XWS_NAME = 'autreAide') | ||
LEFT OUTER JOIN xwikilargestrings AS autre ON | ||
( xwikiobjects.XWO_ID = autre.XWL_ID | ||
AND autre.XWL_NAME = 'autre') | ||
LEFT OUTER JOIN xwikistrings AS email ON | ||
( xwikiobjects.XWO_ID = email.XWS_ID | ||
AND email.XWS_NAME = 'email') | ||
LEFT OUTER JOIN avis ON | ||
( | ||
avis.XWO_ID = xwikiobjects.XWO_ID | ||
) | ||
LEFT OUTER JOIN xwikidoc AS doc ON | ||
( xwikiobjects.XWO_NAME = doc.XWD_FULLNAME) | ||
WHERE | ||
xwoids.XWO_ID = xwikiobjects.XWO_ID | ||
AND (sessionId.XWS_VALUE != avis.avis_session_id OR | ||
apiKey.XWS_VALUE != avis.avis_api_key OR | ||
dem.XWS_VALUE != avis.avis_demarche OR | ||
modalite.XWS_VALUE != avis.avis_modalite OR | ||
score.XWI_VALUE != avis.avis_score OR | ||
vote.XWS_VALUE != avis.avis_vote OR | ||
voteInput.XWL_VALUE != avis.avis_vote_input OR | ||
facile.XWI_VALUE != avis.avis_facile OR | ||
comprehensible.XWI_VALUE != avis.avis_comprehensible OR | ||
autreDifficulte.XWS_VALUE != avis.avis_autre_difficulte OR | ||
autreAide.XWS_VALUE != avis.avis_autre_aide OR | ||
autre.XWL_VALUE != avis.avis_autre OR | ||
email.XWS_VALUE != avis.avis_email OR | ||
src.XWS_VALUE != avis.avis_source OR | ||
doc.xwd_creation_date != avis.avis_date OR | ||
doc.xwd_name != avis.avis_id) | ||
AND xwoids.month=@MONTH; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
CREATE TABLE `avis` ( | ||
`xwo_id` bigint(20) NOT NULL, | ||
`avis_id` varchar(255) DEFAULT NULL, | ||
`avis_date` datetime DEFAULT NULL, | ||
`avis_session_id` varchar(255) DEFAULT NULL, | ||
`avis_api_key` varchar(255) DEFAULT NULL, | ||
`avis_demarche` varchar(255) DEFAULT NULL, | ||
`avis_modalite` varchar(255) DEFAULT NULL, | ||
`avis_score` int(11) DEFAULT NULL, | ||
`avis_vote` varchar(255) DEFAULT NULL, | ||
`avis_vote_input` longtext DEFAULT NULL, | ||
`avis_facile` int(11) DEFAULT NULL, | ||
`avis_comprehensible` int(11) DEFAULT NULL, | ||
`avis_autre_difficulte` varchar(255) DEFAULT NULL, | ||
`avis_autre_aide` varchar(255) DEFAULT NULL, | ||
`avis_email` varchar(255) DEFAULT NULL, | ||
`avis_source` varchar(255) DEFAULT NULL, | ||
`avis_autre` longtext DEFAULT NULL, | ||
PRIMARY KEY (`xwo_id`), | ||
KEY `id_idx` (`avis_id`), | ||
KEY `date_idx` (`avis_date`), | ||
KEY `facile_idx` (`avis_facile`), | ||
KEY `demarche_idx` (`avis_demarche`), | ||
KEY `sessionid_idx` (`avis_session_id`), | ||
KEY `apikey_idx` (`avis_api_key`), | ||
KEY `score_idx` (`avis_score`), | ||
KEY `comprehensible_idx` (`avis_comprehensible`), | ||
KEY `source_idx` (`avis_source`), | ||
KEY `modalite_idx` (`avis_modalite`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
delete from xwikiproperties where xwp_id in | ||
(select xwo_id from xwoids xwoids.month=@MONTH); | ||
delete from xwikistrings where xws_id in | ||
(select xwo_id from xwoids xwoids.month=@MONTH); | ||
delete from xwikiintegers where xwi_id in | ||
(select xwo_id from xwoids xwoids.month=@MONTH); | ||
delete from xwikilists where xwl_id in | ||
(select xwo_id from xwoids xwoids.month=@MONTH); | ||
delete from xwikilistitems where xwl_id in | ||
(select xwo_id from xwoids xwoids.month=@MONTH); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/sh | ||
LEN=0 | ||
if [ "$#" -gt 0 ]; | ||
then | ||
LEN=${#1} | ||
fi | ||
if [ "$LEN" -eq "6" ]; | ||
then | ||
PERIOD=$1 | ||
echo "Running script for $PERIOD" | ||
mysql -u root xwiki -e "set @MONTH=$PERIOD; source $(dirname "$0")/avis_migrate_bymonth.sql;" | ||
elif [ "$LEN" -eq "4" ]; | ||
then | ||
YEAR=$1 | ||
for MONTH in 01 02 03 04 05 06 07 08 09 10 11 12; do | ||
PERIOD=$YEAR$MONTH | ||
echo "Running script for $PERIOD" | ||
mysql -u root xwiki -e "set @MONTH=$PERIOD; source $(dirname "$0")/avis_migrate_bymonth.sql;" | ||
done | ||
else | ||
echo "Missing year or month parameter" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/sh | ||
LEN=0 | ||
if [ "$#" -gt 0 ]; | ||
then | ||
LEN=${#1} | ||
fi | ||
if [ "$LEN" -eq "6" ]; | ||
then | ||
PERIOD=$1 | ||
echo "Running script for $PERIOD" | ||
mysql -u root xwiki -e "set @MONTH=$PERIOD; source $(dirname "$0")/avis_migrate_check_bymonth.sql;" | ||
elif [ "$LEN" -eq "4" ]; | ||
then | ||
YEAR=$1 | ||
for MONTH in 01 02 03 04 05 06 07 08 09 10 11 12; do | ||
PERIOD=$YEAR$MONTH | ||
echo "Running script for $PERIOD" | ||
mysql -u root xwiki -e "set @MONTH=$PERIOD; source $(dirname "$0")/avis_migrate_check_bymonth.sql;" | ||
done | ||
else | ||
echo "Missing year or month parameter" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/sh | ||
LEN=0 | ||
if [ "$#" -gt 0 ]; | ||
then | ||
LEN=${#1} | ||
fi | ||
if [ "$LEN" -eq "6" ]; | ||
then | ||
PERIOD=$1 | ||
echo "Running script for $PERIOD" | ||
mysql -u root xwiki -e "set @MONTH=$PERIOD; source $(dirname "$0")/avis_migrate_delete_bymonth.sql;" | ||
elif [ "$LEN" -eq "4" ]; | ||
then | ||
YEAR=$1 | ||
for MONTH in 01 02 03 04 05 06 07 08 09 10 11 12; do | ||
PERIOD=$YEAR$MONTH | ||
echo "Running script for $PERIOD" | ||
mysql -u root xwiki -e "set @MONTH=$PERIOD; source $(dirname "$0")/avis_migrate_delete_bymonth.sql;" | ||
done | ||
else | ||
echo "Missing year or month parameter" | ||
fi |