@@ -2,7 +2,6 @@ import { config, cosmicSync } from "@anandchowdhary/cosmic";
2
2
import axios from "axios" ;
3
3
import dayjs from "dayjs" ;
4
4
import week from "dayjs/plugin/weekOfYear" ;
5
- import PromisePool from "es6-promise-pool" ;
6
5
import { lstat , pathExists , readdir , readJson } from "fs-extra" ;
7
6
import { join } from "path" ;
8
7
import { integrationConfig , write } from "../common" ;
@@ -42,7 +41,7 @@ const updateRescueTimeDailyData = async (date: Date) => {
42
41
const day = dayjs ( date ) . format ( "DD" ) ;
43
42
const formattedDate = dayjs ( date ) . format ( "YYYY-MM-DD" ) ;
44
43
45
- if ( integrationConfig ( "rescue-time " ) [ "top-categories" ] ) {
44
+ if ( integrationConfig ( "rescuetime " ) [ "top-categories" ] ) {
46
45
console . log ( "RescueTime: Adding data for" , date ) ;
47
46
const topCategories = (
48
47
await axios . get (
@@ -66,7 +65,7 @@ const updateRescueTimeDailyData = async (date: Date) => {
66
65
JSON . stringify ( topCategoriesData , null , 2 )
67
66
) ;
68
67
}
69
- if ( integrationConfig ( "rescue-time " ) [ "top-activities" ] ) {
68
+ if ( integrationConfig ( "rescuetime " ) [ "top-activities" ] ) {
70
69
const topActivities = (
71
70
await axios . get (
72
71
`https://www.rescuetime.com/anapi/data?format=json&key=${ config (
@@ -90,7 +89,7 @@ const updateRescueTimeDailyData = async (date: Date) => {
90
89
) ;
91
90
}
92
91
93
- if ( integrationConfig ( "rescue-time " ) . overview ) {
92
+ if ( integrationConfig ( "rescuetime " ) . overview ) {
94
93
const topOverview = (
95
94
await axios . get (
96
95
`https://www.rescuetime.com/anapi/data?format=json&key=${ config (
@@ -132,16 +131,11 @@ export default class RescueTime implements Integration {
132
131
console . log ( "RescueTime: Added daily summaries" ) ;
133
132
}
134
133
async legacy ( start : string ) {
135
- const CONCURRENCY = 10 ;
136
134
const startDate = dayjs ( start ) ;
137
- let count = 0 ;
138
- const pool = new PromisePool ( async ( ) => {
135
+ for await ( const count of [ ...Array ( dayjs ( ) . diff ( startDate , "day" ) ) . keys ( ) ] ) {
139
136
const date = dayjs ( startDate ) . add ( count , "day" ) ;
140
- if ( dayjs ( ) . diff ( date , "day" ) === 0 ) return null ;
141
- count ++ ;
142
- return updateRescueTimeDailyData ( date . toDate ( ) ) ;
143
- } , CONCURRENCY ) ;
144
- await pool . start ( ) ;
137
+ await updateRescueTimeDailyData ( date . toDate ( ) ) ;
138
+ }
145
139
console . log ( "Done!" ) ;
146
140
}
147
141
async summary ( ) {
0 commit comments