Index: trunk/extensions/Wikidata/util/missing.php |
— | — | @@ -98,10 +98,11 @@ |
99 | 99 | # * don't count deleted stuff (old query did) |
100 | 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 | 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 | +# (+Kim) Alternately, just try the actual defining expression, which should never be NULL in the first place. |
102 | 103 | # 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 |
103 | 104 | |
104 | 105 | $result = mysql_query(" |
105 | | - SELECT member.id, translation_en.spelling_en |
| 106 | + SELECT member.id, translation_dm.spelling_dm |
106 | 107 | FROM |
107 | 108 | ( |
108 | 109 | SELECT member_mid as id |
— | — | @@ -128,37 +129,57 @@ |
129 | 130 | translation.defined_meaning_id = member.id |
130 | 131 | LEFT JOIN |
131 | 132 | ( |
132 | | - SELECT spelling as spelling_en, defined_meaning_id |
133 | | - FROM uw_syntrans, uw_expression_ns WHERE |
134 | | - uw_expression_ns.expression_id = uw_syntrans.expression_id |
135 | | - AND uw_syntrans.remove_transaction_id IS NULL |
136 | | - AND language_id = 85 |
137 | | - AND defined_meaning_id IN |
138 | | - ( |
139 | | - SELECT member_mid as id |
140 | | - FROM uw_collection_contents WHERE |
141 | | - collection_id = $collection_esc |
142 | | - AND remove_transaction_id IS NULL |
143 | | - ) |
144 | | - ) as translation_en |
| 133 | + SELECT COALESCE(translation_en.spelling_en, translation_dm1.spelling_dm ) as spelling_dm, translation_dm1.defined_meaning_id as defined_meaning_id |
| 134 | + FROM |
| 135 | + ( |
| 136 | + SELECT spelling as spelling_dm, defined_meaning_id |
| 137 | + FROM uw_defined_meaning, uw_expression_ns WHERE |
| 138 | + uw_expression_ns.expression_id = uw_defined_meaning.expression_id |
| 139 | + AND uw_defined_meaning.remove_transaction_id IS NULL |
| 140 | + AND uw_expression_ns.remove_transaction_id IS NULL |
| 141 | + AND defined_meaning_id IN |
| 142 | + ( |
| 143 | + SELECT member_mid as id |
| 144 | + FROM uw_collection_contents WHERE |
| 145 | + collection_id = $collection_esc |
| 146 | + AND remove_transaction_id IS NULL |
| 147 | + ) |
| 148 | + ) as translation_dm1 |
| 149 | + LEFT JOIN |
| 150 | + ( |
| 151 | + SELECT spelling as spelling_en, defined_meaning_id |
| 152 | + FROM uw_syntrans, uw_expression_ns WHERE |
| 153 | + uw_expression_ns.expression_id = uw_syntrans.expression_id |
| 154 | + AND uw_syntrans.remove_transaction_id IS NULL |
| 155 | + AND language_id = 85 |
| 156 | + AND defined_meaning_id IN |
| 157 | + ( |
| 158 | + SELECT member_mid as id |
| 159 | + FROM uw_collection_contents WHERE |
| 160 | + collection_id = $collection_esc |
| 161 | + AND remove_transaction_id IS NULL |
| 162 | + ) |
| 163 | + ) as translation_en |
| 164 | + ON translation_dm1.defined_meaning_id=translation_en.defined_meaning_id |
| 165 | + ) as translation_dm |
145 | 166 | ON |
146 | | - translation_en.defined_meaning_id = member.id |
| 167 | + translation_dm.defined_meaning_id = member.id |
147 | 168 | WHERE translation.spelling IS NULL |
148 | | - ORDER BY spelling_en |
| 169 | + ORDER BY spelling_dm |
149 | 170 | ")or die ("error ".mysql_error()); |
150 | 171 | |
151 | 172 | |
152 | 173 | while ($row = mysql_fetch_array($result, MYSQL_NUM)) { |
153 | 174 | $id=$row[0]; |
154 | | - $spelling_en=$row[1]; |
| 175 | + $spelling_dm=$row[1]; |
155 | 176 | |
156 | 177 | # Malafaya: Not translated to target language |
157 | | - if ($spelling_en == null) |
| 178 | + if ($spelling_dm == null) |
158 | 179 | # Malafaya: Not translated to English either; use a placeholder expression |
159 | 180 | print "<a href=\"../../../index.php?title=DefinedMeaning:(untranslated)_($id)\">(untranslated)</a>;\n"; |
160 | 181 | else |
161 | 182 | # Malafaya: English translation exists; use it |
162 | | - print "<a href=\"../../../index.php?title=DefinedMeaning:".$spelling_en."_($id)\">$spelling_en</a>;\n"; |
| 183 | + print "<a href=\"../../../index.php?title=DefinedMeaning:".$spelling_dm."_($id)\">$spelling_dm</a>;\n"; |
163 | 184 | } |
164 | 185 | print "<br>\n"; |
165 | 186 | |