Module talk:Goalscorers

(Redirected from Module talk:Goalscorers/sandbox)
Latest comment: 1 month ago by Jts1882 in topic Bad argument to formatNum

Module idea

edit

Thanks again for your work on the ranking module! I've had an idea for a module for a while, unfortunately I am not familiar enough with Lua so I was wondering what you thought.

At UEFA Euro 2016 qualifying#Goalscorers, there is a list of all the top scorers in the qualifying competition. On the qualifying sub-articles (i.e. UEFA Euro 2016 qualifying Group D, UEFA Euro 2016 qualifying play-offs) there are also lists of goalscorers at the bottom. For example, Arkadiusz Milik scored 6 goals in the group, as listed on both articles. Jonathan Walters scored 3 goals in his group, as well as 2 goals in the play-offs, and therefore is lited having scored 5 goals on the main article. Could a module be created, with all goalscorer data, to be able to output the list of scorers by round, sorted by number of goals? For example, in this situation, Jonathan Walters would have his scoring information by round (3 in Group D and 2 in playoffs), and then display the correct amount of goals on the 3 articles (3 Group D, 2 play-offs, 5 main article). Not sure what way the scoring data would be formatted, possibly by national team and then you could define what rounds a team participated in (i.e. POLGrD and IRLGrD, PO, or something like GrDGER, POL, IRL, SCO, GEO, GIB). Think this would be possible? S.A. Julio (talk) 05:39, 12 December 2018 (UTC)Reply

The first step is determining how the data should be stored. A player table could simply have goals by round so each player has a row: { country name (or code?), player name, 1, 2, 3 ... } and then have a country-group table with each counry having a row { group, country } or a key-value. I'll have a look at the article pages later and comment further.   Jts1882 | talk  10:05, 12 December 2018, (UTC)
I think a single table would be simplest. Then it needs the follow steps
  • Table entry for each row: { player, country, group, goals in group, goals in play-off, ... }
 goalscorers = {
              { Arkadiusz Milik, Poland, D, 3, 2 },  
              ...
              }
  • Iterate through the table and create a table of entries that meet certain criteria, e.g. (group == X AND goals in group > 0), (goals in play-offs > 0), (goals in group > 0 OR goals in play-off > 0). A non-zero threshold could also be set.
  • Then this table needs to be sorted by goals (primary) and name (secondary). This is the more difficult step, although I'm sure some sort algorithm can be found somewhere.
  • Generate the output as a list.
Nothing too difficult. It would be a good excercise for you to get into Lua. I learnt it from scratch when converting the {{clade}} template and I'd never heard of Lua beforehand. Writing the Lua code was much simpler than deciphering the template language code. I could outline a module to get it started, then we could work together to develop it further.   Jts1882 | talk  14:33, 12 December 2018 (UTC)Reply
Alright, my goal is to complete goalscorer information for the entire history of Euro qualifying. In 1960 and 1964 there were no groups, just three rounds, so there'd need to be a way to add this as well. 1980 to 1992, along with 2008, should be fairly simple as there was only the group stage. I had created Template:Goalscorers for tournaments (i.e. not multiple rounds), was thinking that template could be merged into this potential module as well? I'd think the module should also calculate the number of goals from the data. Another issue would be own goals and how to format this. If a player had scored one or more goals, and also an own goal, should this be defined in the same line, or maybe list own goals in a separate section? Also, the country(s) they scored the own goal for needs to be listed, example: "  Josep Gómes (against Kazakhstan)". So for own goals, maybe something like { player, country, group, own goals in group, own goal opponent(s) in group, own goals in play-off, own goal opponent(s) in play-off }. Below I've added a few examples to help envision a potential module.
Some examples
The following would be on the goalscorer data page:

--            { 'round1', 'round2', ...}

data.rounds = { Group stage, Play-offs }


--            { 'country1', 'country2', ...}

data.GrpC = ...
data.GrpD = { GER, POL, IRL, SCO, GEO, GIB }
data.GrpE = ...




The group D article might use the following:

{{#invoke:Goalscorers|main|UEFA_Euro_2016_qualifying|round=Group stage|teams=GrpD}}

It would show all the 'round1' (Group stage) goals only from players with country codes that match those in "GrpD"




Then for the playoffs:

{{#invoke:Goalscorers|main|UEFA_Euro_2016_qualifying|round=Play-offs}}

Unlike round1 (Group stage), which is sub-divided, round2 (Play-offs) is not, therefore the "teams" parameter wouldn't be necessary
I've had this idea for a goalscorer template/module for quite a while, but haven't really been able to get anything started. I'll try and learn some Lua, I'd really appreciate any help with this. S.A. Julio (talk) 02:04, 13 December 2018 (UTC)Reply
I'd be glad to help. A couple of quick question on your proposal above: how flexible do you want it to be? Would you want to get data separately from each of three rounds of the 1960 and 1964 tournments? If not the module just needs to hand a group stage and a knock-out stage (three rounds or the current single round playoffs) and my single table structure (see above) would be sufficient. Do you want something that could be extended to other tournaments (e.g. the Champions League)? This would then require the more complex structure that would be controlled by your data.rounds table, which could hold information about the type of round (group, knock-out, ...).   Jts1882 | talk  08:38, 13 December 2018 (UTC)Reply
I was hoping for something which could be used for other international qualifying tournaments, i.e. UEFA Women's Euro 2017 qualifying / 2019 FIFA Women's World Cup qualification (UEFA) (preliminary group stage, main group stage, playoff round), 2019 Africa Cup of Nations qualification (preliminary knockout round, group stage), or 2018 FIFA World Cup qualification (AFC) (preliminary knockout round, first group stage, second group stage, playoff round). However, for example the AFC World Cup qualifiers don't have dedicated group articles, but rather articles on the four stages (therefore not requiring the group composition to be stored in the module). I was thinking the data.rounds would just be to give a name to identify the various rounds (i.e. data.rounds = { First round, Second round, Third round, Fourth round } for the AFC example. Then with { John Smith, PHI, 3, 5, 7, 1 }, the "3" correlates to "First round", the "5" to "Second round", etc. The module would then be called by {{#invoke:Goalscorers|main|...|round=Third round}} to show Third round goalscorers). This wouldn't need to be used for Champions League/other club competitions, only international tournaments which have these goalscorer sections. S.A. Julio (talk) 10:19, 13 December 2018 (UTC)Reply
@S.A. Julio: Got you. That seems straightforward enough. The only tricky bit will be inserting a group stage in the sequence. But I think I'm now clear on what you want.

Prototype

edit

Meanwhile to get started, I've creates a prototype, Module:Goalscorers, to produce some simple output when called from {{Goalscorers/sandbox}}. It uses some sample data I've placed in Module:Goalscorers/data/UEFA Euro 2016 qualifying using a single table format. I think a more flexible system needs more thought and this can get the basics of the output dealt with. For now the code now just reads the list and outputs the goalscorer with the goals from the group and play-offs totaled. The sample data is accessed through line 16 and then handled by the main() function (line 47). I think you'll see that this is much easier to follow than the template language.   Jts1882 | talk  10:35, 13 December 2018 (UTC)Reply

Great, the module is looking good! I tried to match the output of {{Goalscorers}}, which formats the columns as such: <div class="div-col columns column-count column-count-3" style="{{column-count|3}}">...</div>. I must have messed up the formatting as the edit didn't work, could this be adjusted? Thanks, S.A. Julio (talk) 17:31, 13 December 2018 (UTC)Reply
@S.A. Julio: I think you tried putting the formating around the wrong elements. I've moved the open list and close list template calls to functions, which should make the logic clearer. If you want to use direct HTML instead of {{div col}} and {{div col end}} replace it in those function. I've also put the linked flag icon in a function and it now gets the icon template name from the data module so women's tournaments can use a different template.   Jts1882 | talk  08:52, 14 December 2018 (UTC)Reply
I've updated to use other competitions using the same subpage system as the Sports Rankings. In a Module:Goalscorers/data/test competition I've added a prequalifying round. Note the data.round table. Set the rounds to the approapriate goals column, starting with 4 and it should handle as many as needed. If there is no group stage, column three still needs to be set but will be ignored.   Jts1882 | talk  09:59, 14 December 2018 (UTC)Reply

Alright, looks good! I adjusted the module so that players are linked from the data page, this makes it easier for players that need their links piped. Also, how should we format own goals? And I've completed the information on the Euro 2016 data page. One issue I've noticed is that playoff goals are not being calculated in the overall list anymore, this can be seen on the sandbox with Ibrahimović in the Euro 2016 qualifying and test competition sections. The only other problem is the sorting. On the data page, I sorted all the players alphabetically: first by nationality, then by surname. However, when looking at the sandbox, all the players of the same nationality are no longer kept together. Any idea how this could be fixed? S.A. Julio (talk) 22:45, 14 December 2018 (UTC)Reply

Good idea putting the links and redirects in the data module. Much simpler and more flexible.
The lack of playoff goals was a silly logic test (<#v rather than <=#v) which meant it was adding rounds exclusive of the last one. I think that is fixed. It now counts all goals from column four until the last one as intended.
On own goals, I'd not registered that they need the scored against entries, so they will need different handling. I need to break the main function up into select players, sort players, and output (DONE). Then the own-goals just need to be selected differently and get the note added. Your entries with the goals and opponents in alternating columns is one way. Another might be entering them as { goals, opponent } pairs, which will need slightly more intricate code, but then offers the opportunity for a parenthetic note after any entry. Would this be a useful addition? I'll give this a bit more thought.
The sorting is something I need to look at more. I would have assumed that the order you entered them in would have been retained within each goal block after sorting. However, the Lua handling of tables is quite confusing. It's possible that the sort function (function( a, b ) return a['goals'] > b['goals'] end) can be made to do that, but the documentation of the sort function is minimal. The other way might be just to add addition sorts of for each goalnumber in the main loop. Another thing that needs a bit more thought.
The Lua table.sort function allows quite complicated sorting. I've done sorting on goals, then country and then player name. For the player name I've sorted on the second name, so van Persie is under "v". However, this doesn't work for Jóan Símun Edmundsson who gets sorted under "s". This could be resolved by removing Simun from the data module and using a redirect. I doubt there is a simple formula that will work for every player. Unexpectedly, players with a single name are getting shown first, which I don't understand given I've set the second name.   Jts1882 | talk  11:14, 15 December 2018 (UTC)Reply
The single name wasn't sorted properly because the name string included the redirect. Now handled by splitting after the pipe before testing. It works, albeit a bit messy.   Jts1882 | talk  13:27, 15 December 2018 (UTC)Reply
Anyway, I don't think these modification should present major hurdles. We're getting closer.   Jts1882 | talk  08:12, 15 December 2018 (UTC)Reply

@S.A. Julio: Just to let you know I've moved the discussion from my talk page. It makes more sense to have it here on the module talk page.   Jts1882 | talk  13:28, 15 December 2018 (UTC)Reply

@Jts1882: Perfect, looks very close! If the original order on the data page cannot be retained, could the module instead be able to retrieve the default sort key of an article (i.e. Edmundsson, Joan Simun in this case) to use for sorting? And seems like a good idea for own goals. Only question is what about the (albeit rare) scenario that someone scored own goals across multiple rounds? Say they scored two own goals in the group stage and one in the playoffs, the display on the main article should have the opponents alphabetical. Maybe a manual way to define the overall "against" note? Another unlikely scenario might be someone scoring three own goals against two opponents, for example see 2019 FIFA Women's World Cup qualification – UEFA Group 6#Goalscorers: Nadejda Colesnicenco (2 against Belgium, 1 against Italy). How could this be formatted? S.A. Julio (talk) 15:21, 15 December 2018 (UTC)Reply
Also tried to add a parameter for the youth level that could be used for {{fbuicon}}, though something seems to have gone awry. The age level needs to go before the country code in the template, so the formatting probably needs to be adjusted. S.A. Julio (talk) 15:48, 15 December 2018 (UTC)Reply
For a youth tournament just change the name of the icon template in the data module. Use {{fbuicon}} instead of {{fbicon}} in the line data.templates = { flag_icon_linked = "fbicon" }. Isn't that what you want?   Jts1882 | talk  16:18, 15 December 2018 (UTC)Reply
Though the age level also needs to be added when {{fbuicon}} and {{fbwuicon}} are called, i.e. 17 for under-17. This is the first unnamed parameter of the template, so it needs to be added before the country code. S.A. Julio (talk) 16:33, 15 December 2018 (UTC)Reply
@S.A. Julio: Now I follow. What you did worked for the youth teams, but you didn't handle the empty parameter for senior teams. I've made the changes and it seems to work.   Jts1882 | talk  16:45, 15 December 2018 (UTC)Reply
(edit conflict) These own goals are proving quite tricky. See {{Goalscorers/sandbox2}} for progress (top example).
  • One possibility is to just list the owns goals without the "against" prefix and avoid connecting terms like "and". Goals in the same round get separated by commas, different rounds by a semi-colon. Then the output string would be of form "(Croatia(2), Italy; Spain)" with "Croatia(2), Italy" and "Spain" being the respective entries in the data module.
  • Playing the same opponent in different rounds is unlikely as the draws for the play-offs usually separate teams from the same group and knockout rounds eliminate the losing team.
  • Opponents in chronological order is not unreasonable, but if we have a simple comma-delimited list that can be sorted alphabetically and formating added (e.g. a "games against" prefix) and an "and" separator between the final two.
  • One other awkward feature is how the lists of owngoal countries wrap to the next column.
With this format in the data module you can add comments for any goalscorer. You can see one Ibrahimović might have written himself in {{Goalscorers/sandbox2}}.
The default sort key is an interesting idea and might be a more elegant solution. The question is can Lua get this from the page information of a target article. My guess is yes, but I've no idea how.   Jts1882 | talk  16:06, 15 December 2018 (UTC)Reply
Yes, I recall using a query which retrieved the defaultsort value of a page, hopefully a module could also access this information. S.A. Julio (talk) 16:33, 15 December 2018 (UTC)Reply
@Jts1882: I suppose the defaultsort idea breaks down when not all the players have an existing article. If there's a way to get the defaultsort, maybe it could optionally be enabled, otherwise fall back to the current sorting method? Therefore it could be enabled with the Euro qualifiers (where most players have articles), while articles such as 2019 FIFA Women's World Cup qualification – UEFA Group 2 (which has redlinks) could use the current method. Also, the only problem with removing the "against" prefix is that it could cause confusion for some unfamiliar readers. Not sure what the best solution is, maybe it would be better off to manually define the "against" note for complex situations. One other thing I noticed with the sort order is Spain (codes ESP) now follows England. Using the three letter code is a bit cleaner on the data page, could there be another way so the countries properly sort? For example, {{getalias}} can generate the full name from the country data page using the three letter code (unless there is a name alias for football, instead something like {{getalias2|CHN|name alias-football}} would need to be used). S.A. Julio (talk) 17:39, 15 December 2018 (UTC)Reply
@Frietjes: Would you know if/how a module could call the defaultsort value of an article? S.A. Julio (talk) 16:36, 15 December 2018 (UTC)Reply
S.A. Julio, I don't think you can do it without loading the text of the entire page and then performing a string search for the defaultsort. if the defaultsort were saved in WikiData, it would be much easier. a less expensive and less complicated method would be to put a delimiter between the first and last name, say a "/" or a "!" or a "~". the module could then use that to make the sort key. Frietjes (talk) 13:56, 16 December 2018 (UTC)Reply
@S.A. Julio: I think the simplest solution is to use £nbsp; before second names that shouldn't be used for sorting. The code splits the string on a standard space so treats the first two names separated that way as one. The none breaking space also gets handled correctly in the wikilinks. I've done this for the Norwegian players Jo Inge Berget and Mats Møller Dæhli in Module:Goalscorers/data/UEFA Euro 2016 qualifying.   Jts1882 | talk  09:32, 30 December 2018 (UTC)Reply

Also, should "2 own goals" be listed below "1 own goal"? That way it seems similar to a scale, with the best scorers at the top and the worst (most frequent) own goal scorers at the bottom. S.A. Julio (talk) 11:32, 16 December 2018 (UTC)Reply

Hopefully the own goal country string is properly alphabetised now. I see the logic of "a scale" but it seemed discordant when I looked at those lists. I think more own goals look more natural at the top, but it can be changed. One thing I did wonder is whether there should be a header between goals and own goals (I left a TODO note as a placer).   Jts1882 | talk  11:55, 16 December 2018 (UTC)Reply

@Jts1882: Alright, I don't think a header between goals and own goals is necessary, the current format is standard for football articles and should be clear. One other question is how are special characters handled? Would names such as Jón Dagur Þorsteinsson (Thorsteinsson, Jon Dagur) and Kári Árnason (Arnason, Kari) sort correctly? Also, ideally hyphens and other characters, along with the letter case, should be ignored. And I suppose sorting for single names, such as Isco and Nani, also needs adjusting. And for the issue with country sorting (i.e. Spain/ESP after England/ENG), could the module have a sort of "index" of country codes and their corresponding full names which they should be sorted by? (Similar to the country code definitions on the FIFA rankings template.) S.A. Julio (talk) 18:02, 1 January 2019 (UTC)Reply

Special characters are I assume sorted according to their character code. I've added a few names to Module:Goalscorers/data/test competition (which can be viewed in Template:Goalscorers/sandbox2) and Kári Árnason and Jón Dagur Þorsteinsson appear after the regular alphabet A-Z. The only way to handle this that I can think of is adding a sort name option somehow (perhaps like the own goal opponent as { name , sort_name }).
Punctuation will again be sorted based on character codes, but spaces and hyphens are grouped together so that should be the same as being ignored.
Case isn't handled currently, but lower case can be forced before the test.
I thought I had handled the single names but that doesn't seem the be working in all cases. Pedro loolks like it works; Nani doesn't; Éder looks like it works, but perhaps due to the special character.
The country code sorting is possible, but the simplest is to just enter the counrtry names if you want to sort by name or enter country code if you want to sort by code. However, we already have the code/country lists so that can be implemented.
The issue of name sorting must have come up on Wikipedia before, so I wonder if there is a template/module that deals with this in a far more sophisticated manner than anything I can write.   Jts1882 | talk  08:34, 2 January 2019 (UTC)Reply
@Jts1882: Okay. So there's really no way to retain the original order of the data on Module:Goalscorers/data/UEFA Euro 2016 qualifying? If not, I suppose a sortname value could be added. Otherwise what about defining a number value to sort by, i.e. 01.01 for Bekim Balaj, first player of the first country alphabetically, then 01.02 for Berat Djimsiti and so on. Henrikh Mkhitaryan would by 02.01, all the way to Hal Robson-Kanu who would be 53.04. Then it would be fairly quick to update the sort value when adding a new player for active competitions. Or maybe the first part of the number (sorting for the country) wouldn't be necessary if a country code list was implemented. S.A. Julio (talk) 16:27, 2 January 2019 (UTC)Reply
Also, regarding own goals, I think listing 1 first, then 2 own goals below is standard, for example Women's World Cup, U-17 World Cup, Euros, World Cup qualification, Asian Cup, etc. Could this be adjusted in the module? S.A. Julio (talk) 16:49, 2 January 2019 (UTC)Reply

Update

edit

The sorting of names function has been revamped and I think it now handles most of your requests.

  • There is now an optiional sorting alias handled in the same way as the goals against comment for owngoals. It should be entered as follows:
 
{ {"Kári Árnason", "Arnason, Kari" },     "Iceland",   "D", 5, 0  },
{ { "[[Jo Inge Berget]]", "Berget, Jo Inge" } "NOR",   "H",	1,	0 },
  • Other names don't need the alias as the code checks for the table structure
  • Three named players like "Jo Inge Berget" can also be handled by a non-breaking space (&nbsp;)
  • Single named players now sort properly. It was the wikitext double-brackets [[ and ]] that cause the wrong sorting order (i.e. "[[Nani]]" instead of "Nani"). These are now stripped off before sorting.
  • Names are forced to lower case before sorting
  • Hyphens and other punctuation in names are not ignored. Generally punctuation characters (spaces, hyphens, quotes, etc) are grouped together before number and letter characters so shouldn't interfer with alphabetic character sorting. If this causes a problem, please provide examples. Or just use a sorting alias as above.
  • Own goals should appear in the preferred order. They are now handled as negative goals which seems to give the desired result. It's possible this has some unintended consequences but I haven't seen any.
  • Three-letter codes are now checked against the FIFA codes in Module:Goalscorers/data/Country_codes and the country name used for sorting (e.g. Spain instead of ESP).

Let me know if you still find descrepancies.   Jts1882 | talk  12:11, 3 January 2019 (UTC)Reply

Wow, looks great! One thing I noticed on the sandbox page is the "No goals matching requested criteria" note seems to be incorrectly displaying? Otherwise the formatting seems perfect. Also, to match Template:Goalscorers, could we add a line at the top to list the number of goals? The module should be able to calculate the number of goals scored per round/group and overall from the data? Here's the general wording in italics:
  • There
  • IF ongoing (defined by user)
    • IF # of goals = 1, THEN has been
      • ELSE have been
    • ELSE IF# of goals = 1, THEN was
      • ELSE were
  • # of goals
  • IF # of goals = 1, THEN goal
    • ELSE goals
  • scored in
  • # of matches (defined by user)
  • IF # of matches = 1, THEN match
    • ELSE matches
  • , for an average of
  • average (# of goals / # of matches, round 2)
  • IF average = 1, THEN goal
    • ELSE goals
  • per match
S.A. Julio (talk) 08:24, 4 January 2019 (UTC)Reply
I think the "No goals matching requested criteria" is mainly showing up when there are no own goals. It was put there more to test the logic and should be commented out. Perhaps there should be an erroer messeage when there are no goals in a selection.
It should be easy to count the total goals in a selection and prepend a note before the list. However, the average would also need to get the number of games somehow.   Jts1882 | talk  09:12, 4 January 2019 (UTC)Reply
Yeah, the number of matches played could be defined on the data page, i.e. data.matches = { group_A = 4, group_B = 10, ... }. S.A. Julio (talk) 10:32, 4 January 2019 (UTC)Reply
I've added something using the template parameterss following the logic of {{Goalscorers}}. It does make sense that the data is included on the data page, so all updates are in one place. The date can also be added while a tournament is ongoing. If there is an update date and completion date, the module can work out the ongoing parameter.
I used the number of matches from the Euro 2016 qualifying page, but noticed that the goal totals don't match up, 694 from data module versus 700 in the infobox.   Jts1882 | talk  12:32, 4 January 2019 (UTC)Reply
I now realise these missing goals were those in the 3-0 wins awarded to Albania and Russia after crowd trouble. How should this be handled? It seems wrong to include them in the goals scored and average.   Jts1882 | talk  17:06, 4 January 2019 (UTC)Reply
I agree, while awarded results count as "goals for" a team in the standings, they are not actual "goals scored" by the team, and should be left out of the calculation. Later I'll go through the infoboxes and correct any of these mistakes. Also sounds like a good idea with the date, I've adjusted the module so if the date is set to "complete", past tense will be used, otherwise the present tense will be used along with an "as of" note. Only issue is that this will use the present tense/display the date for rounds which are already finished, could there be a way to define the updated date per group/round? One other thing is could trailing zeros (and decimal point, if applicable) be removed if unnecessary? And if the average is 1 goal/match, could the wording be changed to the singular "goal"? See Template:Goalscorers/sandbox2#Test competition as an example. Thanks, S.A. Julio (talk) 19:26, 4 January 2019 (UTC)Reply

Averages and match number

edit

It seems the averages are rounding incorrectly, for example Template:Goalscorers/sandbox2#All, which should be 2.59, not 2.6. S.A. Julio (talk) 02:43, 6 January 2019 (UTC)Reply

Strange. There is a difference between %.2f (2.59) and %.2g (2.6). Using %0.3g gives 2.59. However that gives 0.999 if the matches is changed to 695 and 10.7 for 65 marches. So %g is giving significant digits rather than precision. There must be a simple way of showing precision of two without trailing zeros. I've changed it for now to allow testing.   Jts1882 | talk  09:29, 6 January 2019 (UTC)Reply
@Jts1882: Hmm, strange. So for storing the matches/updated info on the data pages, should something like data.matches = { prequalifying = 20, group-A = 10, group-B = 15, playoffs = 5 } and data.updated= { prequalifying = "complete", group-A = "2 January 2019", group-B = "4 January 2019", playoffs = "7 January 2019" } be implemented? S.A. Julio (talk) 12:04, 7 January 2019 (UTC)Reply
It seems the lack option to drop trailing zeroes with %f is an old issue going back to C days. I think the version I have using %g will work. If the average is over 10 it will still give three significant digits.
Getting the match number needs some thought. It needs to sum them for the all rounds or all groups options, while the number of rounds and groups is flexible. So perhaps data.matches = { prequalifying = 20, groups = {A = 10, B = 15, ... }, playoffs = 5 } would be better as then we can iterate throught the tables. In terms of keeping it updated might it be clearer to pair the matches to keep the number of matches and the update date in one place.
 
      data.updated = { -- round            group    matches  update date 
                          prequalifying =         {   20,   "complete"       },
                          groups =          { A = {   10,   "2 January 2019" },
                                              B = {   15,   "4 January 2019" },
                                              ...
                                             },
                          playoffs =              {    5,   "7 January 2019" }
                         }
                                           
What do you think? Is this too complicated?   Jts1882 | talk  13:37, 7 January 2019 (UTC)Reply
Looks good to me! S.A. Julio (talk) 14:01, 7 January 2019 (UTC)Reply
I've now added the data.updated using this format to Module:Goalscorers/data/UEFA Euro 2016 qualifying. S.A. Julio (talk) 06:24, 9 January 2019 (UTC)Reply
I've written a function to retrieve the match number and update date. The match number seems to work, but the update date needs some more handling. If all rounds or groups are shown, it needs the last date, which means the dates need comparing somehow. It might be better to give the date in parts (year, month, day). Or there might be a template that can be used.   Jts1882 | talk  10:03, 9 January 2019 (UTC)Reply
@Jts1882: What if the date was given YMD, i.e. playoffs = { 5, "2019-01-07" }? And then for the wording ('as of DATE') the module could convert it to DMY (and option switch to MDY)? S.A. Julio (talk) 11:49, 9 January 2019 (UTC)Reply
Good idea, that makes getting the latest date easier. Nice find with the date module.   Jts1882 | talk  12:06, 9 January 2019 (UTC)Reply
@Jts1882: Alright, so I believe the date of last update for overall, along with an option to change to MDY, need to be added. Also, for the sorting, would there be a way to have a list of common special characters which would be "sanitised", i.e. ü → u, é → e, ž → z? S.A. Julio (talk) 12:04, 10 January 2019 (UTC)Reply
I suppose for sorting all we need is a table with pairs of letters, the actual character and how it should be treated in the sorting, either as { { "ü", "u" } , {"é", "e"} ... } or { u= "ü", e="é", ... }, and just iterate through the list. I suppose technically it should be { "ü", "ue" } . Another possibility is similar pairs for van, de and other parts of names, { { " van ", " van " } , {" de ", " de "} ... } , although searching on the second name solves most of these.
Alright, I think for sorting purposes 'ü' is converted to 'u' (not 'ue'). And I could draw up a list when necessary, just let me know where to place it. S.A. Julio (talk) 12:42, 11 January 2019 (UTC)Reply
Added code for the character substitutions using a table created locally (lines 298-300). This can be extended by adding more pairs. Tested on Mtller, Müller, Mvller in test competition data.
I've also added code for getting latest date for selected rounds/groups. I think it works, but it could do with further testing.   Jts1882 | talk  13:42, 11 January 2019 (UTC)Reply
I've moved the testcase examples in the no include sections to separate subpages: {{Goalscorers/testcases}} for Euro 2016 qualifying and {{Goalscorers/testcases2}} for the test competition. These are then transcluded from {{Goalscorers/sandbox}} and {{Goalscorers/sandbox2}}, respectively.   Jts1882 | talk  14:21, 11 January 2019 (UTC)Reply

Special characters

edit

Alright, great! For the special characters, do uppercase and lowercase need to be added separately to the table, i.e. 'Ü' and 'ü', or would just 'ü' suffice? And a few other questions for sorting:

  1. Letter case: You mentioned this is ignored, correct? So "Jack McDonnell" is treated the same as "Jack Mcdonnell"?
  2. Spaces: How are these treated? Would "John Smith DanielWilliams" come after "John Smith" and before "John Smithson"?
  3. Apostrophes: Are these ignored? Would "John O'Keeffe" be treated the same as "John Okeeffe"?
  4. Hyphens: Are these ignored? Would "Christopher Antwi-Adjei" be treated the same as "Christopher Antwi Adjei"?
  5. Full stops: Are these ignored? Would "George J. Williams" be treated the same as "George J Williams"?

Thanks, S.A. Julio (talk) 09:48, 12 January 2019 (UTC)Reply

  1. At the moment the special character conversion is done before the lower case conversion. If this is reversed there would be no need to specify 'Ü' and 'ü'. This makes sense and should be done. Your example raises the question of where "Jack McDonnell" would come. I think traditionally it should be before "Jack Maddox although sometimes "Mc" is treated as "Mac" to group them together.
  2. Spaces are important as they are the basis for the word split. The name is broken by spaces and then reconstructed as "second third etc, first". Would "secondthirdetc, first" be better? I think "John Smith Daniel" would be between "John Smith" and "John Smithson" with or without the space.
  3. Apostrophies and other punctuation in names are sorted according to their character codes. "John O'Keeffe" would be treated differently from "John Okeeffe". I think "John O'Keeffe" would be before "John OaKeeffe". This is what I would expect.
  4. Likewise for hyphens. Space would appear before hyphen but before all letter characters. So "Christopher Antwi Adjei" before "Christopher Antwi-Adjei" before "Christopher AntwiAdjei". Should this be changed? At the moment "John Smith-Zzz" would be before "John Smithson".
  5. Likewise, fullstops are part of the search order. "George J Williams" before "George J. Williams" before "George Jack Williams". This is also what I would expect.
Comments?   Jts1882 | talk  10:44, 12 January 2019 (UTC)Reply
Alright. For #2, maybe "John Smith Williams" would be a better example. Looking at Alphabetical order#Treatment of multiword strings, I'd think the first approach would make most sense? And I was unsure about hyphens, but looking at the defaultsort key of some articles (e.g. Karl-Heinz Rummenigge), hyphens seem to be left in. The rest seems fine to me, just wanted to fully understand how the sorting currently works. And regarding the special character conversion, it would just need to be moved below what is currently on line 305? S.A. Julio (talk) 11:33, 12 January 2019 (UTC)Reply
@Jts1882: The special characters seem to be case sensitive, looking at Turkey's 1 goal scorers, "Hakan Çalhanoğlu" appears below "Bilal Kısa" currently. Adding the uppercase "Ç" to the character table seemed to correct the order. Will uppercase and lowercase need to be defined? S.A. Julio (talk) 16:25, 14 January 2019 (UTC)Reply
I switch the lowercase function to the unicode one. That seems to work.   Jts1882 | talk  16:46, 14 January 2019 (UTC)Reply

Close to completion

edit

Thanks, the sorting looks great and the output for Euro 2016 is now an exact match. I've now updated the Euro articles to use the module. This module seems nearly perfect, I thought I'd list the final few thoughts I had in order to 'fine-tune' the module:

  • 1. "Final tournament" function: Currently, {{Goalscorers}} is used on a variety of "final tournament" articles, i.e. 2019 AFC Asian Cup, where goals are not tallied separately by round. For these pages, it would be easier to update the information on the article itself instead of needing to create a dedicated module sub-page for the data. Would it be possible to add a separate "finals" function to the module for this usage? Basically to exactly match how {{Goalscorers}} works so the template itself could be replaced with a call to the module's "finals" function. The template is very simple so I imagine this function could be added to the module? Only difference would be an updated parameter instead of ongoing to change the tense of the wording. Additionally, could the module "count" the number of asterisks used on a page to calculate the number of goals scored automatically?
    • Update (partially done): Can the goals total be calculated by the module based of the number of asterisks? Can it match how 'updated' works in the main function instead of using 'ongoing'? Singular 'goal' and 'match' needs to be added.
  • 2. Modifying for other statistic types: What about a way to use it to tally for other uses, such as assists, clean sheets or another custom statistic? For example see UEFA Euro 2016 statistics. The own goal portion of the module wouldn't need to be used, and I'd think just giving the name would be enough on the data page, i.e. data.statistic = { type = assists }.(then the trailing 's' could be cut off for singular use (i.e. 1 clean sheet), with maybe a backup way to define singular + plural should it be necessary). Ideally this would also work for the aforementioned "final tournament" option.
    • Update (partially done): Can the output text (along with 'further') be disabled for assists/clean sheets, and the blank line be removed?
  • 3. Bold option: Could there be a way to optionally enable a "bold" note (Players highlighted in bold are still active in the competition.) on the data page? Maybe it could be added to data.updated, i.e. playoffs = { 8, "complete", "bold" } to add the bold note to the playoffs article. Then data page would have the relevant players bolded (i.e. {"'''[[Marcel Sabitzer]]'''", "AUT", "G", 1, 0 }), and then the module could trim the apostrophes for rounds which have bold disabled (or alternatively {"[[Marcel Sabitzer]]", "AUT", "G", 1, 0, "bold" })?
    • Update (partially done): Can the bold note display in rounds that have bolded players?
  • 4. MDY dates: Way to convert output of the date from data.updated to MDY format.   Done
  • 5. Flag variants: Way to add flag variants for countries to the relevant template (i.e. {{fbicon}}). Ideally, this wouldn't need to be defined on every line of the country's players, instead maybe data.flagvar = { GRE = "old", ESP = "1945" }?   Done
  • 6. Expanding footer note: I noticed there was a few lines regarding a footer in the module. Could this be expanded to support linking to sub-articles when a minimum is used? This would be displayed in 85% size font, for example see 2018 FIFA World Cup qualification (UEFA)#Top goalscorers, the links are formatted similar to goals in columns. Maybe something like data.footer = { text = "For full lists of goalscorers, see sections in each group:", links = "[[2018 FIFA World Cup qualification – UEFA Group A#Goalscorers|Group A]], [[2018 FIFA World Cup qualification – UEFA Group B#Goalscorers|Group B]], ...", bottom = "XYZ" }? The 'text' and 'links' would only be displayed for the overall goals, while 'bottom' would display on all articles.
  • 7. Group definitions: Not of of major importance, but maybe it would be a bit simpler on the data page if groups were defined separately instead of needing to add it on each line for the players, i.e. data.groups = { A = "ESP, ITA, NED", B = "TUR, NIR, GER", C = ... }.
  • 8. Additional details: If you look at {{Goalscorers}}, there are also the parameters 'further' (additional text following the 'X goals in Y matches' text) and 'extra' (displayed on a new line below), could these possibly be added as template parameters? Also, could there be an option on the data page to define an inline reference immediately following the 'X goals in Y matches' text, this could be useful if a note needs to appended to the text (i.e. regarding awarded matches, void results, etc). Also, below the footer, could there be a way to add a source (similar to {{Goalscorers}}, for example see the bottom of UEFA Euro 2000#Goalscorers).
  • 9. World Cup qualifying: Best way to store goalscorer data across confederations?
  • 10. British Home Championship/Euro qualifiers: UEFA Euro 1968 qualifying Group 8 is a bit interesting, the group combined the results of the 1966–67 British Home Championship and 1967–68 British Home Championship. Was curious if there could be a solution so that the module could output information for the two BHC articles, in addition to the group article and the main qualifying article? Not hugely important, but could be useful.
  • 11. Change sort method for certain countries: Would there be a way to change the sorting for certain countries (stored on the main module page)? For example, China, Chinese Taipei, Myanmar, South Korea, North Korea, Thailand and Vietnam should all have names sorted exactly as written. So maybe the module could deviate from the default sorting when a player is from one of these countries?   Done
It should be sorting on those names. For instance, ESP sorts as Spain. Have you an example where the sorting is wrong?   Jts1882 | talk  15:33, 20 January 2019 (UTC)Reply
Sorry, may have worded that poorly. I meant that the player names use Eastern name order and should be sorted exactly as written, for example Son Heung-min or Wu Lei, I didn't know if the module could automatically switch the sort method if a player is from one of a list of countries. S.A. Julio (talk) 16:03, 20 January 2019 (UTC)Reply
With you now. Now names from certain countries (currently CHN and KOR) will be returned from getPlayerSortName() without changing the word order. I think this does what is required.   Jts1882 | talk  13:53, 22 January 2019 (UTC)Reply
Alright thanks, looks good! S.A. Julio (talk) 15:01, 22 January 2019 (UTC)Reply
  • 12. Player notes: Could there be a way to support notes for players? For example, see 2018 FIFA World Cup qualification (AFC)#Top goalscorers, where certain players have a note ("This player's goal tally includes one or more goals which the player scored in matches that were subsequently forfeited, but which FIFA continues to count in its statistics.") How would you suggest formatting it? Maybe something like {"[[Marcel Sabitzer]]", "AUT", "G", { 1, "forfeit" }, 0, "bold" } for the player, and elsewhere on the data page a place to define notes, i.e. data.playernotes = { group = "upper-alpha", notes = { forfeit = "This player's goal tally includes ...", abandoned = "XYZ" } }?
    • Update (partially done): Maybe designed for specially ref notes in mind? Can external notes sections be supported, and can different note groups be allowed (both with override options through template parameters)? And support for multiple notes for players?
  • 13. Data page without groups: Way so groups are no longer required to be defined?
  • 14. Display goalscorer data of multiple rounds Could there be a way for a page to call the data from multiple rounds? For example, say I added the final tournament goalscorers to Module:Goalscorers/data/1964 European Nations' Cup qualifying, could there be a way to call the goalscorers from only the first three rounds for the qualifying article?

Thoughts? I tried to word these ideas as best as possible, I can clarify anything if necessary. S.A. Julio (talk) 01:34, 15 January 2019 (UTC)Reply

Some quick answers.

  • 1. "Final tournament" function Wouldn't data.rounds = { finals =4 } in the data submodule do the trick? A finals tournament would just need a different subpage from its qualifying.
  • 2. Modifying for other statistic types. It would probably need its own set of functions modelled after p.selectGoalscorers() and p.outputGoalscorers(). The sort function should be reusable with some modification. The owngoals functions can be deleted. If this is only needed for a finals torunament, then one approach might be modelled after data.rounds with data.stats = { goals =4, owngoals = 5, assists = 6, clean_sheets = 7 } with the numbers refering to the column containing the statistic in the player table.
  • 3. Bold option This would best be linked to the players country or would be a lot of work to maintain in the player table (see #7 below).
  • 4. MDY dates. Should be straightforward enough using a template parameter (as in {{FIFA World Rankings}})
Could there be an option to also define this on the data page? S.A. Julio (talk) 14:06, 16 January 2019 (UTC)Reply
There could. My thinking is that Wikipedia policy is that things like date format, British vs Amerian English type, citation style, etc are matters for each individual page. Using a template parameter allows this. However, these pages ares likely to be following the same style so placing it in the module isn't a problem. Perhaps setting it in the module subpage and allowing the template to override the style would be the best approach.   Jts1882 | talk  15:37, 16 January 2019 (UTC)Reply
Agreed, most tournaments will use DMY though occasionally some CONCACAF articles use MDY. Should an article need the other format, the override should suffice. I've also adjusted it so |mdy=no results in DMY format. S.A. Julio (talk) 19:28, 16 January 2019 (UTC)Reply
  • 5. Flag variants. The checking of a flagvar table as you suggest could be added to p.addLinkedIcon().
  • 6. Expanding footer note. I added the empty function as a reminder. I think a template |footer= with footerSentence = g.args['footer'] and some formating would do it. The could be several footer lines if required. I think a template parameter is best as the footer can then be modified depending on the group or round being displayed. The weblink could be substituted as the update date is in {{Sports rankings tableg}}.
  • 7. Group definitions. Again possible. I wonder if a country table with group name and participation status (for bolding players still involved) could be combined. Perhaps the flag icon variants could also go here.
Overall, I think most of this can be done. The mdy dates, footer and flag vaiant can be incorporated simply enough. The others perhaps need a bit of proper pre-planning.   Jts1882 | talk  14:02, 15 January 2019 (UTC)Reply
  • 1. I was hoping for a way to not need a data page for final tournaments all all, instead the relevant goalscorer info would be on the article itself. For example see 2018 UEFA European Under-19 Championship#Goalscorers. The function wouldn't need to do any sorting, just display the info in the parameters. Since the goalscorer info will only be transcluded to one article, having to create a separate data page would make the updating a bit more tedious, and could possibly result in mistakes from less familiar editors/IPs. Hence it might make sense to add a simple function to exactly replicate how {{Goalscorers}} works. This function could also be applied for youth qualifying tournaments which do not have group/round sub-articles, for example 2018 UEFA European Under-19 Championship qualification.
If the current template does what is required, perhaps the solution is to add a parameter like |data=data_module. The template just needs to see if this is set, in which case it invokes the module, otherwise it operates as is using the supplied data. A second template name (e.g. {{Goalscorers/auto}}) is another option.   Jts1882 | talk  17:09, 15 January 2019 (UTC)Reply
See {{Goalscorers/sandbox3}} for version of current template with added data option to use module.   Jts1882 | talk  17:35, 15 January 2019 (UTC)Reply
On second thoughts it shouldn't be difficult to have a function to handle data supplied by the template. See p.list() at the end of the module for a prototype function.   Jts1882 | talk  18:05, 15 January 2019 (UTC)Reply
Alright, I guess I thought it might make sense for the module to fully replace the template. S.A. Julio (talk) 18:09, 15 January 2019 (UTC)Reply
@S.A. Julio: You are right. I wasn't thinking clearly yesterday. There are now two functions: p.useModuleData() and p.useTemplateData(). The main() function checks to see if there is a data module supplied and then calls the appropriate function. The template function should handle assists as well (although I've yet to check this). See {{Goalscorers/sandbox4}} for example.   Jts1882 | talk  10:45, 16 January 2019 (UTC)Reply
That's looking good! I'd be curious to know if there's a way for the module to "count" how many asterisks are on each level in order to automatically calculate the goals total? Then this wouldn't have to be inputted manually by editors, decreasing the number of mistakes. S.A. Julio (talk) 14:03, 16 January 2019 (UTC)Reply
Also, I wasn't sure what 'statNumber' on line 598 was for, does this relate to the output text (X in Y matches) (wasn't sure if 'clean sheets' was supposed to be there as well)? Could the output text (along with 'further') be disabled for assists/clean sheets (if an editor were to accidentally leave the number of goals/matches in the template)? Then any text necessary for assists/own goals could be added using 'extra'. Also, there seems to be a blank line remaining at the top of the own goals/assists output. S.A. Julio (talk) 19:53, 16 January 2019 (UTC)Reply
Could this function also replicate how "updated" works, with the value of the date/'complete' to control the tense (and output the "as of" date) instead of the 'ongoing' parameter? S.A. Julio (talk) 02:14, 20 January 2019 (UTC)Reply
  • 2. Yeah, I don't imagine this would be used outside of final tournament statistic pages, so I'd think this would be connected to #1.
  • 3. Agreed, sounds like a better idea.
  • 4. Sounds good.
  • 5. Alright, would storing the info in data.templates or a potential data.groups be better?
  • 6. A template parameter sounds like a good method.
  • 7. Setting the bold here seems best, how do you think it should be formatted?
Another thing to consider is could the module be implemented for 2022 World Cup qualifying, which begins in June? Since each confederation has a different number of rounds, maybe the data pages should be split by region? Then how would they all be "merged" together, similar to 2018 FIFA World Cup qualification#Top goalscorers? Only UEFA would need to be split by group, the rest of the articles are divided by round (see 2018 outline here). Thanks, S.A. Julio (talk) 16:38, 15 January 2019 (UTC)Reply
I've added the WC qualifying, along with a few more thoughts I had, to the top list (#8 to 10). S.A. Julio (talk) 18:21, 15 January 2019 (UTC)Reply
As explained above, the module now handles data given in the template if no data module is supplied.
8. Additional details. I'll look at adding |further= and |extra=. Should the template parameters be used for both, or, in the case of module data, do you prefer having everything in the module subpage? Yes, a reference option for the goals is a good idea either as an inline reference (supplied in module subpage) or a footer, as in the template.   Jts1882 | talk  10:45, 16 January 2019 (UTC)Reply
I think for flexibility it would probably by easier to have 'further' and 'extra' as template parameters, instead of stored on the data page. However, the inline/footer ref I think are best stored on the data page, as (unlike further/extra) these would likely need to be displayed 'universally' across all groups/rounds. S.A. Julio (talk) 12:58, 16 January 2019 (UTC)Reply
12. Player notes. I've added something using the comment field for the goals, where a note template can be added, e.g. {{efn-ua|name=goals}}. The notes are defined in params.footer{}. Using the comment field for the goals ensures the note is only added for the appropriate round or group. The notes are only displayed in the footer if selected. However, if there are multiple notes, the whole list gets displayed. To only display the relevant notes makes it quite a bit more complicated. If this is to be done, one footnote system probably needs to be selected (e.g. "efn-ua" or "efn-la"). This needs more thought.   Jts1882 | talk  12:03, 18 January 2019 (UTC)Reply
@Jts1882: Alright, maybe there could be an option to also use an external notes section? Many of these articles already have a notes heading at the bottom, so ideally they'd all be grouped together. (Maybe also an option to also override this choice on an article using a template parameter?) Regarding the note type, it might be easiest to have a way for it to be defined on the data page (otherwise using "upper-alpha" as the default), with an option to override it on an article using a template parameter? Supporting multiple notes would probably be best, could the module append the relevant note for each player, i.e. {{refn|group=GROUP|name=NAME|CONTENTS}}? Also, if such a note system were used, could multiple notes be added to a player, i.e. {"[[[Robert Lewandowski]]", "POL", "D", { 13, "goals, awarded"}, 0 }? Thanks, S.A. Julio (talk) 13:26, 18 January 2019 (UTC)Reply
Also, will notes also work for own goal scorers in the future? S.A. Julio (talk) 02:14, 20 January 2019 (UTC)Reply

I've just created Module:Goalscorers/data/1960 European Nations' Cup qualifying, however I can't seem to figure out how to fix the output (currently getting an error). S.A. Julio (talk) 16:32, 18 January 2019 (UTC)Reply

Where are you testing it? One problem with the more complex data is that one syntax error can cause it to fail. I do need to add more error checking at some point.   Jts1882 | talk  16:54, 18 January 2019 (UTC)Reply
Found it. The group table (A= {}) was missing in data.updated (now corrected) and the country and groups are in the wrong order in the goalscorers table. Incidentally, I'm still thinking about how to move the group away from the goalscorer table without needing a major rewrite.   Jts1882 | talk  17:06, 18 January 2019 (UTC)Reply
I've moved the flagvar table and it looks like it is working (e.g. the Greek flag is different).
In answer to your question about the British championships for two years being used as Euro qualifiers, I can think of two approaches. One would use two data submodules and introduce a |data2= parameter. Then just make two calls to selectgoalscorers. Alternatively, one data submodule could handle both years of the British championships and be treated as two groups, i.e. group=year1, group=year2 and group=all (for Euros). The latter seems simplest.   Jts1882 | talk  17:45, 18 January 2019 (UTC)Reply
Alright, thanks for the fix, looks good with the flags now. And I agree, it would make it simpler for other competitions if the group didn't have to be defined. For the 2018 World Cup qualifying, only UEFA had sub-articles divided by group, with the other confederations being divided by round. And the latter option for the BHC sounds ideal, I'll create Module:Goalscorers/data/UEFA Euro 1968 qualifying soon here to test it with. Another thing I've noticed is the past tense is no longer being used, for example Template:Goalscorers/testcases, where all the rounds are set as 'complete' but the present tense is displaying. S.A. Julio (talk) 19:25, 18 January 2019 (UTC)Reply
Now created. I wasn't sure how to format the group 8 players, so for now I just separated the goals in brackets. I also had to prefix the group numbers with 'G' because using just the number seemed to cause an error in data.updated, would there be a way for this to not be necessary? S.A. Julio (talk) 02:14, 20 January 2019 (UTC)Reply
The group name expects a string so define as ["1"] = { matches, date } and set the group in the player list as "1". I've made the changes.
I think the update dates are now being sorted correctly so the tenses are correct.
My suggestion for the BHC doesn't work when with the rest of the groups. The way you bracket the goals could work, but it interfers with the comment code used for the footnotes. Using two groups and trying to sum them adds complications. I can't see how to do this without a major change to the data structure. Would this ever be needed elsewhere?   Jts1882 | talk  10:12, 20 January 2019 (UTC)Reply
It's an unusual case, so I doubt it would need to be used elsewhere. Maybe instead, for their number of group goals the first BHC statistics could be added, while a new round could be added for the second BHC (for all other players this will be '0') (see this edit). Would it be possible to combine these two different rounds? S.A. Julio (talk) 11:02, 20 January 2019 (UTC)Reply
Not easily. It adds too much overhead for an unusual situation. I think the goals for the two BHC should be combined into group 8. I not even clear why this would be that useful. The articles on EC qualifying wouldn't list the goalscorers for the two rounds of the BHC separately and the BHC articles don't list goal scorers. It would be easier to add them using the template parameters than rewriting the module to handle such an usual situation.   Jts1882 | talk  11:42, 20 January 2019 (UTC)Reply
Alright, I guess I was thinking there could be a 'round2' parameter, i.e. {{Goalscorers|UEFA Euro 1968 qualifying|round=group|group=8|round2=BHC}} to combine 'Group 8' + 'BHC'. Though if it's too complex that's fine, this is not very important. S.A. Julio (talk) 12:21, 20 January 2019 (UTC)Reply

Also, I've noticed at Template:Goalscorers/testcases#UEFA Euro 1976 qualifying, "François Van der Elst" is displayed below "Wilfried Van Moer". Is this a sorting issue with the handling of letter case? S.A. Julio (talk) 07:01, 22 January 2019 (UTC)Reply

And for the 'X goals in Y matches' text, could a comma be added if the number of goals/matches is four digits? S.A. Julio (talk) 07:38, 22 January 2019 (UTC)Reply
The number can be formated with mw.language:formatNum( n, options ). Just need to work out the options.   Done
That does look like a case issue (M < d) but I can't see why p.preprocessSortName() isn't handling it.
  Fixed No it was not an issue with the case. There was a problem with the logic of the sort name. The last name was not being added so "François Van der Elst" was being sorted as "van der, francois" and "Wilfried Van Moer" as "van, wilfried".   Jts1882 | talk  10:08, 22 January 2019 (UTC)Reply
One other issue I've been thinking about is handling bold for active players. I suggest a simple table of active countries in form data.active_countries = {"SWE","UKR","IRL"} . This would only be needed for new coompetitions and can just be omitted from completed countries.   Done
  Jts1882 | talk  08:40, 22 January 2019 (UTC)Reply
Great, thanks! I noticed on Template:Goalscorers/testcases2 that player comments and the '(against X)' text for own goal scorers also gets bolded, could this be adjusted? Also, could bold be disabled for rounds which are set to 'complete'? Then I guess only the bold note would then need to be added. (Players highlighted in bold are still active in the competition.) S.A. Julio (talk) 13:27, 22 January 2019 (UTC)Reply
Only the name is bolded now (see Robbie Keane).
It could check the rounds for completion, but that doesn't tell us if the country/player is still involved or has been eliminated. It could check that the competition is completed but it's easy to delete or empty the still active table.   Jts1882 | talk  14:16, 22 January 2019 (UTC)Reply
Yeah, I just wanted to avoid having players who are still active be bolded in completed rounds (like 'prequalifying'), looks good now. S.A. Julio (talk) 15:01, 22 January 2019 (UTC)Reply

Also good news, I've now finished the data pages for all the previous 15 Euro qualifying tournaments. Is it ready for further mainspace use? S.A. Julio (talk) 12:38, 25 January 2019 (UTC)Reply

You are best placed to answer that question. I think I have dealt with most of the issues above and it is a behaving as expected. Separating the groups from the goalscorer table is one change that I keep putting off. The table is so integrated with the way the goalscorers are selected that I'm hesitant to change it too much, especially now you have entered the data.
If you are starting to use it in mainspace then we should start using a sandbox version for changes to the module. One advantage of a slow roll out is that you should catch any problems as you make the changes.   Jts1882 | talk  13:06, 25 January 2019 (UTC)Reply
Oops, I've just noticed that you have been annotating the issues above and I've missed some of them. I'll have to get back to you on those later.   Jts1882 | talk  13:10, 25 January 2019 (UTC)Reply
Alright, I may starting updating the Euro articles to call it now. Then hopefully soon Template:Goalscorers can be updated to call the module instead. Also, regarding changes to the table, the difficult part was getting/structuring the scoring information from the articles, now that I've compiled the data it should be fairly easy to re-format it if necessary. S.A. Julio (talk) 13:49, 25 January 2019 (UTC)Reply

The group table feature added looks great, would this mean 1960 and 1964 no longer need to have a group defined? Also, regarding the bold note, the only issue is that bold is not used until at least one team has finished playing all their matches, therefore the note shouldn't display when all teams are still active. Would there be a way to have this display only when there are bolded players? Or maybe the note could be manually set to display on the data page? S.A. Julio (talk) 07:56, 28 January 2019 (UTC)Reply

New issues

edit

@Jts1882: So now that the module can retrieve groups from the table, such as you did here, is it possible to remove the group column altogether? I tried to do so here, though while it displayed correctly on the group article (UEFA Euro 2020 qualifying Group I#Goalscorers), it did not display correctly on the main article (UEFA Euro 2020 qualifying#Goalscorers). S.A. Julio (talk) 17:38, 21 March 2019 (UTC)Reply

Yes, it should be possible to remove that column, assuming I have the code correct. Am I missing something, what is wrong with the display in the main article?   Jts1882 | talk  17:45, 21 March 2019 (UTC)Reply
Jts1882, when I remove the column, the main article says "There have been 0 goals scored in 1 match, for an average of 0 goals per match (as of 21 March 2019).No goals matching requested criteria." However the group article displays normally as expected. S.A. Julio (talk) 18:04, 21 March 2019 (UTC)Reply
OK, I'll look at this later. It might be something simple like me leaving a hard coded column for the groups in one of the conditional loops that select the games for the whole competition.   Jts1882 | talk  18:08, 21 March 2019 (UTC)Reply
Have a look at line 249. I think code i = 4 should be i = goalsCol. I have to go now so can't check it, but will try tomorrow.   Jts1882 | talk  18:14, 21 March 2019 (UTC)Reply
S.A. Julio I've updated the module so "all" doesn't assume column four for the first round. I've also removed the group column for the Euro 2020 qualifying. I've checked the testcases and the 2016 qualifying and all seems well. You might want to check some earlier ones just to be sure.   Jts1882 | talk  09:04, 22 March 2019 (UTC)Reply

@Jts1882: Would it be possible to add an optional prefix to the update date? For example, when there are multiple matches in a day, the text "as of 11 June 2019" might want to be changed to "as of 1 match played on 11 June 2019" or "as of OFC matches played on 11 June 2019" until all the matches in the day are completed, when the normal wording can then be used. Maybe this could optionally be added using another set of brackets, for example playoffs = { 3, {"2019-06-11", "2 matches"} }? S.A. Julio (talk) 12:27, 11 June 2019 (UTC)Reply

It is nearly always possible but that section with the update dates is getting complicated and I'm struggling to follow the code after time since writing it. I think we should avoid further complication. However, if you add a time to the update date as I have in Module:Goalscorers/data/UEFA Euro 2020 qualifying it does display the time in the introductory statement of the goalscorers section in UEFA_Euro_2020_qualifying. Would this do?   Jts1882 | talk  13:52, 11 June 2019 (UTC)Reply
Seems the module could already do what you wanted. You can use the date format statement in the data module to change the text. I've added a simple version, but you could get what you requested using date_format = 'first match played on %-d %B %Y'. There is more on the date formating in Module:Date.   Jts1882 | talk  14:28, 11 June 2019 (UTC)Reply

Top goalscorers

edit

I seem to have encountered a problem while trying to make Module:Goalscorers/data/2022 FIFA World Cup qualification: it only displays the number of goals scored by the top goalscorers, which is the intended purpose of the section at its related article, 2022 FIFA World Cup qualification. I can't find anything in the code that covers this. If it's not already added, is there a way to modify the code to cover this? Jalen Folf (talk) 17:30, 29 September 2019 (UTC)Reply

@JalenFolf: The module outputs a list of goalscorers from the data subpage for the competition in question. By default it outputs a list of all goalscorers for which there is data. The output can be limited to top goalscorers with |minimum=. In the case of the 2022 FIFA qualification, there is only data for a few players with 3 or more goals, which are all output as |minimum= is not set. If you add |minimum=4 to the invocation call in the article it will only output Fikri.
The {{Goalscorers}} template needs updating to use the module and the documentation updated.   Jts1882 | talk  06:06, 30 September 2019 (UTC)Reply

Bottom text

edit

One feature that was lost from the merging of Template:Goalscorers was the parameter for the bottom text, for example when the scorers are cut off on certain articles such as here. Would it be possible to allow for this in order to link full lists of goalscorers in other articles? Therefore the appearance can be streamlined. S.A. Julio (talk) 20:43, 29 November 2019 (UTC)Reply

The original template had two parameters, but as neither were used in any article I didn't add them to the module version. It's easy enough to add.
The parameters were:
  • |bottom_text=: Heading for the optional bottom information (suggest |footer-heading=)
  • |bottom=: Optional information added below the goalscorers (suggest |footer-text=)
The code was:
  • {{#if:{{{bottom|}}}|{{small|{{{bottom_text}}}}} <div class="div-col columns column-count column-count-3" style="{{column-count|3}}"> {{{bottom}}}</div>|}}{{#if:{{{source|}}}|{{smaller|Source: {{{source}}}}}|}}
Should I just repeat what was used or do something else? I found it strange that the header (and not the text) was shown in small font and don't see the reason for using columns.   Jts1882 | talk  09:06, 30 November 2019 (UTC)Reply
Yeah looks as though I may have had it backwards, I think the heading would go in italics and the individual links would be 85% or 90% font size. S.A. Julio (talk) 11:33, 30 November 2019 (UTC)Reply
I've added something using the old parameters and my suggestions (|footer-heading= and |footer-text=), with the option title in italics and the text at 85%. The code is lines 760-769. Is there an example to test it?   Jts1882 | talk  12:04, 30 November 2019 (UTC)Reply
Great, I've added a quick test here. Could the list be formatted in columns, the same way as the scorers are? Otherwise looks to be perfect. S.A. Julio (talk) 12:36, 30 November 2019 (UTC)Reply
Now I see why you chose those parameter names and wanted columns. I've added the columns for the |footer-text= or |bottom=. I've left the introductory text (|footer-header= or |bottom-text=) unformated to keep it flexible. Just add the desired wikitext with the parameter if you want italics or small.   Jts1882 | talk  13:38, 30 November 2019 (UTC)Reply
Great, thanks! S.A. Julio (talk) 14:06, 30 November 2019 (UTC)Reply
What do you want to do with the names for the parameters. Keeping both is unnecessary and/or confusing. Do you want to keep your original names? Or how about |bottom-text= and |bottom-list=, with the latter being the one using the three columns. The former could then just be used as general footnote, in which case it should be shown independently (rather than only if there is a |bottom=.   Jts1882 | talk  14:40, 30 November 2019 (UTC)Reply

I'd go with your parameter names, given they are more descriptive to their purpose. And I'd be fine with a general footnote parameter to be available as well. I've had another question in my mind recently, is there a way the module could automatically count the number of goals when calling Template:Goalscorers? For example here, instead of manual setting the number of goals, the module would multiply the number of bullet points (4 goals × 1 player, 2 goals × 2 players, 1 goal × 10 players, 1 OG × 1 player → 19 total). Not a huge priority, though it certainly would be useful in updating articles and reducing the number of errors. S.A. Julio (talk) 14:58, 30 November 2019 (UTC)Reply

I've added a count which works for the Euro76 example. I don't know how reliable it is so I've added a warning in edit mode when the count doesn't match the number in the template parameter. This will always be the case if only the top goalscorers are listed.   Jts1882 | talk  16:24, 30 November 2019 (UTC)Reply

Column-count

edit

I have replaced {{column-count}} with "column-count". All Template:Column-count does is prepend the text "column-count:". If your browser is not respecting the value, please report the browser you are using here so we can debug the issue. Thanks! Plastikspork ―Œ(talk) 15:14, 12 January 2021 (UTC)Reply

I was trying to work out why it would fail and couldn't see why. The only complication might be form the classes (div-col columns column-count column-count-3) which might do something different in some browsers, but again I can't see why the change would make a difference. When I wrote this module I copied the formatting from the template rather than looking at what the templates were doing, but removing such templates makes a lot of sense.
Perhaps we should make the column width update now. I tried column-width:25em; and that gave three columns with the same width on my browser. —  Jts1882 | talk  16:13, 12 January 2021 (UTC)Reply
@Jts1882: The column-count template used to do a bit more before this change. Moving to column-width is definitely the way to go, especially for supporting mobile phone/device browsers. We may want to have the option to override the default and/or have a different default width for the "own goal" section, but I think 25em should generally work for most cases. Thanks! Plastikspork ―Œ(talk) 16:48, 12 January 2021 (UTC)Reply
@Plastikspork:. Any idea what classes column-count and column-count-3 do? I don't see anything looking at the output with Inspect Element. —  Jts1882 | talk  16:59, 12 January 2021 (UTC)Reply
@Jts1882: You can find some stuff for "columns" in MediaWiki:Common.css. Note that Div col used to use "columns" before it was switched over to its own "templatestyles". Izno tried to import those updates here but was reverted. If we want to make sure we are always compatible with {{div col}} we could use frame:expandTemplate{ title = 'div col', args = {colwidth = '25em'} } instead of the expanded version. It would only need to be expanded once and then re-used where necessary. Izno may have an opinion as well. Thanks! Plastikspork ―Œ(talk) 17:08, 12 January 2021 (UTC)Reply
So far as I can see about the classes named column-count(-#) (class column-width is around here somewhere also), those were signposts for people who wanted to style things to personal taste if they didn't want a fixed column count (and consistently so across the few templates I've seen, mostly derived either from div col or reflist). I recommend removal and simply using whatever semantic naming you'd use for the element in question. It's something we can look at later if we think it's necessary. I would generally recommend against using div col here in this context since I'm generally not a fan of expanding templates in modules.
I don't recall the exact use case for this template, so other styles may/not be warranted. (From mobile.) --Izno (talk) 17:37, 12 January 2021 (UTC)Reply
@Plastikspork: After the change, column counts are displayed differently on different pages (across browsers). Like for 2021 Africa U-20 Cup of Nations qualification I am being displayed 2 columns (both desktop and mobile) but for 2018 AFC U-23 Championship I am being displayed a three column count. In both the cases this module is being displayed. What seems to be the problem here?--Anbans 585 (talk) 07:41, 13 January 2021 (UTC)Reply
In 2021 Africa U-20 Cup of Nations qualification the styling includes an extra column-width:30em; that isn't in the pages showing three columns. Disabling this with Inspect Element produces three column display. This CSS is set in .mw-parser-output .div-col (is this from templatestyles?) which is getting set elsewhere on the page. I get three column display in edit preview of the section and two column display in edit preview of the whole page. —  Jts1882 | talk 
The solution seems to be to use column-width:25em; as discussed above. This fixes the page in question, but it might be better to ensure that the code is independent. —  Jts1882 | talk  09:28, 13 January 2021 (UTC)Reply
So column-width:30em; is set by {{div col/styles.css}} using class div-col. When {{div col}} was used earlier in the article this was setting column-width:30em;. The relevant CSS is set using class column in MediaWiki:Common.css. The templatestyles {{div col/styles.css}} replicates these settings and adds the default 30em width and a couple of other classes (small, rules) which are not used here. So I think all it needs is to use class column and remove div-col and column-count column-count-3. While this seems the way forward, I'm still puzzled why setting column-count directly or by expanding the template gave different results on 2021 Africa U-20 Cup of Nations qualification as the templatestyles addition is there in both cases. —  Jts1882 | talk  12:33, 13 January 2021 (UTC)Reply

Wording when using {{Goalscorers}}

edit

@Jts1882: I noticed a few issues with the "X goals in Y matches" wording for {{Goalscorers}}, though I am unsure of where to fix it. Would the following issues be possible to resolve? Thanks, S.A. Julio (talk) 16:07, 19 January 2021 (UTC)Reply

  • When number of goals is 1 "There were 1 goals scored in X match" → There was 1 goal scored in X matches
  • When number of goals is 0 "There were 0 goals scored in X match" → There were 0 goals scored in X matches
  • When number of matches is 1 "There were X goals scored in 1 matches" → There were X goals scored in 1 match
  • When goal average is 1 "for an average of 1 goals per match" → for an average of 1 goal per match
Can you give me an example of where the problem is found? At the moment this is set in two different places, depending on whether it is using data placed in a module subpage (in function p.addIntroductorySentence(), line 85) or whether the data is placed in template parameters (in which case everything is in function p.useTemplateData(), line 683). Ideally both would use the function (on the TODO list), but it is easier to fix specific cases for now. —  Jts1882 | talk  16:22, 19 January 2021 (UTC)Reply
@Jts1882: Sorry if I was not clear, I was referring to when the data is included in the template parameters. I have left a few examples below. Thanks, S.A. Julio (talk) 17:46, 19 January 2021 (UTC)Reply

There was 1 goal scored in 2 matches, for an average of 0.5 goals per match.

1 goal


There were 2 goals scored in 1 match, for an average of 2 goals per match.

2 goals


There were 15 goals scored in 5 matches, for an average of 3 goals per match.

5 goals

@S.A. Julio: It should be fine now. The plurals for goal(s) and match(es) were incomplete and garbled. Multiple goals were setting the plural on matches (which was nearly always OK) and goals left plural. —  Jts1882 | talk  08:29, 20 January 2021 (UTC)Reply
@Jts1882: Great, thanks! I noticed however when the goal average is 1, the wording still uses the plural form (see above), could this be changed to singular? Thanks, S.A. Julio (talk) 15:42, 20 January 2021 (UTC)Reply
  Done —  Jts1882 | talk  18:07, 20 January 2021 (UTC)Reply
Great, thank you! Separate from this, but is there a way that if the |goals= parameter in not set, the goals could be calculated automatically? I noticed already that in preview, there is a warning to note if there is a "mismatch between number of goals listed (_) and goals parameter (_)". I think this would be a useful addition, then only the number of matches would need updating. S.A. Julio (talk) 12:20, 21 January 2021 (UTC)Reply
Pinging @Jts1882: if you had missed the last reply. Also, I noticed there is a spacing issue if the goals/matches text is not displayed, for example at 1999 FIFA Women's World Cup#Goalscorers, is this possible to fix? Another question, would it be possible to optionally output the list of goalscorers from the module data page into a wikitable (with a set goals limit)? For example, I had wanted to output the data from Module:Goalscorers/data/2020–21 UEFA Nations League in wikitables to the Nations League main article, similar to the tables in the previous season. Thanks, S.A. Julio (talk) 22:07, 7 February 2021 (UTC)Reply
Apologies for not replying. I did see but didn't had time to look into it at the time and then forgot.
  • The mismatch will also occur when only the top scorers are listed (e.g. the last example with Muller where I've changed the goals). So it would need an extra parameter to indicate it is an incomplete listing (e.g. |others=yes. I also think requiring the goals helps maintain accuracy. The goals and players could get updated partially, as when people update their favourite players without thinking of the whole tournament, and the warning is not that prominent and easy to miss.
  • The extra new line is a tricky one. A new line is inserted into the wikitext output after the introductory test so the "N goals" starts on a new line. I can't see where the extra newline is earlier. I will have to look into this further later.
  • An optional alternative output as a table is a good idea. In principle it just needs putting in a table rather than a series of bulleted lists. The tricky bit will be getting the rowspans right.
I will try and look at this later today and see what is entailed. It may have to wait if the changes are too involved. —  Jts1882 | talk  09:05, 8 February 2021 (UTC)Reply
You are probably right regarding the goals scored, probably better to require the parameter to help ensure the information is kept accurate. S.A. Julio (talk) 14:37, 8 February 2021 (UTC)Reply

Tabulated top goalscorers

edit

There were 396 goals scored in 172 matches, for an average of 2.3 goals per match.

Rank Player Goals
Top Scorers
1   Ferran Torres 8
2   Romelu Lukaku 7
3   Kylian Mbappé 6
  Erling Haaland
5   Eran Zahavi 5
6 10 players 4

This table is to test the tabulated version. Is this what is wanted? —  Jts1882 | talk  10:41, 8 February 2021 (UTC)Reply

@Jts1882: That looks great! Though the paragraph tags seem to add spacing to the rows, could this be removed? Also, would it be possible to have the rank and goal columns centered, and to removal the equal sign? Thanks, S.A. Julio (talk) 14:46, 8 February 2021 (UTC)Reply
I hadn't noticed the extra p tags. The Wikimeda parser added them to an unnecessary newline. I've centred the rank and goals columns by making them table headers (as in the example you linked to). I can centre them without the header background if you prefer. I would argue in favour of the equals signs on the grounds that second and equal second are not equivalent, but I'll change it if you insist. —  Jts1882 | talk  15:17, 8 February 2021 (UTC)Reply
The only reason I mention that is because typically there's nothing used to differentiate if players are tied on goals, for example on the Premier League and UEFA Champions League pages, and I would prefer to remain consistent across articles. S.A. Julio (talk) 16:31, 8 February 2021 (UTC)Reply
I would say that the other articles should be changed for consistency. Anyway, you are the one who does the work on article content so it's your call and I've removed it. —  Jts1882 | talk  18:07, 8 February 2021 (UTC)Reply
Alright, maybe that can be discussed at WT:FOOTY sometime. Is the table feature ready to be implemented in the main module? S.A. Julio (talk) 20:53, 8 February 2021 (UTC)Reply
@Jts1882: Can the sandbox code be copied to the module now? Or is it not ready? S.A. Julio (talk) 19:06, 17 February 2021 (UTC)Reply
Apologies for not answering. The new option shouldn't affect any current use so it can be copied safely. I'll do it tomorrow unless you do it first. —  Jts1882 | talk  20:57, 17 February 2021 (UTC)Reply
  Done (belatedly) —  Jts1882 | talk  12:33, 18 February 2021 (UTC)Reply

Option for goalscorers from one group in all rounds

edit

@Jts1882: Hello, I was wondering if it would be possible to list the goalscorers from across all rounds, but only by teams of a specific group? For example, if I wanted to list the top scorers of qualifying (both group and playoffs) for Module:Goalscorers/data/UEFA Euro 2016 qualifying, but only for teams from Group C. Any help would be greatly appreciated. Cheers, S.A. Julio (talk) 14:58, 6 October 2021 (UTC)Reply

It probably is by adding an option to p.selectGoalscorers() and modifing the code in round=all to include some from round=group. I'm reluctant to attempt this because its a while since I modified this code and would be afraid of unexpected consequences. I'll try and have a look later and see if an option can be added safely. Why do you want this information, it seems an odd statistic? —  Jts1882 | talk  16:20, 6 October 2021 (UTC)Reply
I think the sandbox version at Module:Goalscorers/sandbox does what you want. See testcases. The group goalscorers without playoffs is above. The goals and total matches seem correct, but I can't verify what would happen with the update dates for an incomplete tournament. —  Jts1882 | talk  10:44, 7 October 2021 (UTC)Reply

Gap at the top of the list

edit

there is an unexpected gap at the top of the list in 2006 FIFA World Cup statistics#Goalscorers. I attempted to fix this, but was reverted. Frietjes (talk) 18:49, 14 December 2022 (UTC)Reply

I've removed the linebreak before the section (this edit). —  Jts1882 | talk  19:15, 14 December 2022 (UTC)Reply
Jts1882, great but that doesn't fix the spurious newlines, which are being included via WP:LST. there are many others with the same problem. if you use Special:ExpandTemplates you will see the problem. we should prevent the module from adding extra newlines at the top. changing line 935 from local output = "\n" to local output = "" also fixes the problem, as demonstrated here. Frietjes (talk) 20:14, 14 December 2022 (UTC)Reply
I figured out a fix, now in Module:Goalscorers/sandbox. Frietjes (talk) 20:22, 14 December 2022 (UTC)Reply

Comma in numbers >= 1,000

edit

Would it be possible to add a comma to 4+ digit numbers when presenting the total number of goals, like is done in infoboxes? Thus changing, for example, the first line of 2002 FIFA World Cup qualification#Top goalscorers from "There were 2452 goals scored..." to "There were 2,452 goals scored..." Wburrow (talk) 15:38, 27 April 2024 (UTC)Reply

This was done earlier for the module data version, but not for numbers given in template parameters. Now done.  —  Jts1882 | talk  11:52, 16 October 2024 (UTC)Reply

Table display error

edit

For some reason, the top goalscorers table for League D at the 2024–25 UEFA Nations League is not properly displaying, but the full list is being properly displayed at 2024–25 UEFA Nations League D#Goalscorers. The tables for League A, League B and League C are properly displayed, though. — Jkudlick ⚓ (talk) 19:01, 15 October 2024 (UTC)Reply

Bad argument to formatNum

edit

Some recent changes have led to "Lua error: bad argument #1 to 'formatNum' (number expected, got nil)" in several articles. I have only looked at a couple of these but it appears that use of assists=yes causes Module:Goalscorers#L-900 to give an error. I don't know what should be done but could offer some opinions on giving a more helpful error message if assists should be a number. I think these need fixing, and maybe some more from here.

Johnuniq (talk) 02:35, 27 October 2024 (UTC)Reply

I think it is fixed now. That particular variable is only used with goals (which is a number).  —  Jts1882 | talk  09:16, 27 October 2024 (UTC)Reply