Module talk:SportsRankings

Updating data
Hi Jts1882, Just wondering if there's any protocol or consensus already in place for updating all the ranking data? I see that the November rankings were released, but the Module:SportsRankings/data/FIFA World Rankings page still has the data from October. Is this something that you'll be maintaining as author of the module data? Or is there a quick way to pull the data from FIFA (etc) and repopulate the data so that someone else can do it if they notice its out of date? -- Phil k84  12:07, 4 December 2018 (UTC)
 * I hadn't really thought about it. I can do it, but the the more people who can make the updates the better. Do you want to volunteer and I'll talk you through it?
 * I have an Excel file where I copy the data and use a formula to generate the appropriate lines. If the rank is in column A, teams in column B, ... points in colume E, then this formula should work:

=CONCAT("         {  '", B11, "',  ",A11,",  ",E11,", ",LEFT(C11,FIND("(",C11)-1)," },  ")
 * Then it just needs copying into the rankings section of the data. The name in the Ivory Coast entry also needs to be change to { "Côte d'Ivoire",  xx,  x, xxxx }, as unfortunately Excel only allows double quotes in strings.
 * If you don't have time, let me know and I'll make the changes.  Jts1882 &#124; talk 12:38, 4 December 2018 (UTC)
 * I don't have time at the moment (end of year deadlines in 'the real world'), but it could be something I can look into sporadically next year. How do you get the data into Excel? Does FIFA give an export somewhere? -- Phil k84 [[Image:circle-icons-chat.svg|16px |link=User Talk:Philk84 |alt=Talk |Talk]] [[Image:circle-icons-compose.svg|16px |link=Special:Contributions/Philk84 |alt=Contributions|Contributions]] 12:50, 4 December 2018 (UTC)
 * I just copy and paste table from their rankings page. I'll make the changes. I note they have changed the format of the table so it will need a different formula.  Jts1882 &#124; talk 12:54, 4 December 2018 (UTC)
 * Not sure if it would help, but as a starting point I made a quick JavaScript function that you could use, rather than having to copy everything to Excel: https://jsfiddle.net/yux387b2/ copy the JS, open the console on the FIFA page (F12 in Chrome) and paste the JS and run it (enter). It will then output the table in a similar format to what you need for the data. Next time I find some spare time, I'll try to make it grab all pages rather than just the one you're on, as at the moment you'd need to combine 5 sets of console outputs into one. I can also see about a code version of the list (FRA instead of France etc). Assuming this would be helpful? -- Phil k84 [[Image:circle-icons-chat.svg|16px |link=User Talk:Philk84 |alt=Talk |Talk]] [[Image:circle-icons-compose.svg|16px |link=Special:Contributions/Philk84 |alt=Contributions|Contributions]] 13:12, 4 December 2018 (UTC)
 * Very useful. I didn't even know that was possible. You can also change your code to put the countries in double quotes and that allows "Côte d'Ivoire".
 * The data module has a table of country names and codes, which is used for aliases when country code is used in  (Output:


 * ), although having it in the same data table might be useful in future.  Jts1882 &#124; talk 14:04, 4 December 2018 (UTC)
 * Try https://jsfiddle.net/philipbkemp/sorhxqg2/2/. You'll need to copy the JS into the console, then type, change page, type   again (repeating until you've called pullData on each page). Then, use   to get all data, in both formats, displayed in the console output. I tried to get it to paginate automatically, but it's a bit tricky as the next page data only comes at a random time later. Hopefully this should be enough for now and you can copy/paste the output into the data file. Can you take a look and let me know if this sufficient? When I find a few spare minutes here and there, I'll see about making scripts for similar Sports Rankings datasets. -- Phil k84 [[Image:circle-icons-chat.svg|16px |link=User Talk:Philk84 |alt=Talk |Talk]] [[Image:circle-icons-compose.svg|16px |link=Special:Contributions/Philk84 |alt=Contributions|Contributions]] 10:08, 5 December 2018 (UTC)

Is the SportsRankings module it ready?
Would this module be ready to implement for Elo and FIFA men/women rankings? And would the module be called through the existing templates (i.e. FIFA World Rankings)? Also with FIFA's new ranking page design, new teams in the FIFA women's rankings have an incorrect movement number (their movement listed is the negative value of their position), so I added new entry for newly listed teams, could this be added to the module? Thanks, S.A. Julio (talk) 11:44, 10 December 2018 (UTC)
 * I think so. The tests I have done seem to work as expected and emulate the existing template (see FIFA World Rankings/sandbox). The module also has the option to create lists of the rankings (see Sports rankings table). Whether it replaces the FIFA World Rankings template or uses its own generic template would be a matter for consensus. Having one place to update rankings would make life easier. User:Philk84 has some clever javascript code (see above) that can get the FIFA rankings off their page in the right format.
 * I'll look at the new FIFA design. If I understand you correctly, I just need to add a test for the absolute values of the ranking and movement being equal and call your new template. Done. It should work if a newly ranked teams is ranked at 125 with move=-125, (e.g. Bangladesh: )   Jts1882 &#124; talk 13:52, 10 December 2018 (UTC)
 * Alright, great! Only question is why are there two lists on Module:SportsRankings/data/FIFA World Rankings, couldn't the points be included in a singular list? I'd say then it should be converted soon, so the code of FIFA World Rankings/sandbox would just need to be moved to FIFA World Rankings, etc.? Also, could the module be able to output tables tables which match those at the top of FIFA World Rankings and FIFA Women's World Rankings? With maybe an optional image parameter for the men's logo? Not sure about the table on World Football Elo Ratings, it seems a bit complex. (Though the 100 top teams seems excessive, maybe only 20 or 25 are necessary similar to the FIFA pages, could be discussed at the talk page or FOOTY.) S.A. Julio (talk) 20:32, 10 December 2018 (UTC)
 * Aren't there two lists so that people can call the list either by "England" or "ENG"? I could certainly update my JavaScript to be able to combine the two at some point. Would you be able to get the top 20, as on the FIFA (Women's) Working Rankings page with  - although as you can see on the right, this doesn't include the footer bit "*Change from 25 October 2018" or the link to the FIFA page, so it's not identical.. yet. -- Phil k84 [[Image:circle-icons-chat.svg|16px |link=User Talk:Philk84 |alt=Talk |Talk]] [[Image:circle-icons-compose.svg|16px |link=Special:Contributions/Philk84 |alt=Contributions|Contributions]] 08:25, 11 December 2018 (UTC)
 * There is a residual third list in the FIFA data page that I had forgotten about(see edit below). There are two lists used. One contains the rankings (country, rank, move, points), which is the only one that needs updating. The second contains the alias list for the the three-letter code and the country name used on the FIFA page. This would only need changing if FIFA changed the exacr name of the country in the listing.  Jts1882 &#124; talk 08:37, 11 December 2018 (UTC)
 * . The second list (rankings2) is not used. When I added the table with the points I renamed the old one to make it easy to switch back while testing the module. I forgot it was still there.
 * I think FIFA World Rankings/sandbox works from my testing. If you are also satisfied, go ahead and move it.
 * The table output can be customised with a few additions. To match the table at FIFA World Rankings it needs a way to add the logo and footer rows. I think the simplest would be to add two header rows and two footer rows as parameters in the template. These would respectively take the logo, header, the "change from .. " and "full rankings at" rows to match the existing table. I think this is more flexible than adding specific items in the module data page, although that is an option. Thoughts?  Jts1882 &#124; talk 08:29, 11 December 2018 (UTC)
 * Alright, sounds like a good option. Also, does it make a difference if the countries are contained in quotation marks vs. apostrophes? Since Côte d'Ivoire uses quotation marks, couldn't all the countries as well? (In order to prevent any mistakes from unfamiliar editors that update the rankings.) S.A. Julio (talk) 09:19, 11 December 2018 (UTC)
 * The module treats handles single or double quotation marks. It would be better to use double as then Côte d'Ivoire doesn't need the manual edit, but I used an Excel formula to generate the lines and that uses the double quotation marks for the formula. I'm not sure if there is a way to escape them. However, 's script could generate lines with double quotation marks. As you say, for clarity it would be better if all the data modules used double quotationmarks throughout.   Jts1882 &#124; talk 09:29, 11 December 2018 (UTC)

Update
Update. I've added the header and footer rows (it can take 5 of each). It uses keywords as shown in the example (code below, output right) to insert dates and references. I've added an extra table to the data module for the previous date.

I think this now replicates the table in FIFA World Rankings. Any other thoughts on any additions?  Jts1882 &#124; talk 10:16, 11 December 2018 (UTC)


 * Looks great! Also, is it possible for the module to populate a tracking category (i.e. Category:Pages using SportsRankings with unknown parameters) for articles which call an invalid country name/code? The names used on FIFA and Elo sites have changed since I began working on this in October, and are likely to change again. A tracking category would be helpful to catch any name adjustments. S.A. Julio (talk) 10:56, 11 December 2018 (UTC)
 * Done. Do you want one category or separate ones for mismatched three-letter code and country name with no ranking? At the moment the one category is set at lines 100 or 112 in module code. The bad examples can be seen in Template:FIFA_World_Rankings/sandbox. Also what should the output be? Should an error message be produced or just the NR text as now?  Jts1882 &#124; talk 11:49, 11 December 2018 (UTC)
 * One category probably would be alright, the mistakes on articles should be obvious. Not sure about the output, maybe one of the error messages which display in the edit window, or nothing at all to display? And SportsRankings is now being used for the Elo and FIFA men/women rankings, thanks for creating this module! Only thing is that there seems to be a preceding space when calling the module? For example see the doc page, it seems to format like code because a preceding space? S.A. Julio (talk) 12:19, 11 December 2018 (UTC)
 * Also, I've also updated the doc pages with clearer instructions, feel free to adjust any wording/formula that needs improving. I couldn't figure out your Elo formula, so I left the longer version for now, not sure what's quicker. The instructions for the javascript method could be added also, with the Excel formula as a backup if needed. As a side note, the redesigned page for the women's rankings is strange, Lebanon (#134) is missing, and they list Tanzania under the name "Zanzibar Football Association (ZFA)" (and Zanzibar is not even a FIFA member). S.A. Julio (talk) 13:07, 11 December 2018 (UTC)
 * I had wondered about Zanzibar and why it was there when I put in the new rankings. I saw your change and clearly the movement (125-131) matches Tanzania. That is not an accidental mistake.
 * The Elo formula was only one of two formulas necessary. That one converts the vertical column of data (how it copied) into a table, which then used  (where D14 is rank 1). There was also a problem with the movements using en-dashes for minus signs, so the data needed more fixing. The alias table also needs completing.   Jts1882 &#124; talk 13:56, 11 December 2018 (UTC)
 * I adjusted all the alias definitions based off the exact names used on the FIFA/Elo websites, so that should now be working. I also noticed the en dash difference, I added a substitute function in the formula to change to the correct dashes. There also seems to be a typo, the category being populated is Category:Pages using SportsRankings with unknown parameters), which includes a stray ')'. S.A. Julio (talk) 17:47, 11 December 2018 (UTC)
 * I've fixed the category name.
 * The alias list does two things which are slightly contradictory in a some cases. Initially, it simply converted the three-letter country codes to the country names used by the organisation using the rankings. So when Elo uses "St Vincent/Gren" or "Bosnia/Herzegovina" these are the names used in the rankings and alias table definitions. This was to make updating the rankings easier.
 * A few "countries" in the Elo rankings don't have three-letter codes (Northern Cyprus, Tibet, Kurdistan), which meant they failed to return the flagicon-linked name from the fb series templates. I added a test for a valid value and if it failed it tries again with the country name in the alias list. These names might not correspond to the ones the wikipedia template (as you have tabulated in the Elo documentation). This currently works, but I think this is because you've change the names in the two data tables to use, for instance, "Saint Vincent and the Grenadines" rather than name used by Elo. This is convenient, but means the update lists will need more editing. I'm wondering if the alias list should have three elements: the three letter code, the name in organisations rankings and a Wikipedia name.
 * Also, I've noticed the unranked women's national teams are showing up in the category. Would it be possible to exclude instances where a valid name/alias is called, even if they are currently unranked? S.A. Julio (talk) 05:18, 12 December 2018 (UTC)
 * Ah, that is simply because no ranking was found and part of the code sets the "NR" and the category. What you suggest should work. I'll have a look and try and separate the not ranked from the error category.  Jts1882 &#124; talk 08:40, 12 December 2018 (UTC)

The Elo site is a bit strange, I've noticed the names used switch around. My computer currently uses the name "Saint Vincent and the Grenadines", while my laptop uses "St Vincent & Grenadines". Would it be possible to add additional aliases for certain countries where this is an issue? S.A. Julio (talk) 09:19, 12 December 2018 (UTC)
 * Yes, that was what I was thinking. The simplest would be a three-part alias: {code, wiki-name, federation-name}. Then using the wiki-name would ensure than the flag-icon-linked name works. Adding multiple alias for the federation-name would also be possible: {code, wiki-name, {federation-name1, federation-name2 ...} }. This would need a bit more coding, but might be a reason to replace the alias lists in each ranking data module with a master alias list for all rankings with all the used federation-name aliases: {code, wiki-name, {fifa-name, elo-name1, elo-name2, fiba-name, iif-name, ...} }.
 * One thing we should do when updating the rankings is to test against the full table to see that the names have matched.  Jts1882 &#124; talk 10:19, 12 December 2018 (UTC)
 * Alright, I've compiled a full list of name differences (in addition to the obvious mistake "Zanzibar Football Association (ZFA)" for Tanzania):

Hopefully this would help if you make a "master list". S.A. Julio (talk) 05:20, 13 December 2018 (UTC)
 * "United States Virgin Islands" / "US Virgin Islands" / "U.S. Virgin Islands"
 * "United States" / "USA"
 * "St. Vincent / Grenadines" / "St Vincent and the Grenadines" / "St. Vincent and the Grenadines" / "St Vincent & Grenadines" / "Saint Vincent and the Grenadines"
 * "Côte d'Ivoire" / "Ivory Coast"
 * "Sao Tome e Principe" / "São Tomé and Príncipe"
 * "St Kitts and Nevis" / "St. Kitts and Nevis" / "Saint Kitts and Nevis"
 * "IR Iran" / "Iran"
 * "Korea DPR" / "North Korea"
 * "Korea Republic" / "South Korea"
 * "Ireland" / "Republic of Ireland"
 * "Kyrgyz Republic" / "Kyrgyzstan"
 * "China PR" / "China"
 * "Chinese Taipei" / "Taiwan"
 * "Czechia" / "Czech Republic"
 * "Federated States of Micronesia" / "FS of Micronesia" / "FS Micronesia" / "F.S. Micronesia"
 * "Democratic Republic of Congo" / "Congo DR" / "DR Congo"
 * "Brunei Darussalam" / "Brunei"
 * "Cape Verde Islands" / "Cape Verde"
 * "FYR Macedonia" / "Macedonia"
 * "Kurdistan" / "Iraqi Kurdistan"
 * "Swatini" / "Eswatini" / "Swaziland"
 * "St Lucia" / "St. Lucia" / "Saint Lucia"
 * "Curacao" / "Curaçao"
 * "American Samoa" / "Eastern Samoa"
 * "Vatican" / "Vatican City"
 * "East Timor" / "Timor-Leste"
 * "Macao" / "Macau"

Suggest
I suggest adding a fiction that it can only display AFC national rankings so that Asian Football Confederation can be automatically updated. Hhkohh (talk) 08:21, 8 February 2019 (UTC)
 * pinging Hhkohh (talk) 08:22, 8 February 2019 (UTC)


 * I think that can be done relatively easily. One way would be to add lists that can be selected to the data subpage and only display if on the list.

data.list = { AFC = { "JAP", "KOR", "QAT", "KSA", ... },             UEFA = { "FRA", "ENG", "GER", "ESP", ... },              ...}
 * An alternative would be adding the confederations to the alias listing . The first is probably easier and could be extended for any subgrouping (e.g. teams qualified for a tournament). Can someone generate a list of AFC teams and I'll have a look later.   Jts1882 &#124; talk 09:09, 8 February 2019 (UTC)
 * All list of AFC:
 * AFG,AUS,BAN,BHR,BHU,BRU,CAM,CHN,GUM,HKG
 * IDN,IND,IRN,IRQ,JOR,JPN,KGZ,KOR,KSA,KUW
 * LAO,LIB,MAC,MAS,MDV,MNG,MYA,NEP,OMA,PAK
 * PHI,PLE,PRK,QAT,SIN,SRI,SYR,THA,TJK,TKM
 * TLS,TPE,UAE,UZB,VIE,YEM

Hhkohh (talk) 09:48, 8 February 2019 (UTC) The table to the right uses a sandbox version of the template and module that selects from  at the bottom of Module:SportsRankings/data/FIFA_World_Rankings data module. This is a first pass, which throws up a few issues. When two countries are tied the AFC ranks are adjusted, but not when there are three. The header and footer rows don't currently adjust for the extra column. I'll return to these later.
 * Great! However, I also have another concern: better to use country/nation instead of team. Also, I see another table format, see UEFA Hhkohh (talk) 12:27, 8 February 2019 (UTC)
 * Parameters to set the column headings added: selection_header (for conferation column), rank_header, change_header, team_header and points_header.
 * Extra description and notes can be added above and below using headerN and footerN where . I think the UEFA format can be approximated.   Jts1882 &#124; talk 13:13, 8 February 2019 (UTC)
 * I think it is ready. No problem (unless UEFA) Hhkohh (talk) 16:12, 8 February 2019 (UTC)
 * Now using on AFC Hhkohh (talk) 16:20, 8 February 2019 (UTC)

Best/Worst Ranking
Hi, is it possible to add Best/Worst Ranking to the module like my version on the arabic wiki? --وهراني (talk) 15:21, 4 January 2020 (UTC)

Adding darts to this list
Hello!

I am looking to add implement these modules for Template:PDC Order of Merit, and was looking for a little guidance. Everything will work nearly the same, other than having table listings say "player" instead of country. Do you have any advice? Or is there a better location for this? Possibly using the same format for the data collection but a slightly modified table template?

Thanks! — DLManiac (talk) 08:21, 14 October 2020 (UTC)
 * Sorry, I've just noticed this. Did you manage what you wanted or choose an alterantive? —  Jts1882 &#124; talk 12:35, 19 April 2021 (UTC)
 * Yep I did! At Module:DartRankings. I think it was more beneficial to separate as the individual sports require some different stuff. Therefore if snooker or golf or something ever needs such a module, that would be a good place to start as well. Thanks for checking in!DLManiac (talk) 15:33, 19 April 2021 (UTC)

How to interpret a "-" (minus) only at the position indicating the rank change?
So, it's a "-" only, not 0, + or -.

It doesn't occur in recent lists. In total I found 227 entries on 35 different dates.

The 10 most recent are:

All dates where such entries occur:

1992-12-31 1993-08-08 1993-11-19 1993-12-23 1994-03-15 1994-05-17 1994-06-14 1994-10-25 1994-11-22 1994-12-20 1995-02-20 1995-07-25 1995-09-19 1995-10-17 1995-12-19 1996-05-22 1996-08-28 1996-09-25 1996-10-23 1996-11-20 1997-05-14 1998-08-19 1998-10-21 1998-12-23 1999-03-24 1999-12-22 2000-08-09 2002-12-18 2003-01-15 2004-06-09 2005-12-16 2006-07-12 2006-11-22 2006-12-18 2007-06-13

--Sb008 (talk) 10:44, 19 April 2021 (UTC)


 * I'm not sure I follow. Are these found on pages with module output or at the FIFA rankings page? Can you link to where they are found. —  Jts1882 &#124; talk 12:32, 19 April 2021 (UTC)
 * They are present in the lists for specific dates on the FiFA site. Select the date in the select-box at the right top. E.g. 17 October 1995. Select page 4 at the bottom and you'll see several entries with a "-" only in the "+/-" column and in the "previous points" column. Maybe, in the past it was used to indicate a new listing. Nowadays if a team is new, the value in the "+/-" column is - (minus ). So, if a team is new at rank 218, the "+/-" column will say -218. --Sb008 (talk) 12:56, 19 April 2021 (UTC)
 * Yes, I think it is country that is new listing. On page you mention there is Kazakhstan with the - and it isn't in the previous ranking list (19 Spetember 1995). The newer -218 is far more confusing and suggests a software bug. — <span style="font-family:Arial;background:#d6ffe6;border:solid 1px;border-radius:5px;box-shadow:darkcyan 0px 1px 1px;"> Jts1882 &#124; talk 14:55, 19 April 2021 (UTC)

Bugs?
Linenumbers are based on the current code.
 * 1) Bug?
 * lines 327-329
 * first and last do not default to 1 and 10 but to nil and nil
 * change lines 336-338
 * to
 * 1) Bug?</li>
 * lines 154-156
 * Using empty "|caption=" does not suppress the default caption.
 * 1) Bug?</li>
 * lines 154-156
 * Using empty "|caption=" does not suppress the default caption.
 * Using empty "|caption=" does not suppress the default caption.


 * 1) As supposed to be?</li>
 * Why is function "replaceKeywords" not defined as a local function?

--Sb008 (talk) 15:34, 23 April 2021 (UTC)
 * 1) Bug?</li>
 * See: Sports rankings table 3rd table and reference 3a b c d e
 * What/which are reference 3b, 3d and 3e?
 * To solve, change line 323
 * into
 * into
 * Replies:
 * The 1-10 default works when using Sports rankings table but the module should set them for usage with . Your fix looks fine.
 * The blank caption used to work but new additions have messed this up. I'll look at this later.
 * Probably no particular reason, although it might have been exposed during testing.
 * That's surprising. Now I see that the addReference function is executed (and adds the citation) before being passed to gsub so should have been expected. Your fix looks fine.
 * I'll look at the caption and update the others later, unless you want to do it beforehand.— <span style="font-family:Arial;background:#d6ffe6;border:solid 1px;border-radius:5px;box-shadow:darkcyan 0px 1px 1px;"> Jts1882 &#124; talk 16:35, 23 April 2021 (UTC)

FIFA World Rankings needs updating
Canada for example is listed here as rank 70, but at FIFA's website, it's listed as rank 59. A lot of countries probably have their rankings and points changed, so I prefer someone who is more familiar with generating the data. pandakekok9 (talk) 09:17, 12 August 2021 (UTC)

Flag variant
Can a flag variant be selected? FIFA is still using the old flag of Afghanistan--Mike Rohsopht (talk) 14:13, 7 March 2022 (UTC)
 * I don't think it can be done at present. But I think there is an option in Module:Goalscorers that could be implemented here as well. Do you know which flag variant is needed and where it is located on Wikipedia? Those flag icon templates are a nightmare to navigate. Can you remember where to find the flags for the different flag icon templates? — <span style="font-family:Arial;background:#d6ffe6;border:solid 1px;border-radius:5px;box-shadow:darkcyan 0px 1px 1px;"> Jts1882 &#124; talk 17:14, 7 March 2022 (UTC)
 * The flag variants are at Country_data_Afghanistan. Which one is FIFA using? Looks like the 2004 one. — <span style="font-family:Arial;background:#d6ffe6;border:solid 1px;border-radius:5px;box-shadow:darkcyan 0px 1px 1px;"> Jts1882 &#124; talk 17:28, 7 March 2022 (UTC)
 * I think its now working using the 2004 variant. The variant can be changed and others added at Module:SportsRankings/data/FIFA World Rankings (line 5). — <span style="font-family:Arial;background:#d6ffe6;border:solid 1px;border-radius:5px;box-shadow:darkcyan 0px 1px 1px;"> Jts1882 &#124; talk 18:02, 7 March 2022 (UTC)
 * Interesting situation, this module is most often used to generate current rankings, so typically there would not be a need to use an old flag. Another method is to change the country data page itself, for example Template:Country data New Caledonia specifies a football-specific flag. Either way I'm not really sure what the path forward for Afghanistan's national team is, hence why the flag on FIFA's site is out of date. Prior to FIFA's recent website redesign they did use the 2013 version of the flag. S.A. Julio (talk) 20:28, 7 March 2022 (UTC)
 * Maybe we should use the 2013 flag then, as FIFA's use of the older one must be inadvertent. I assume they don't use the Taliban flag because their takeover isn't officially recognised by the international community. There's probably a discussion somewhere on using the Taliban flag on Wikipedia, or as the default for the flag icons, as I assume the choice is controversial. — <span style="font-family:Arial;background:#d6ffe6;border:solid 1px;border-radius:5px;box-shadow:darkcyan 0px 1px 1px;"> Jts1882 &#124; talk 08:07, 8 March 2022 (UTC)