diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ff6646f..73931f4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,7 +2,9 @@ ## How to test the basic functions of gtt -Create a new project on GitLab if you haven't done so already and write down the project path. e.g. `kriskbx/example-project`. To test groups and subgroups, create a new group with at least one subgroup. Add a new project to both the parent group (e.g. `example-group`) and the subgroup (e.g. `example-group/example-subgroup`) and write down the paths of all the projects and groups. Create at least two issues (write down their id e.g. `42`, `43`) and one merge request (e.g. `13`) in all projects. Then run the following basic commands and check that they work as expected: +Create a new project on GitLab if you haven't done so already and write down the project path. e.g. `kriskbx/example-project`. To test groups and subgroups, create a new group with at least one subgroup. Add a new project to both the parent group (e.g. `example-group`) and the subgroup (e.g. `example-group/example-subgroup`) and write down the paths of all the projects and groups. Create at least two issues (write down their id e.g. `42`, `43`) and one merge request (e.g. `13`) in all projects. Or just use our public group over here: https://gitlab.com/gtt + +Then run the following basic commands and check that they work as expected: ``` # Test config command diff --git a/package.json b/package.json index 8dc55e8..9496a9c 100755 --- a/package.json +++ b/package.json @@ -57,6 +57,7 @@ "request-promise-native": "^1.0.4", "shelljs": "^0.8.3", "tempfile": "^2.0.0", + "throttled-queue": "^1.0.7", "underscore": "^1.9.1", "xdg-basedir": "^3.0.0", "xlsx": "^0.13.5" diff --git a/readme.md b/readme.md index f41da8d..bc99b29 100755 --- a/readme.md +++ b/readme.md @@ -8,6 +8,10 @@

+## ⚠️ Attention + +This repository is not maintained anymore. If you still want to use gtt and get regular updates, I recommend checking out this fork: https://github.com/ndu2/gitlab-time-tracker + ## introduction gtt is a fully featured command line interface for GitLab's time tracking feature. It monitors the time you spent on an issue or merge request locally and syncs it to GitLab. It also allows you to create reports in various formats from time tracking data stored on GitLab. **Looking for a graphical user interface? Check out the [gtt taskbar/menubar app](https://github.com/kriskbx/gitlab-time-tracker-taskbar) for Linux, Mac & Windows!** diff --git a/src/models/base.js b/src/models/base.js index 4488564..754aac5 100755 --- a/src/models/base.js +++ b/src/models/base.js @@ -2,6 +2,7 @@ const request = require('request-promise-native'); const url = require('url'); const async = require('async'); const crypto = require('crypto'); +const throttle = require('throttled-queue')(10, 1000); /** * base model @@ -35,7 +36,7 @@ class base { data.private_token = this.token; - return new Promise((resolve, reject) => { + return new Promise((resolve, reject) => throttle(() => { request.post(`${this.url}${path}`, { json: true, body: data, @@ -49,7 +50,7 @@ class base { if (this.config.get('_createDump')) this.setDump(response, key); resolve(response); }).catch(e => reject(e)); - }); + })); } /** @@ -66,7 +67,7 @@ class base { path += (path.includes('?') ? '&' : '?') + `private_token=${this.token}`; path += `&page=${page}&per_page=${perPage}`; - return new Promise((resolve, reject) => { + return new Promise((resolve, reject) => throttle(() => { request(`${this.url}${path}`, { json: true, insecure: this._insecure, @@ -79,7 +80,7 @@ class base { if (this.config.get('_createDump')) this.setDump(response, key); resolve(response); }).catch(e => reject(e)); - }); + })); } /** @@ -190,4 +191,4 @@ class base { } } -module.exports = base; \ No newline at end of file +module.exports = base; diff --git a/yarn.lock b/yarn.lock index 2da1b0d..8dfdeda 100755 --- a/yarn.lock +++ b/yarn.lock @@ -2429,6 +2429,11 @@ text-encoding@0.6.4, text-encoding@^0.6.4: version "0.6.4" resolved "https://registry.yarnpkg.com/text-encoding/-/text-encoding-0.6.4.tgz#e399a982257a276dae428bb92845cb71bdc26d19" +throttled-queue@^1.0.7: + version "1.0.7" + resolved "https://registry.yarnpkg.com/throttled-queue/-/throttled-queue-1.0.7.tgz#da7ed6702941993044a1c5fd2ac3a58582dd2977" + integrity sha512-/HT49S7m+NvdyJMoMRzIYlawKjeHn8jEc8TZaGmFi5IBu09hIiU/QoP1zcrB9X2qsVC11PgfRfqd8zEQs7PlEA== + throttleit@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/throttleit/-/throttleit-1.0.0.tgz#9e785836daf46743145a5984b6268d828528ac6c"