Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
emafazillah committed Mar 31, 2020
1 parent b8dee1c commit 6810f71
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const bot = new Telegram(process.env.TELEGRAM_TOKEN);

const URL = 'https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_daily_reports/';
const CSV = '.csv';
const COUNTRY = 'Australia';

try {
const today = new Date();
Expand All @@ -28,15 +27,6 @@ try {
Total Deaths: ${totalDeaths}.
Total Recovered: ${totalRecovered}.
Total Active: ${totalActive}.`;

// request.get(URL + formattedYesterdayDate + CSV)
// .pipe(new StringStream())
// .CSVParse({ skipEmptyLines: true, header: true })
// .filter(object => (object.Country_Region === 'Malaysia'))
// .map(async(object) => {
// const message = generateMessage(object);
// bot.sendMessage(process.env.TELEGRAM_CHAT_ID, message);
// });

async function getResult(country) {
let arr = [];
Expand All @@ -49,7 +39,7 @@ try {
return arr;
}

getResult(COUNTRY)
getResult(process.env.COUNTRY)
.then(result => {
let totalConfirmed = 0;
let totalDeaths = 0;
Expand All @@ -63,9 +53,9 @@ try {
totalActive = totalActive + parseInt(element.Active);
});

const message = generateMessage(COUNTRY, totalConfirmed, totalDeaths, totalRecovered, totalActive);
const message = generateMessage(process.env.COUNTRY, totalConfirmed, totalDeaths, totalRecovered, totalActive);
console.log('message: ', message);
// bot.sendMessage(process.env.TELEGRAM_CHAT_ID, message);
// bot.sendMessage(process.env.COUNTRY, message);
});

} catch (error) {
Expand Down

0 comments on commit 6810f71

Please sign in to comment.