Index: trunk/extensions/Wikidata/util/missing.php |
— | — | @@ -63,6 +63,8 @@ |
64 | 64 | |
65 | 65 | "; |
66 | 66 | |
| 67 | +# Malafaya: Here lies the old query, assuming there's always an English expression for the DM |
| 68 | +/* |
67 | 69 | $result = mysql_query(" |
68 | 70 | SELECT en.id, en.spelling |
69 | 71 | FROM |
— | — | @@ -90,18 +92,69 @@ |
91 | 93 | ON en.id=actual.id |
92 | 94 | WHERE actual.id IS NULL |
93 | 95 | ")or die ("error ".mysql_error()); |
| 96 | +*/ |
94 | 97 | |
| 98 | +# Malafaya: This is my query (performance must be checked live) for missing expressions based on |
| 99 | +# * don't count deleted stuff (old query did) |
| 100 | +# * do 2 joins: between members of collection and target language, and then with english for default, but only for elements having target language expression as NULL (non-existing) |
| 101 | +# * this gives us the DM id, the spelling in target language (or NULL, if none), the spelling in English (or NULL, if none) |
| 102 | +# Warning: some DMs came up in OLPC and Swadesh collections belonging to those collections but having no expressions associated... These are visible in this query |
95 | 103 | |
| 104 | +$result = mysql_query(" |
| 105 | + SELECT member.id, translation_en.spelling_en |
| 106 | + FROM |
| 107 | + ( |
| 108 | + SELECT member_mid as id |
| 109 | + FROM uw_collection_contents WHERE |
| 110 | + collection_id = $collection_esc |
| 111 | + AND remove_transaction_id IS NULL |
| 112 | + ) as member |
| 113 | + LEFT JOIN |
| 114 | + ( |
| 115 | + SELECT spelling, defined_meaning_id |
| 116 | + FROM uw_syntrans, uw_expression_ns WHERE |
| 117 | + uw_expression_ns.expression_id = uw_syntrans.expression_id |
| 118 | + AND uw_syntrans.remove_transaction_id IS NULL |
| 119 | + AND language_id = $language_esc |
| 120 | + ) as translation |
| 121 | + ON |
| 122 | + translation.defined_meaning_id = member.id |
| 123 | + LEFT JOIN |
| 124 | + ( |
| 125 | + SELECT spelling as spelling_en, defined_meaning_id |
| 126 | + FROM uw_syntrans, uw_expression_ns WHERE |
| 127 | + uw_expression_ns.expression_id = uw_syntrans.expression_id |
| 128 | + AND uw_syntrans.remove_transaction_id IS NULL |
| 129 | + AND language_id = 85 |
| 130 | + ) as translation_en |
| 131 | + ON |
| 132 | + translation_en.defined_meaning_id = member.id |
| 133 | + WHERE translation.spelling IS NULL |
| 134 | + ORDER BY spelling_en |
| 135 | +")or die ("error ".mysql_error()); |
96 | 136 | |
| 137 | + |
97 | 138 | while ($row = mysql_fetch_array($result, MYSQL_NUM)) { |
98 | 139 | $id=$row[0]; |
99 | | - $spelling=$row[1]; |
100 | | - print "<a href=\"../../../index.php?title=DefinedMeaning:".$spelling."_($id)\">$spelling</a>;\n"; |
| 140 | + $spelling_en=$row[1]; |
| 141 | + |
| 142 | + # Malafaya: Not translated to target language |
| 143 | + if ($spelling_en == null) |
| 144 | + # Malafaya: Not translated to English either; use a placeholder expression |
| 145 | + print "<a href=\"../../../index.php?title=DefinedMeaning:(untranslated)_($id)\">(untranslated)</a>;\n"; |
| 146 | + else |
| 147 | + # Malafaya: English translation exists; use it |
| 148 | + print "<a href=\"../../../index.php?title=DefinedMeaning:".$spelling_en."_($id)\">$spelling_en</a>;\n"; |
101 | 149 | } |
102 | 150 | print "<br>\n"; |
103 | 151 | |
| 152 | + |
104 | 153 | print "<hr>\n |
105 | 154 | <h3>Already present</h3>\n"; |
| 155 | + |
| 156 | +# Malafaya: Old query with same caveats as the one above |
| 157 | + |
| 158 | +/* |
106 | 159 | $result = mysql_query(" |
107 | 160 | SELECT actual.id, actual.spelling |
108 | 161 | FROM |
— | — | @@ -129,8 +182,27 @@ |
130 | 183 | ON en.id=actual.id |
131 | 184 | WHERE actual.id IS NOT NULL |
132 | 185 | ")or die ("error ".mysql_error()); |
| 186 | +*/ |
133 | 187 | |
| 188 | +# Malafaya: my new query, not counting deleted stuff; just select target language expression for DMs in collection (whether translated to English or not, it's not relevant) |
134 | 189 | |
| 190 | +$result = mysql_query(" |
| 191 | + SELECT defined_meaning_id, spelling |
| 192 | + FROM uw_syntrans, uw_expression_ns WHERE |
| 193 | + uw_expression_ns.expression_id = uw_syntrans.expression_id |
| 194 | + AND uw_syntrans.remove_transaction_id IS NULL |
| 195 | + AND language_id = $language_esc |
| 196 | + AND uw_syntrans.defined_meaning_id IN |
| 197 | + ( |
| 198 | + SELECT member_mid as id |
| 199 | + FROM uw_collection_contents WHERE |
| 200 | + collection_id = $collection_esc |
| 201 | + AND remove_transaction_id IS NULL |
| 202 | + ) |
| 203 | + ORDER BY spelling |
| 204 | +")or die ("error ".mysql_error()); |
| 205 | + |
| 206 | + |
135 | 207 | while ($row = mysql_fetch_array($result, MYSQL_NUM)) { |
136 | 208 | $id=$row[0]; |
137 | 209 | $spelling=$row[1]; |
— | — | @@ -153,8 +225,9 @@ |
154 | 226 | <h3> see also</h3> |
155 | 227 | <ul> |
156 | 228 | <li><a href=\"collection.php?collection=$collection_id\">Return to Number of Expressions per language in this collection</a></li> |
157 | | -<li><a href=\"stats.php\">Overview, expressions per langauge</a></li> |
| 229 | +<li><a href=\"stats.php\">Overview, expressions per language</a></li> |
158 | 230 | <li><a href=\"../../..\">return to Omegawiki proper</li></a> |
159 | 231 | </p> |
160 | 232 | " |
| 233 | + |
161 | 234 | ?> |
Index: trunk/extensions/Wikidata/util/collection.php |
— | — | @@ -77,7 +77,9 @@ |
78 | 78 | WHERE collection_id = $collection_esc |
79 | 79 | AND uw_syntrans.defined_meaning_id= uw_collection_contents.member_mid |
80 | 80 | AND uw_expression_ns.expression_id = uw_syntrans.expression_id |
| 81 | +AND uw_expression_ns.remove_transaction_id IS NULL |
81 | 82 | AND uw_syntrans.remove_transaction_id IS NULL |
| 83 | +AND uw_collection_contents.remove_transaction_id is NULL |
82 | 84 | GROUP BY language_id |
83 | 85 | ORDER BY counts DESC |
84 | 86 | ")or die ("error ".mysql_error()); |
— | — | @@ -160,6 +162,6 @@ |
161 | 163 | <h3> see also</h3> |
162 | 164 | <ul> |
163 | 165 | <li><a href="collections.php">Other collections</a></li> |
164 | | -<li><a href="stats.php">Overview, expressions per langauge</a></li> |
| 166 | +<li><a href="stats.php">Overview, expressions per language</a></li> |
165 | 167 | <li><a href="../../..">return to Omegawiki proper</li></a> |
166 | 168 | </p> |
Index: trunk/extensions/Wikidata/util/collections.php |
— | — | @@ -48,6 +48,8 @@ |
49 | 49 | SELECT uw_collection_ns.collection_id AS id ,count(*) AS total |
50 | 50 | FROM uw_collection_contents, uw_collection_ns |
51 | 51 | WHERE uw_collection_ns.collection_id=uw_collection_contents.collection_id |
| 52 | + AND uw_collection_contents.remove_transaction_id is NULL |
| 53 | + AND uw_collection_ns.remove_transaction_id is NULL |
52 | 54 | GROUP BY uw_collection_ns.collection_id |
53 | 55 | ) AS counts |
54 | 56 | ON spellings.id=counts.id |
— | — | @@ -71,6 +73,6 @@ |
72 | 74 | <p align="left"> |
73 | 75 | <h3> see also</h3> |
74 | 76 | <ul> |
75 | | -<li><a href="stats.php">Overview, expressions per langauge</a></li> |
| 77 | +<li><a href="stats.php">Overview, expressions per language</a></li> |
76 | 78 | <li><a href="../../..">return to Omegawiki proper</li></a> |
77 | 79 | </p> |
Index: trunk/extensions/Wikidata/util/stats.php |
— | — | @@ -43,11 +43,11 @@ |
44 | 44 | <hr width=950 size=1 noshade><br> |
45 | 45 | "; |
46 | 46 | |
47 | | -$expressions_r=mysql_query("SELECT COUNT(*) FROM uw_expression_ns"); |
| 47 | +$expressions_r=mysql_query("SELECT COUNT(*) FROM uw_expression_ns WHERE remove_transaction_id IS NULL"); |
48 | 48 | $expressions_a=mysql_fetch_row($expressions_r); |
49 | 49 | $expressions=$expressions_a[0]; |
50 | 50 | |
51 | | -$defined_meanings_r=mysql_query("SELECT COUNT(*) FROM uw_defined_meaning"); |
| 51 | +$defined_meanings_r=mysql_query("SELECT COUNT(*) FROM uw_defined_meaning WHERE remove_transaction_id IS NULL"); |
52 | 52 | $defined_meanings_a=mysql_fetch_row($defined_meanings_r); |
53 | 53 | $defined_meanings=$defined_meanings_a[0]; |
54 | 54 | echo"<br>\n"; |
— | — | @@ -69,7 +69,7 @@ |
70 | 70 | //////////////////////////////////////////////////////// |
71 | 71 | $result = mysql_query(" |
72 | 72 | SELECT |
73 | | -language_id, count(*) |
| 73 | +language_id, count(*) as tot |
74 | 74 | FROM uw_expression_ns |
75 | 75 | WHERE expression_id IN |
76 | 76 | ( |
— | — | @@ -77,8 +77,9 @@ |
78 | 78 | FROM uw_syntrans |
79 | 79 | WHERE remove_transaction_id IS NULL |
80 | 80 | ) |
| 81 | +AND remove_transaction_id IS NULL |
81 | 82 | group by language_id |
82 | | -order by count(*) desc |
| 83 | +order by tot desc |
83 | 84 | ")or die ("error ".mysql_error()); |
84 | 85 | |
85 | 86 | echo ' |