GithubHelp home page GithubHelp logo

fusky / wakatime-sync Goto Github PK

View Code? Open in Web Editor NEW

This project forked from superman66/wakatime-sync

0.0 1.0 0.0 692 KB

Wakatime Data Sync to Gist

Home Page: http://wakatime.chenhuichao.com

JavaScript 100.00%

wakatime-sync's Introduction

Wakatime Sync To Gist

Waktime 是一款专门为程序员打造的时间统计工具。可以在各大编辑器、IDE 安装插件,然后统计你的 coding 时间。统计的维度包括:在具体项目的时长、所用的操作系统、所用的编辑器、所用的语言等。更多具体的可以前往 Wakatime 官网.对于程序员而言,我强烈建议每个人都去使用 WakaTime。这样就能非常详细的记录你每天在 coding 的时间。

这是我自己的 WakaTime 统计首页:

WakaTime 非常完美,但是它有区分免费版和付费版。免费版只能保持两个礼拜的 Dashboard History,而付费版则要 $9 每个月。这样使用免费版的你,就无法查看历史更多的统计数据了。用订阅去支持这样的优秀的工具是件好事,可以帮助企业获得更好的收入,进而提升工具的质量和用户体验。

但是对于可能不太需要去看历史统计数据,但是可能偶尔需要看一看的人(比如一个季度或者一年看一次等),每个月花 $9 的成本确实不低。因此就产生了 wakatiem-sync 这个项目。

wakatime-sync 可以帮助你每天定时去请求 WakaTime 的统计数据,然后将数据同步到 Gist 上面。这样就可以永远的将你的统计数据保存到 Gist 上面,随时想看都可以。 目前只同步该接口的数据 https://wakatime.com/api/v1/users/current/summaries。因为通过该接口,基本上就能获取你所需要的各类信息。

通过 Wakatime Dashboard这个项目,你就可以在上面保存查看 Gist 上面的统计数据,突破 WakaTime 免费版只能查看过去 14 天的数据。

如果觉得对你有帮助,请点波 star 支持下作者,非常感谢~

用法

第一步

你需要先去 Gist 创建一个 Gist,记得设置为 secret.

第二步

git clone 该项目到你的本地或者你的服务器。由于需要每天定时跑任务同步数据到 Gist,因此强烈建议有服务器的同学直接部署到自己的服务器,这样部署完了之后就不需要管它了,脚本会在每天的 每天1点30分30秒 执行。 如果没有服务器的同学,也可以部署到本地。至于部署到本地效果如何,我没有测试过。

git clone https://github.com/superman66/wakatime-sync.git && cd wakatime-sync
npm install
// 项目通过 pm2 来管理 node,因此你还需要全局安装 pm2,如果你还没有安装过。
npm i pm2 -g

第三步

src 目录下创建 config.json 配置文件,将第一步创建的 Gist ID 填入。同时还需要:

// config.json
{
  "wakatimeApiKey": "xxxxxxxxx",
  "gistToken": "xxxxxxxxx",
  "syncGistId": "xxxxxxxxx"
}

Waketime apikey 截图

how to get wakatime apikey 安装完依赖后,你可以通过几个命令来运行该项目:

  • npm run start 本地启动该脚本
  • npm run build 构建项目
  • npm run pm2 构建项目并通过 pm2 启动管理项目

如果是部署到服务器,则可以直接运行 npm run pm2 即可。

这是我保存在 Gist 上的数据

定时任务

该项目使用的是 node-schedule 来执行定时任务的,我的设置是每天1点30分30秒执行(该时间是基于服务器的时间)。如果你要更改时间的话,只需要在 src/server/index.js 中更改即可:

// 每天1点30分30秒执行该job
const job = schedule.scheduleJob('30 30 1 * * *', function() {
  syncWakaTimeToGist(config.syncGistId)
})

node-schedule 的规则如下:

*    *    *    *    *    *
┬    ┬    ┬    ┬    ┬    ┬
│    │    │    │    │    │
│    │    │    │    │    └ day of week (0 - 7) (0 or 7 is Sun)
│    │    │    │    └───── month (1 - 12)
│    │    │    └────────── day of month (1 - 31)
│    │    └─────────────── hour (0 - 23)
│    └──────────────────── minute (0 - 59)
└───────────────────────── second (0 - 59, OPTIONAL)

更多请看 node-schedule 文档

wakatime-sync's People

Contributors

superman66 avatar

Watchers

xiaochao lee avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.