ahmadawais / corona-cli

🦠 Track the Coronavirus disease (COVID-19) in the command line. Worldwide for all countries, for one country, and the US States. Fast response time (< 100ms). https://x.com/MrAhmadAwais
https://NodeCLI.com
MIT License
1.85k stars 191 forks source link

Use Of -l flag drops some countries #62

Closed wgmyers closed 4 years ago

wgmyers commented 4 years ago

Output of: corona -l 10:

 corona-cli  v3.8.6 by Awais.dev
Track the Coronavirus disease (COVID-19).

ℹ Sorted by: cases
┌────┬─────────────┬─────────┬───────────────┬────────┬────────────────┬───────────┬─────────┬──────────┬─────────────┐
│ #  │ Country     │ Cases   │ Cases (today) │ Deaths │ Deaths (today) │ Recovered │ Active  │ Critical │ Per Million │
├────┼─────────────┼─────────┼───────────────┼────────┼────────────────┼───────────┼─────────┼──────────┼─────────────┤
│ —  │ Worldwide   │ 663,928 │ —             │ 30,882 │ —              │ 142,361   │ —       │ —        │ —           │
├────┼─────────────┼─────────┼───────────────┼────────┼────────────────┼───────────┼─────────┼──────────┼─────────────┤
│ 1  │ USA         │ 123,750 │ 172           │ 2,227  │ 6              │ 3,231     │ 118,292 │ 2,666    │ 374         │
├────┼─────────────┼─────────┼───────────────┼────────┼────────────────┼───────────┼─────────┼──────────┼─────────────┤
│ 2  │ Italy       │ 92,472  │ 0             │ 10,023 │ 0              │ 12,384    │ 70,065  │ 3,856    │ 1,529       │
├────┼─────────────┼─────────┼───────────────┼────────┼────────────────┼───────────┼─────────┼──────────┼─────────────┤
│ 3  │ Spain       │ 73,235  │ 0             │ 5,982  │ 0              │ 12,285    │ 54,968  │ 4,165    │ 1,566       │
├────┼─────────────┼─────────┼───────────────┼────────┼────────────────┼───────────┼─────────┼──────────┼─────────────┤
│ 4  │ Germany     │ 57,695  │ 0             │ 433    │ 0              │ 8,481     │ 48,781  │ 1,581    │ 689         │
├────┼─────────────┼─────────┼───────────────┼────────┼────────────────┼───────────┼─────────┼──────────┼─────────────┤
│ 5  │ France      │ 37,575  │ 0             │ 2,314  │ 0              │ 5,700     │ 29,561  │ 4,273    │ 576         │
├────┼─────────────┼─────────┼───────────────┼────────┼────────────────┼───────────┼─────────┼──────────┼─────────────┤
│ 6  │ Iran        │ 35,408  │ 0             │ 2,517  │ 0              │ 11,679    │ 21,212  │ 3,206    │ 422         │
├────┼─────────────┼─────────┼───────────────┼────────┼────────────────┼───────────┼─────────┼──────────┼─────────────┤
│ 7  │ UK          │ 17,089  │ 0             │ 1,019  │ 0              │ 135       │ 15,935  │ 163      │ 252         │
├────┼─────────────┼─────────┼───────────────┼────────┼────────────────┼───────────┼─────────┼──────────┼─────────────┤
│ 8  │ Switzerland │ 14,076  │ 0             │ 264    │ 0              │ 1,595     │ 12,217  │ 301      │ 1,626       │
├────┼─────────────┼─────────┼───────────────┼────────┼────────────────┼───────────┼─────────┼──────────┼─────────────┤
│ 9  │ Netherlands │ 9,762   │ 0             │ 639    │ 0              │ 3         │ 9,120   │ 914      │ 570         │
├────┼─────────────┼─────────┼───────────────┼────────┼────────────────┼───────────┼─────────┼──────────┼─────────────┤
│ 10 │ S. Korea    │ 9,583   │ 105           │ 152    │ 8              │ 5,033     │ 4,398   │ 59       │ 187         │
└────┴─────────────┴─────────┴───────────────┴────────┴────────────────┴───────────┴─────────┴──────────┴─────────────┘
ℹ Last Updated: Sun Mar 29 2020 06:05:17 GMT+0100 (British Summer Time)

Output of corona:

 corona-cli  v3.8.6 by Awais.dev
Track the Coronavirus disease (COVID-19).

ℹ Sorted by: cases
┌─────┬────────────────────────┬─────────┬───────────────┬────────┬────────────────┬───────────┬─────────┬──────────┬─────────────┐
│ #   │ Country                │ Cases   │ Cases (today) │ Deaths │ Deaths (today) │ Recovered │ Active  │ Critical │ Per Million │
├─────┼────────────────────────┼─────────┼───────────────┼────────┼────────────────┼───────────┼─────────┼──────────┼─────────────┤
│ —   │ Worldwide              │ 663,928 │ —             │ 30,882 │ —              │ 142,361   │ —       │ —        │ —           │
├─────┼────────────────────────┼─────────┼───────────────┼────────┼────────────────┼───────────┼─────────┼──────────┼─────────────┤
│ 1   │ USA                    │ 123,750 │ 172           │ 2,227  │ 6              │ 3,231     │ 118,292 │ 2,666    │ 374         │
├─────┼────────────────────────┼─────────┼───────────────┼────────┼────────────────┼───────────┼─────────┼──────────┼─────────────┤
│ 2   │ Italy                  │ 92,472  │ 0             │ 10,023 │ 0              │ 12,384    │ 70,065  │ 3,856    │ 1,529       │
├─────┼────────────────────────┼─────────┼───────────────┼────────┼────────────────┼───────────┼─────────┼──────────┼─────────────┤
│ 3   │ China                  │ 81,439  │ 45            │ 3,300  │ 5              │ 75,448    │ 2,691   │ 742      │ 57          │
├─────┼────────────────────────┼─────────┼───────────────┼────────┼────────────────┼───────────┼─────────┼──────────┼─────────────┤
│ 4   │ Spain                  │ 73,235  │ 0             │ 5,982  │ 0              │ 12,285    │ 54,968  │ 4,165    │ 1,566       │
├─────┼────────────────────────┼─────────┼───────────────┼────────┼────────────────┼───────────┼─────────┼──────────┼─────────────┤
│ 5   │ Germany                │ 57,695  │ 0             │ 433    │ 0              │ 8,481     │ 48,781  │ 1,581    │ 689         │
├─────┼────────────────────────┼─────────┼───────────────┼────────┼────────────────┼───────────┼─────────┼──────────┼─────────────┤
│ 6   │ France                 │ 37,575  │ 0             │ 2,314  │ 0              │ 5,700     │ 29,561  │ 4,273    │ 576         │
├─────┼────────────────────────┼─────────┼───────────────┼────────┼────────────────┼───────────┼─────────┼──────────┼─────────────┤
│ 7   │ Iran                   │ 35,408  │ 0             │ 2,517  │ 0              │ 11,679    │ 21,212  │ 3,206    │ 422         │
├─────┼────────────────────────┼─────────┼───────────────┼────────┼────────────────┼───────────┼─────────┼──────────┼─────────────┤
│ 8   │ UK                     │ 17,089  │ 0             │ 1,019  │ 0              │ 135       │ 15,935  │ 163      │ 252         │
├─────┼────────────────────────┼─────────┼───────────────┼────────┼────────────────┼───────────┼─────────┼──────────┼─────────────┤
│ 9   │ Switzerland            │ 14,076  │ 0             │ 264    │ 0              │ 1,595     │ 12,217  │ 301      │ 1,626       │
├─────┼────────────────────────┼─────────┼───────────────┼────────┼────────────────┼───────────┼─────────┼──────────┼─────────────┤
│ 10  │ Netherlands            │ 9,762   │ 0             │ 639    │ 0              │ 3         │ 9,120   │ 914      │ 570         │
├─────┼────────────────────────┼─────────┼───────────────┼────────┼────────────────┼───────────┼─────────┼──────────┼─────────────┤
│ 11  │ S. Korea               │ 9,583   │ 105           │ 152    │ 8              │ 5,033     │ 4,398   │ 59       │ 187         │
├─────┼────────────────────────┼─────────┼───────────────┼────────┼────────────────┼───────────┼─────────┼──────────┼─────────────┤
│ 12  │ Belgium                │ 9,134   │ 0             │ 353    │ 0              │ 1,063     │ 7,718   │ 789      │ 788         │
├─────┼────────────────────────┼─────────┼───────────────┼────────┼────────────────┼───────────┼─────────┼──────────┼─────────────┤
│ 13  │ Austria                │ 8,271   │ 0             │ 68     │ 0              │ 225       │ 7,978   │ 135      │ 918         │
├─────┼────────────────────────┼─────────┼───────────────┼────────┼────────────────┼───────────┼─────────┼──────────┼─────────────┤
│ 14  │ Turkey                 │ 7,402   │ 0             │ 108    │ 0              │ 70        │ 7,224   │ 445      │ 88          │
├─────┼────────────────────────┼─────────┼───────────────┼────────┼────────────────┼───────────┼─────────┼──────────┼─────────────┤
│ 15  │ Canada                 │ 5,655   │ 0             │ 60     │ 0              │ 508       │ 5,087   │ 120      │ 150         │
├─────┼────────────────────────┼─────────┼───────────────┼────────┼────────────────┼───────────┼─────────┼──────────┼─────────────┤
│ 16  │ Portugal               │ 5,170   │ 0             │ 100    │ 0              │ 43        │ 5,027   │ 89       │ 507         │
├─────┼────────────────────────┼─────────┼───────────────┼────────┼────────────────┼───────────┼─────────┼──────────┼─────────────┤
│ 17  │ Norway                 │ 4,032   │ 17            │ 23     │ 0              │ 7         │ 4,002   │ 84       │ 744         │
├─────┼────────────────────────┼─────────┼───────────────┼────────┼────────────────┼───────────┼─────────┼──────────┼─────────────┤
│ 18  │ Australia              │ 3,969   │ 334           │ 16     │ 2              │ 170       │ 3,783   │ 23       │ 156         │
├─────┼────────────────────────┼─────────┼───────────────┼────────┼────────────────┼───────────┼─────────┼──────────┼─────────────┤
│ 19  │ Brazil                 │ 3,904   │ 0             │ 114    │ 0              │ 6         │ 3,784   │ 296      │ 18          │
├─────┼────────────────────────┼─────────┼───────────────┼────────┼────────────────┼───────────┼─────────┼──────────┼─────────────┤
│ 20  │ Israel                 │ 3,619   │ 0             │ 12     │ 0              │ 89        │ 3,518   │ 50       │ 418         │
├─────┼────────────────────────┼─────────┼───────────────┼────────┼────────────────┼───────────┼─────────┼──────────┼─────────────┤
│ 21  │ Sweden                 │ 3,447   │ 0             │ 105    │ 0              │ 16        │ 3,326   │ 239      │ 341         │
├─────┼────────────────────────┼─────────┼───────────────┼────────┼────────────────┼───────────┼─────────┼──────────┼─────────────┤
│ 22  │ Czechia                │ 2,631   │ 0             │ 11     │ 0              │ 11        │ 2,609   │ 45       │ 246         │
├─────┼────────────────────────┼─────────┼───────────────┼────────┼────────────────┼───────────┼─────────┼──────────┼─────────────┤
│ 23  │ Ireland                │ 2,415   │ 0             │ 36     │ 0              │ 5         │ 2,374   │ 59       │ 489         │
├─────┼────────────────────────┼─────────┼───────────────┼────────┼────────────────┼───────────┼─────────┼──────────┼─────────────┤
│ 24  │ Malaysia               │ 2,320   │ 0             │ 27     │ 0              │ 320       │ 1,973   │ 54       │ 72          │
├─────┼────────────────────────┼─────────┼───────────────┼────────┼────────────────┼───────────┼─────────┼──────────┼─────────────┤

China should be at #3 in both lists, but does not appear in the first.

wgmyers commented 4 years ago

In getCountries.js you have:

        // Limit.
        allCountries = allCountries.slice(0, limit);

        // Sort & reverse.
        const direction = reverse ? 'asc' : 'desc';
        allCountries = orderBy(
            allCountries,
            [sortingKeys[sortBy]],
            [direction]
        );

Perhaps sort first, then limit?

wgmyers commented 4 years ago

Ok, forked, tried the change suggested above, it fixes the issue, have raised pull request :)

wgmyers commented 4 years ago

Fixed elsewhere