Skip to content
José Briones Romero edited this page Jun 1, 2020 · 52 revisions

corona-cli

1. About the project
2. About the issues
2.1. Candidate issues
2.2. Issue 1: Creation of CSV Files
2.3. Issue 2: Adding Multiple Countries
3. Project Maintainability Status

About the project

What is corona-cli for?

Track the Coronavirus disease (COVID-19) via command-line interface.

🚀 Get worldwide Coronavirus disease (COVID-19) reporting
🤯 Active daily reporting of your country's COVID-19 statistics
🇺🇸 Get US States data for Coronavirus disease reports across the US
🗃️ Data: Country, Cases, Deaths, Recovered, Active, Critical, Per Million
📈 Charts: Plot statistics in the form of line charts both regular and logarithmic
📟 Sort: cases, cases-today, deaths, deaths-today, recovered, active, critical, per-million

How alive is the project?

This project has been active since 21 January 2020 when the novel coronavirus strain reached Europe and USA.

imagen

How important is it?

The coronavirus pandemic has infected more than 4 billion people worldwide. Having the cases tracked is of major importance so it can be decided the population safety and measures to be taken according to the latest number of infected persons.

What is it good for?

It gives you the possibility of having a cli tool to track covid cases worldwide. It has a fast response time (< 100ms) and can plot statistics charts to allow a better visualization of the propagation of the disease.

What are the technologies involved?

This project is built on Node.js.

Is the project in a development phase or maintenance/evolution phase?

The project is in the maintenance/evolution phase with new functionalities being added and others adapted to pretended functionalities.

Are there many issues to fix?

The number of open issues currently is 21.

About the issues

Candidate issues

The list of candidate issues included:

  • #98: Create CSV files along with the chart display to provide effective visualisation.
  • #54: Fetch multiple countries data for the input command and display them in the selected output format.
  • #33: Provide a new option --date -d ddmmyy to the command line that gives the results for the given date.
  • #87: Add an in chart option to display the bar chart.
  • #99: Fetch information by continent and display output.

Issue 1: Creation of CSV Files

The issue

This is a new feature which was ideated from one of the contributors, the owner described this functionality to be made as a nice to have feature. Hence, we implemented this option to create a csv file with the output data which is currently visualized as charts and tables.

The issue can be found at https://github.com/ahmadawais/corona-cli/issues/103.

Requirements

As a user, I want to be able to extract the output data to csv format after a specific search that I performed.

Design of the fix

The main fix is to create a csv file from the command line. It is now added along with the existing chart display feature, so when the user inputs the command to view the states in form of chart, the data is extracted to a csv file.

The following activity diagram explains how the fix was conceived. imgActDiag

Source code files

Code changes were made on the file: utils/getStates.js
This file contains the code for extracting the data that is shown on the application.

Fix source code

First, the csv-writer package from npm library was installed in the project. The data is fetched from the following REST API: https://corona.lmao.ninja/v2/states

Then, the data fetched is transformed to the required format. After that, the data is mapped to each column for csv generation and a path is also defined inside the project path named /output.

We can see the code changes made in the following lines of code:

LOC 9: Installed package is imported inside the project
LOC 54 - 64: Data is mapped to required csv format
LOC 66: Write the records to csv file

9: const createCsvWriter = require('csv-writer').createObjectCsvWriter;
10: const [err, response] = await to(
 axios.get(`https://corona.lmao.ninja/v2/states`)
);
 
 
54:         const csvWriter = createCsvWriter({
55:             path: 'output/chart.csv',
56:             header: [
57:               {id: 'state', title: 'State'},
58:               {id: 'cases', title: 'Cases'},
59:               {id: 'todayCases', title: 'Cases (today)'},
60:               {id: 'deaths', title: 'Deaths'},
61:               {id: 'todayDeaths', title: 'Deaths (today)'},
62:               {id: 'active', title: 'Active'},
63:             ]
64:         });
 
66:         csvWriter.writeRecords(allStates);

Commited files
issue1

Submit the fix

A pull request was submitted on the project’s GitHub and can be found at:
https://github.com/ahmadawais/corona-cli/pull/103.

We have tested the feature in multiple platforms such as macOS and Windows.

Example of CSV file generated

imagen

Issue 2: Adding multiple countries

The issue

The issue can be found at https://github.com/ahmadawais/corona-cli/issues/54.

This feature is a value add to the application, since currently there is not an option to select multiple countries from the application.

Requirements

As a user, I want to add multiple countries to the input so taht I can visualize the data of coronavirus affected cases for several countries.

Design of the fix

This is a feature addition to already existing country selection. So when the user inputs the command to view a list of countries, he gets the selected countries data in the chart/table view.

The following activity diagram describe the bifurcation that now the command will have, adding the possibility of showing one or more countries. imagen

Source code files
A new file module named getMultipleCountries.js is placed inside /utils folder.

Fix source code

First, we validate the list of countries of the input to access the REST API and then an iteration is made to every country so its information can be shown later.

The following lines of code describe the fix:

LOC 08-11: Validate if the list of countries are provided as input, after that, access to the REST API https://corona.lmao.ninja/v2/countries/{countryList} and fetch the list of countries data.

LOC 20-32: The country data is iterated and formatted for data display. Then, each country in the list is displayed as a separate row in the table view.

07: module.exports = async (spinner, table, states, countryList, options) => {
08: 	if (countryList && !states && !options.chart) {
09: 		const [err, response] = await to(
10: 			axios.get(`https://corona.lmao.ninja/v2/countries/${countryList}`)
11: 		);
12: 		exitCountry(err, spinner, countryList);
13: 		err && spinner.stopAndPersist();
14: 		handleError(`API is down, try again later.`, err, false);
15: 		const countries = response.data;
16: 
17: 		// Format.
18: 		const format = numberFormat(options.json);
19: 
20: 		if (Array.isArray(countries)) {
21: 			countries.map(data => table.push([
22: 				`—`,
23: 				data.country,
24: 				format(data.cases),
25: 				format(data.todayCases),
26: 				format(data.deaths),
27: 				format(data.todayDeaths),
28: 				format(data.recovered),
29: 				format(data.active),
30: 				format(data.critical),
31: 				format(data.casesPerOneMillion)
32: 			]));
33: 		}
34: 
35: 		spinner.stopAndPersist();
36: 		console.log(table.toString());
37: 	}
38: };
39: 

Commited files
issue2.1 issue2.2

Submit the fix
A pull request was submitted on the project’s Github and can be found at:
https://github.com/ahmadawais/corona-cli/pull/104.
We have tested the feature in multiple platforms such as macOS, Windows.

Example of multiple countries command
Input command:
node index.js portugal,india,ecuador

Output result:

Project Maintainability Status

Criticality of the issues

The issues resolved are nice to have features. We chose them because they add more value to the project and add more flexibility to the current functionality. Code modularity is maintained hence it is easy to add a specific functionality to setup the project and to run it locally, since the project does not include heavier packages/modules.

As the project is a command line application, it was easier to debug the flow of the application and understand it. It also provides an intuitive graphical display view in the cli. The output types (chart/table view) are configured in a separate file and the command inputs provides determined output. This application is based on real time corona statistics data feed from external APIs, the accuracy of the information is based on the API output information. Another aspect to highlight is that the documentation provided in the source wiki page was extensive and informative.

Roadmap for solving issues

Issue 1 : Creation of CSV files

Time/Effort required: 1 Developer/2 days

This issue is a nice to have feature proposed by one of the contributors, the maintainer agreed to include into the project. The maintainer had provided a suggestion for the implementation which guided us in understanding the issue. However, it was difficult to identify the sections where it needed to be implemented which took us the first day. During this time we were also selecting the suitable package manager for implementing the CSV generation. Once this was done, we started our work on adding the code to the project.

The implementation was easier for us, since the data required for CSV file generation was already available in that functionality. We needed to integrate the data to the CSV module and we also added a folder to write files. While the solution was quicker, considering the difficult level of the issue, we made sure that this addition did not break the existing functionality. This feature is yet to be merged and also we did not get any comments regarding this issue.

issue1status

Issue 2: Adding mutiple countries

Time/Effort required: 1 Developer/3 days

This is a feature which was also proposed by one of the contributors, but this is a new implementation which provides much value addition to the project. The current features only allow to view all the corona affected countries along with the statistics. This implementation provides users with the ability to view selected countries' data. For example, if the user is interested in viewing a particular list of countries, he can provide that list as input to the command and get the desired output.

In order to implement this new feature, we spent our initial effort to understand the current implementation for selecting all the countries, since this feature is similar to the present. The API used for this feature was not clearly documented which took us time. On the first day, we were also formulating the flow for this feature. The second day, we started work on the implementation part. Since during this phase we already had the required details, it was easier for us. After code completion, we made regression testing of the functionality, in order to ensure the code addition did not break the current functionality. Once we felt confident about the implementation, we raised the pull request during the third day. This pull request received comments regarding the opportunity to refactor the code, and we also felt the option for improvement in particular sections of the code. We addressed the developers comments and provided a separate commit as shown in the below screenshot.

Addmultiplecountries

However, this feature is also yet to be merged. issue2status

Quality of artifacts

Knowledge artifacts were qualified following the Likert-scale which consists in assess an artifact from 1 to 5, being 5 the best value.

Documentation - 5

The documentation is very good, you can find everything explained regarding:

  • How to set up the developer environment
  • Workflow to use the client(commands in the Usage section):
    • All Countries
    • Single Country
    • US States Data
    • Sort Data
    • Bar Charts
    • Line Charts: Regular & Logarithmic
    • Limit the output
    • CLI Help
  • Changelog of every release with keys
  • Sources of information

Source code - 4

The learning was great since the project had the latest coding standards used by Node.js community. Project was developed using JavaScript best practices and it helped increase our knowledge. The control flow used by the author of this project was also remarkable, the code is developed considering modularity. Hence, it made easier for us understanding the functionality. The documentation was extensive as mentioned earlier, and also the steps to reproduce a particular feature was explained using gif format, it was quick to understand. We also would like to provide special mentions to the work done by the authors in developing the project.

  • Minimum Storage space consumed by the project
  • Intuitive graphical display in spite being a command-line application
  • Code separation of concerns
  • Documentation
  • Author's contribution to the JavaScript community
  • Contributor's participation in addressing peer works.

Community support - 3

The community was small, but had good support from the contributors. The project has most of the features documented with demonstrations in video, which help to understand what is being done and what should have been done in the future. It can be seen that it is an active project with peer contributor support and that we have received comments on the pull request.

The creator of the project responds to some of the issues in the comments, new features requests that are suggested and delivers a solution or opinion on how they should be solved. One downsize that could be mentioned is the lack of activity seen in the project, due to the low number of users and developers working on the same. However, this project is in an initial phase, there is a space to grow and even use the core for other purposes in the future.