== Roadmap for EUPP seats module/template ==
== Project roadmap ==
Following the discussion [[Wikipedia_talk:Lua#Module calling Wikidata to list European parties' seats in various institutions|on the Lua talk page]], here is the roadmap for the template and module:
{| class="wikitable centre sortable"
!Comments
|-
| Create Template talk:SeatsEUPPs
| 1.1 Create the module "EU party seats lower upper houses" to give out the number of seats in lower/upper houses held by all the national member parties of a given European political party; the module should also give the associated composition bar
| style="text-align: center;" |✅
|
| Test cases for the module: [[Module talk:EUPP seats/testcases|main function]] and [[Module:EUPP seats/testcases composition bar|composition bars]]; and for the sandbox: [[Module:EUPP seats/sandbox/testcases|main function]] and [[Module:EUPP seats/sandbox/testcases composition bar|composition bars]]
|-
| 1.2 IntegrateRedirect module abovetalk intopages EUPPto seatsTemplate moduletalk:SeatsEUPPs
| style="text-align: center;" |✅
|
| [[Module:EUPP seats]] is now the reference
|-
| Create [[Template:EUPP seats/sandbox]] so that it uses [[Module:EUPP seats/sandbox]]
| 1.3 Ensure comments are all in the code
| style="text-align: center;" |✅
|
|-
| Create [[Template:EUPP seats/testcases]]
| 1.4 Update documentation of EUPP seats module and its two templates
| style="text-align: center;" |✅
|
| [[Template:EUPP seats]], [[Template:EUPP composition bar]]
|-
| Replace documentation for Template:SeatsEUPPs
| 2.1 Update membership of European parties' national member parties based on APPF data
| style="text-align: center;" |✅
|
|-
| Create module testcases; see mw:Multilingual Templates and Modules#Testcases
| 2.2 Make a table of lower and upper houses and their qID for each EU member state
| style="text-align: center;" |✅
|
| [https://commons.wikimedia.org/wiki/Data:Lower_and_upper_houses_of_eu_member_states.tab Lower/upper houses per MS]
|-
| Make sure that at least one (probably both) of above testcases have a test for each of the error messages
| 2.3 Find qIDs of all national member parties and update Wikimedia Commons table
| style="text-align: center;" |✅
| Done for Module:SeatsEUPPs/testcases
| [https://commons.wikimedia.org/wiki/Data:Seats_of_EU_national_parties_in_lower_and_upper_houses.tab National party seats in lower/upper houses]
|-
| Improve description text above functions seats() and seats_share() in both the live and sandbox modules
| 2.4 Update Wikidata for seats in lower/upper houses for all relevant national member parties
| style="text-align: center;" |✅
|
|-
| Review all the comments in live and sandbox modules
| 2.5 Update infoboxes of EUPPs on Wikipedia to use templates
| style="text-align: center;" |✅
|
|-
| Review all error messages in [[Module:EUPP seats/config]]
| 3.1 Create the national_party_composition_bar function (in EUPP seats module) to give out a political party's composition bar in its relevant national lower or upper house (called from national party infobox, takes "lower house" or "upper house" as argument)
| style="text-align: center;" |✅
|
| Deployed
|-
| Make separate validation function for width
| 3.2 Create a template for the above function and add documentation (to module and template)
| style="text-align: center;" |✅
|
| [[Template:EUPP national party]]
|-
| Make separate validation function for institution and party
| 3.3 Check/update the EUPP membership, country, and hex value of national parties on Wikidata
| style="text-align: center;" |✅
|
|-
| Fix issues with error messages in [[Module:EUPP seats/sandbox]]
| style="text-align: center;" |✅
|
|-
| Update documentation
| 3.4 Add option to query EP seats in national_party_composition_bar(), then update document for module and template
| style="text-align: center;" |✅
| Ready (check after sandbox is moved to main module)
|-
| Make documentation for [[Template:EUPP composition bar]]
| style="text-align: center;" |✅
| Ready
|-
| Rename all module/template pages to names "EUPP seats" and "EUPP composition bar"
| style="text-align: center;" |✅
|
|-
| Make separate validation function for percentage/reference
| 3.5 Check/update the EP seats of national parties on Wikidata
| style="text-align: center;" |❌✅
| Not needed, but might help fix issue further down
|-
| Make [[Template:EUPP composition bar]] use [[Module:EUPP seats]] instead of [[Module:EUPP seats/sandbox]]
| style="text-align: center;" |✅
|
|-
| Allow "ref=yes" alongside "yes" for references, error message for all other (same with "pc=" percentage)
| 3.6 Update national member parties' infoboxes to use the above template (including a comment with the URL of the party's page on Wikidata to make updates easier)
| style="text-align: center;" |✅
| Done as part of broader change
|-
| Allow different order to parameters 3, 4, and 5
| style="text-align: center;" |✅
| Done as part of broader change
|-
| Fix composition_bar calling "this party" from non-party page (show error but also attempts to make a composition bar)
| style="text-align: center;" |✅
|
|-
| Allow to bypass colour with special parameter
| style="text-align: center;" |✅
| Done as part of broader change
|-
| Deploy on relevant pages
| style="text-align: center;" |✅
|
|-
| Make cosmetic tweaks to code
| style="text-align: center;" |⚠️
| Still relevant? Should we care that [[Template:EUPP composition bar]] or [[Template:EUPP seats]] shows an error at the top?
|
|}
== Questions ==
== Error for two European parties ==
As I add data to the wide table, I implement the "EUPP composition bar" template on the relevant pages of European parties, by adding <code><nowiki>{{EUPP composition bar|ms-upper-house|thisparty|width=80%|percent=yes}}</nowiki></code> in the infobox (see [[European Green Party]] for instance).
Is there a way to made a testcases page for <code>ModuleEUPPs/sandbox</code> to test the impact of the proposed code?
So far, it has been very smooth. However, for the [[Party of the European Left]] and [[European People's Party]], it gives out "Lua error in Module:EUPP_seats at line 437: attempt to perform arithmetic on a string value", in both cases just for the upper house. Any ideas? I checked the data and it seems in order. [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 12:43, 4 April 2025 (UTC)
Note:Ok "for the 'share' outputs, should the otheroutput issuehave isa fixed.'%' Anysuffix?" clue-> aboutI thiswould say no, @[[User:Trappistas themy monk|Trappistidea thewas monk]]?to use this for charts that need a percentage value (as a number, not a string). [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 1708:5503, 425 AprilMarch 2025 (UTC)
:I've copied the tests from [[User:Julius Schwarz/sandbox]] into {{tlx|test case}} templates at [[Template:SeatsEUPPs/testcases]]. I have also changed {{tlx|SeatsEUPPs/sandbox}} to use [[Module:SeatsEUPPs/sandbox]]. From the ~/testcases results, you can see that the live template rarely agrees with Module:SeatsEUPPs/sandbox. At a glance, testing the live module against the live template in ~/testcases gives similar results. No doubt, the live template uses it parameters differently from the modules.
::I think that I have tracked it to {{Q|Q1315362}}. If I write these templates (takes [[Module:EUPP_seats/sandbox]] out of the loop) I get unexpected results for the upper house:
:::lower house: <syntaxhighlight lang="wikitext" inline="1">{{wikidata|property|Q1315362|P1410|P194=Q320265}}</syntaxhighlight> → {{wikidata|property|Q1315362|P1410|P194=Q320265}} – a number so that's ok
:::upper house: <syntaxhighlight lang="wikitext" inline="1">{{wikidata|property|Q1315362|P1410|P194=Q389423}}</syntaxhighlight> → {{wikidata|property|Q1315362|P1410|P194=Q389423}} – (apparently empty string) not a number so not ok
::Q1315362 property {{property|P1410}} has 'issues' so perhaps fixing those will fix the problem.
::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 19:03, 4 April 2025 (UTC)
:::Yes, I also commented out and back in some entries for the ESN and identified the AfD as the one responsible. But in that case, it's because the entry was indeed empty. I fixed it and it works. Would there be a way to replace a missing entry with a zero but to record that somewhere? The issue here is that the Bundesrat is filled by State-level coalitions and the coalition seemingly decides together, meaning the seats aren't directly attributed to specific parties. So, on the one hand we would need to account for the Bundesrat, but on the other we can't directly link one seat to a party. It's easy for parties that are not in present at all in the coalitions (then it's 0), but not for the rest. [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 20:43, 4 April 2025 (UTC)
:::Turns out Levice was also just simply missing its upper house entry, but for no good reason. Currently, the reason above only affects the EPP (so my changes are pending), but that's because other German parties have 0 as a number of seats for the Bundesrat, but erroneously so. A proposal: we mute the error by replacing a missing value with 0, but we make a test function that would allow me to keep an eye on missing issue and that would report the parties with missing values. [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 20:51, 4 April 2025 (UTC)
::::Created <code><nowiki>{{#invoke:EUPP seats|test_wikidata_entries}}</nowiki></code> for this purpose. Seems to work.
::::Currently: <code><nowiki>{{#invoke:EUPP seats|test_wikidata_entries}}</nowiki></code> -> {{#invoke:EUPP seats|test_wikidata_entries}} [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 11:57, 6 April 2025 (UTC)
== Capitalisation ==
Since it may be that some party/alliance names are not capitalised in the table (and I do not want to force this), I wanted to make sure that, when we compare a requested European party (from the argument) with the entries of the first column, we compare to the capitalised version of the entries (because we force the capitalisation of the arguments.
I tried changing:
<code>if european_party == cfg.tab_data_t[row]['european_party'] then</code>
into:
<code>if european_party == cfg.tab_data_t[row]['european_party']:upper() then</code>
or
<code>if european_party == string.upper(cfg.tab_data_t[row]['european_party']) then</code>
but that did not work. Any idea why? [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 08:28, 6 April 2025 (UTC)
:I thought I had fixed it -- see latest changes to [[Module:EUPP seats/sandbox]], also deployed to [[Module:EUPP seats]]. And when I test both on my own sandbox ([[User:Julius Schwarz/sandbox]]), it works. But from [[Patriots.eu]], it doens't work. What am I missing, @[[User:Trappist the monk|Trappist the monk]]? [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 11:55, 6 April 2025 (UTC)
::Not obvious that [[Module:EUPP_seats#L-444--L-447|lines 444–447]] execute when the module is called from [[Patriots.eu]].
::
::Both of <syntaxhighlight lang="lua" inline="1">cfg.tab_data_t[row]['european_party']:upper()</syntaxhighlight> and <syntaxhighlight lang="lua" inline="1">string.upper(cfg.tab_data_t[row]['european_party']</syntaxhighlight> work to upcase the value assigned to <code>european_party</code>. But is that code necessary or appropriate? Oughtn't you to be checking that with <code>test_wikidata_entries()</code> rather than upcasing <code>cfg.tab_data_t[row]['european_party']</code> for every row in the loop?
::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 12:47, 6 April 2025 (UTC)
:::Not sure how test_wikidata_entries can help here -- it is just supposed to find issues in Wikidata itself. Here I just want the european_party under consideration to match the tabular data, whether the table has "PATRIOTS" or "Patriots" in the first column. Since the european_party is always capitalised, I was thinking of doing the if test with the capitalised version of the table cell value. And it does work well in the test (I added a non-capitalised version line at the bottom of the tabular data). [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 13:02, 6 April 2025 (UTC)
::::<code>test_wikidata_entries()</code> can ensure that all of the names listed under the <code>european_party</code> heading in the wide table are written using the correct case. That way you don't have to upcase <code>cfg.tab_data_t[row]['european_party']</code> every time you need that name. <code>test_wikidata_entries()</code> is really a cross-checking function; if there is an error in tested qids in the wide table, there is some chance that the function will catch that error. If you are going to establish a requirement that all parties named in the <code>european_party</code> column are uppercase, it makes sense to test those party names to ensure compliance with the requirement. The user should be able to write <code>patriots</code>, <code>PATRIOTS</code>, or anything in between; [[Module:EUPP seats]] will accommodate those variations because it only needs to do it once per template. That is better than doing it 265 times per template.
::::
::::{{tq|it does work well in the test}} but {{tq|from [[Patriots.eu]], it doens't work.}} What was {{tq|the test}}? How do you know that {{tq|from [[Patriots.eu]], it doens't work}}? These seem contradictory to me.
::::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 14:04, 6 April 2025 (UTC)
:::::But I am ''not'' establishing a requirement that all names in the first column be capitalised. Most are because they are acronyms, but others (Patriots, DiEM25, Volt, etc.) are not -- well, I capitalised them temporarily so that it would work, but that is just a temporary fix. We all people to call the module/templates with "Patriots" or "PaTrIoTs" and I think we should keep that fleibility in the table, because someone is bound not to respect the capitalisation, starting with me, since the initial table that I have should not have everything capitalised.
:::::As for the last question, when I call <code><nowiki>{{#invoke:EUPP seats|composition_bar|ms-lower-house|Patriots}}</nowiki></code> or <code><nowiki>{{EUPP composition bar|ms-lower-house|Patriots}}</nowiki></code> from my user sandbox, it works (it finds 734 seats (which accounts for the redundant last line of the table). However, when calling <code><nowiki>{{EUPP composition bar|ms-lower-house|thisparty}}</nowiki></code> from the page Patriots.eu, it gives 608 (which does not include the last line of the table, which is not capitalised. [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 14:30, 6 April 2025 (UTC)
::::::OR maybe we can force uppercase for the first column when we import the table via the config function? [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 14:55, 6 April 2025 (UTC)
::::::{{ec}}
::::::As you wish.
::::::
::::::<syntaxhighlight lang="wikitext" inline="1">{{EUPP composition bar|ms-lower-house|Patriots}}</syntaxhighlight> doesn't 'work' because in [[Module:EUPP_seats#L-436--L-442|lines 436–442]], you do not do the upcasing thing.
::::::
::::::Alternate solution: Because we copy the tabular data file into a lua sequence, we can, as we read the data, upcase <code>european_party</code>. Add this at [[Module:EUPP_seats/config#L-123|line 123]]:
:::::::<syntaxhighlight lang="lua" inline="1"> row_data_t.european_party = row_data_t.european_party:upper(); -- ensure <european_party> values are always uppercase</syntaxhighlight>
::::::Do nothing else; then look at [[Patriots.eu]].
::::::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 14:59, 6 April 2025 (UTC)
:::::::That's perfect! And I guess in the same way, we would skip an empty line (perhaps by just testing on whether the first column is empty, which it should never be)? [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 15:46, 6 April 2025 (UTC)
::::::::If {{tq|the first column is empty, which it should never be}}, I don't think you want to skip it. You should allow the module to shout an error (as it did when the whole bottom row was empty) because sommat is seriously wrong and needs urgent attention.
::::::::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 16:02, 6 April 2025 (UTC)
:::::::::Yeah, that's a good point. Any recommendation for an entirely empty line? [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 16:44, 6 April 2025 (UTC)
:::::::::I would like to avoid that crashing all the pages where the module is used.. [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 16:44, 6 April 2025 (UTC)
::::::::::You could add a <code>null_row</code> export and then as part of <code>build_tab_data()</code>, test each row for all-nil values. If any whole row is nil, set <code>null_row</code> to some value – boolean <code>true</code>, the row number, an error message, etc. Then, in [[Module:EUPP seats]], look at <code>cfg.null_row</code>. If set do something about it.
::::::::::
::::::::::This idea not tested.
::::::::::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 18:00, 6 April 2025 (UTC)
== Error in mobile app ==
@[[User:Trappist the monk|Trappist the monk]], in my browser, all the composition bars on the pages of European parties work. On the Android mobile app, however, several pages show error messages relating to the config file (for instance, Animal Politics EU and European Green Party, but not the European People's Party).
[[File:Screenshot error module EUPP seats in Android mobile app.png|thumb|Screenshot error module EUPP seats in Android mobile app]] [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 07:47, 7 April 2025 (UTC)
:Caching problem? What happens if you purge the page? Does that android device have a browser option? Do the errors appear when viewed with the device's browser? That's about all the help that I can offer because I don't have an android device. I don't see the errors when viewing [[Animal Politics EU]] and [[European Green Party]] on my iphone.
:—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 11:31, 7 April 2025 (UTC)
::Thanks @[[User:Trappist the monk|Trappist the monk]]. I will check the cache and yes it does work from the browser of the same phone. On a separately topic, I note that the module does not work for European political alliances when called with "thisparty", I guess the check is only done on the party table. Unfortunately, I can't check this now, would it be possible for you to have a quick look? PS: data gathering on all national parties is now done and I am working on the "second module". [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 12:43, 7 April 2025 (UTC)
:::Link to someplace that doesn't work? What template specifically doesn't work?
:::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 12:55, 7 April 2025 (UTC)
::::Sorry, you can take [[European Pirate Party]] as an example. You will see in the infobox that figures for upper and lower houses are 0 -- this is not in line with the same calls (but using "PPEU" instead of "thisparty" on my own [[User:Julius Schwarz/sandbox|sandbox]]. Same for [[European Communist Action|ECA]] or [[Volt Europa|Volt]]. [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 14:23, 7 April 2025 (UTC)
:::::Maybe line 438; it seems like we try and find "thisparty" only in the list of parties, but not in the list of alliances. [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 14:30, 7 April 2025 (UTC)
::::::Dunno whether that was the best way, but I found a quick fix. [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 14:42, 7 April 2025 (UTC)
:::::::Thanks, I actually almost tried that but wasn't sure it'd work :) [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 14:58, 7 April 2025 (UTC)
:::::::{{ec}}
:::::::Simplified some. That code should work. Will <code>sum_national_party_seats()</code> ever be called without a party? If so, some sort of error trapping or default value will be needed.
:::::::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 15:02, 7 April 2025 (UTC)
::::::::It should not, no. Because it is only called internally, and it seems always after one of the two party validations functions are called. So if the party given in argument is not really a party, then there should be an error message before it reached that function. [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 18:44, 7 April 2025 (UTC)
== Double error message ==
@[[User:Trappist the monk|Trappist the monk]], error messages in the two testcases pages ([[Module talk:EUPP seats/sandbox/testcases]] and [[Module talk:EUPP seats/sandbox/testcases composition bar]]) seem to nest two error messages. For instance <pre>Error: Error: {{EUPP composition bar}}: institution is required (help): unknown party: TEST (help)</pre> where the "institution is required" message seems nested between the first "error" and "unknown party: TEST". [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 16:11, 8 April 2025 (UTC)
:Doesn't seem to happen in the examples of [[Module:EUPP seats/sandbox]], though. [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 16:31, 8 April 2025 (UTC)
:
:To change the live template so that it uses the live module, copy the contents of the {{tld|SeatsEUPPs/sandbox}} to {{tlx|SeatsEUPPs}}. In {{tlx|SeatsEUPPs}}, change the invoke to <syntaxhighlight lang="wikitext" inline="1">{{#invoke:SeatsEUPPs|main}}</syntaxhighlight>. Save.
:The {{color|#d33|institution is required}} bit suggests that an empty {{em|template}} is processed by mediawiki after the error message is created by the module which would explain why the {{color|#d33|institution is required}} error appears within the {{color|#d33|unknown party: TEST}} error message. I'm not sure of the exact mechanism, nor if the issue has something to do with [[Module:UnitTests]] or with MediaWiki
:
::<syntaxhighlight lang="wikitext" inline="1">{{EUPP seats}}</syntaxhighlight> → {{EUPP seats}}
:Look at ~/testcases again. All tests should produce similar results; the flagged tests should be the result of different error message formatting.
:A fix might be made to the <code><nowiki>{{$1}}</nowiki></code> bit of the error message at [[Module:EUPP_seats/sandbox#L-29|line 29]]. Perhaps change one of the <code>{</code> to <code>&#x7B;</code>:
:—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 16:14, 25 March 2025 (UTC)
::<syntaxhighlight lang="lua" inline="1">return substitute ('<span style="color:#d33">Error: {{$1}}: $2 ([[:Template:$1|$3]])</span>$4',</syntaxhighlight>
:—:How would one go about adding that "%"? [[User:TrappistJulius the monkSchwarz|TrappistJulius the monkSchwarz]] ([[User talk:Trappist theJulius monkSchwarz|talk]]) 1722:4418, 825 AprilMarch 2025 (UTC)
:::With the concatenation operator: <code>..'%'</code>
::Thanks. I can't say that I would have ever figured that one out... [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 19:10, 8 April 2025 (UTC)
:::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 23:39, 25 March 2025 (UTC)
== SPARQLUse queryof template ==
@[[User:Trappist the monk|Trappist the monk]] as you can tell, I am rather new to modules. My idea was that, by creating the module, we would use it directly in relevant pages. But from your last comment about the way forward, I have a sense that we will keep using the template. Does this mean that we should rewrite the template to call the module? For instance, the revised template would be <code><nowiki>{{SeatsEUPPs|EP|EPP}}</nowiki></code> and this would actually call <code><nowiki>{{#invoke:SeatsEUPPs|main|EP|EPP}}</nowiki></code>? Is it just for writing convenience, then? [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 08:09, 25 March 2025 (UTC)
Any chance you are also familiar with Sparql queries, @[[User:Trappist the monk|Trappist the monk]]? ;)
:I have no problem with using module invokes in article text... But, not all editors are sufficiently technically minded to do that. The template hides the function call (<code>main</code>) from editors.
:
:The nice thing about [[Module:Arguments]] is that it automatically fetches arguments from the both the frame and the parent frame. Writing <syntaxhighlight lang="wikitext" inline="1">{{#invoke:SeatsEUPPs|main}}</syntaxhighlight> in the template will hand the parent frame parameters (from the template call in article wikitext) to the module. You can see this working in {{tlx|SeatsEUPPs/sandbox}}:
::<syntaxhighlight lang="wikitext" inline="1">{{SeatsEUPPs/sandbox|EP|EPP}}</syntaxhighlight> → {{t|SeatsEUPPs/sandbox|EP|EPP}}
:—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 16:14, 25 March 2025 (UTC)
::Yeah, I have to admit that's neater this way. Thanks, it's all looking really clear. [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 21:35, 25 March 2025 (UTC)
== Continuation ==
I am trying to list all national parties that are members of a European party and whose country is a member of the European Union. That much I have. However, I also want to display their number of seats in the European Parliament (but it should not be a requirement to have such an entry).
Hi @[[User:Trappist the monk|Trappist the monk]], before you bow out, allow me to ask one more thing. I started replacing raw calls to wikidata with the module and it hit me that, in most cases, this is being used as part of a composition bar. Not always, but super often.
So far, I have:
And all of a sudden, it became a bit irresistible to make another module, based on [[Module:SeatsEUPPs]] that would spit out the composition bar :D Now, I got the gist of most of the process, but I could use a quick hand to write the part that actually writes the composition bar using our module. Would you mind having a look? It's at [[Module:Sandbox/Julius Schwarz/CompositionBarEUPPs]] [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 21:43, 25 March 2025 (UTC)
<pre>
:Forking is a bad idea. Instead, add a new exported function to [[Module:SeatsEUPPs/sandbox]] that calls the necessary local functions to produce the output that you want. I've started a function <code>composition_bar()</code> at the bottom of ~/sandbox, added some comments and questions there. Improve on that.
SELECT ?item ?itemLabel ?countryLabel ?seats
::<syntaxhighlight lang="wikitext" inline="1">{{#invoke:SeatsEUPPs/sandbox|composition_bar|EC|EPP}}</syntaxhighlight> → <nowiki>{{#invoke:SeatsEUPPs/sandbox|composition_bar|EC|EPP}}</nowiki>
WHERE {
:—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 22:50, 25 March 2025 (UTC)
?item wdt:P463 [wdt:P31 wd:Q24649]; #member of an instance of European party
::Well noted. I started having a look at the comment you made. For line 346, indeed, share has no place here. That was in case "%" or "share" ended up as the party argument. Not happening here. And I will introduce data validation for width and percentage. However, I hit the same issue three times: 1) width should be a percentage and not a number should we can input it as a number but we have attach a "%" sign; 2) I have to attach a "#" sign to the hex code; and 3) I might attach a "%" for seats_share. In all three cases, I am not sure how to concatenate text. [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 23:57, 25 March 2025 (UTC)
wdt:P17 [wdt:P463 wd:Q458]; #from a country that is a member of the European Union
:::According to the {{tlx|Composition bar}} documentation, width specified as without units assumes <code>px</code>. The documentation also says that the template will also accept <code>%</code> and <code>em</code> units. I've added a snippet of code to validate the width value. Should probably be a separate function. Also added '#' to the color.
wdt:P17 ?country;
:::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 00:45, 26 March 2025 (UTC)
OPTIONAL { ?item p:P1410 [ps:P1410 ?seats; pq:P1410 wdt:Q8889]. }
::::Thanks and now indeed the colour displays properly. I did a similar operation to add "%" to the share_fc function, but reverted it as bar charts may need to do some calculation on the percentage, so better to leave it out until I create a separate function for this :) [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 08:05, 26 March 2025 (UTC)
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". } }
:::::Thanks for the help @[[User:Trappist the monk|Trappist the monk]]. I think we are nearing completion. I updated the roadmap above and I think when these items are done this can be considered completed for the time being and I will start using it on all relevant pages. [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 11:02, 27 March 2025 (UTC)
ORDER BY ?countryLabel ?itemLabel
::::::If {{tlx|CompositionBarEUPPs}} is going to mimic {{tlx|composition bar}}, it seems to me that {{tld|CompositionBarEUPPs}} should use the same parameter names for the options:
</pre>
::::::*{{para|background-color}}
::::::*{{para|border}}
The <code>OPTIONAL</code> line is what doesn't work as it yields an empty column. [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 12:02, 9 April 2025 (UTC)
::::::*{{para|width}}
:No experience with database queries. Does the dot after <code>wdt:Q8889]</code> have meaning? What about the dot after <code>en-gb"</code>? For that matter, what about the semicolons?
::::::*{{para|per}}
:
::::::*{{para|ref}}
:I see that you have also asked this question at {{slink|WP:VPT|SPARQL query}}. If you don't get an answer there, surely someone at Wikidata will know the answer.
::::::That means no <syntaxhighlight lang="wikitext" inline="1">{{{3}}}</syntaxhighlight>, <syntaxhighlight lang="wikitext" inline="1">{{{4}}}</syntaxhighlight>, <syntaxhighlight lang="wikitext" inline="1">{{{5}}}</syntaxhighlight>.
:—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 13:40, 9 April 2025 (UTC)
::::::
::Thanks, and fingers crossed! [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 14:39, 9 April 2025 (UTC)
::::::To override the wikidata-supplied bar color we might reinstate <syntaxhighlight lang="wikitext" inline="1">{{{3}}}</syntaxhighlight> for use as {{tlx|composition bar}} uses it, or create a new option parameter {{para|bar-color}}. This latter would be my preference. Of course, I would also spell-out {{para|percent}} and {{para|reference}} (and also rename {{tld|CompositionBarEUPPs}} to {{tlx|Composition bar EUPPs}} or better, {{tlx|EUPP composition bar}} because English is written with space characters between words; I might even suggest {{tlx|EUPP seats}} as a better name).
::::::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 14:35, 27 March 2025 (UTC)
== The time allocated for running scripts has expired ==
:::::::That seems all very sensible. For the colour element, I think it is nice to have it, but it should just be the exception; by default, we just take the registered party colour. And I am happy to rename the modules and templates. As for the arguments, like I wrote in the table, I was unfortunately stuck when I tried to use something else than 'yes' for percentage or reference, for instance. [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 14:58, 27 March 2025 (UTC)
::::::::I've added a 'thisparty' test to <code>validate_institution_party()</code>. Seems to work, you might want to test it further.
You should probably archive some of this page since it now exceeds the Expensive parser function count (886/500) and sometimes exceeds the Lua time usage limit (10 seconds).
::::::::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 15:27, 27 March 2025 (UTC)
::::::::
::::::::Added support for {{para|width}} (<code>{{{3}}}</code>), {{para|pc}} (<code>{{{4}}}</code>), and {{para|ref}} (<code>{{{5}}}</code>). Still to do is to remove support for those positional parameters.
::::::::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 16:16, 27 March 2025 (UTC)
::::::::
::::::::Rewrote <code>get_colour()</code>. The hash prefix is added there because it should be possible to use named colors in {{para|bar-color}} (which overrides the wikidata color). Other color parameters also appear to be working:
:::::::::<syntaxhighlight lang="wikitext" inline="1">{{EUPP composition bar/sandbox|EC|EPP|bar-color=blue|border=red|background-color=#3a3}}</syntaxhighlight> → {{t|EUPP composition bar/sandbox|EC|EPP|bar-color=blue|border=red|background-color=#3a3}}
::::::::{{para|percent}} and {{para|ref}} are now case-insensitive. Positional parameters <code>{{{3}}}</code>, <code>{{{4}}}</code>, and <code>{{{5}}}</code> are now ignored.
::::::::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 00:31, 28 March 2025 (UTC)
:::::::::Thanks for this, @[[User:Trappist the monk|Trappist the monk]]; this is now all reflected in the testcases and it is all working correctly. I will therefore move the code to the main module and update the documentation accordingly. [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 09:08, 28 March 2025 (UTC)
:In the module sandbox, I have streamlined <code>seats()</code> and <code>seats_share()</code>. [[Template:EUPP seats/testcases]] seems to show that I did not break anything. If you agree then the live module should be updated from the sandbox.
:—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 15:42, 28 March 2025 (UTC)
::The changes are deployed and I confirm that nothing is broken! However, I started having a look at translation and it won't be as easy as planned since the Wikidata templates are not the same on all wikis. I think I can handle it, though. [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 15:52, 28 March 2025 (UTC)
== Massive thanks! ==
—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 13:47, 9 April 2025 (UTC)
Just wanted to massively thank @[[User:Trappist the monk|Trappist the monk]] for their help on this. Given my own knowledge of Lua (or lack thereof), none of this would have been possible without them, and the code in the articles look much much neater now! I also learned a whole lot, which feels great. Admittedly, this does not impact too many pages per wiki, but it is directly applicable to many other wikis, so I look forward to working on translating it and replicating it! [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 14:38, 28 March 2025 (UTC)
:Done! [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 14:41, 9 April 2025 (UTC)
|