@codeclimbers/server 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (175) hide show
  1. package/README.md +73 -0
  2. package/dist/index.d.ts +4 -0
  3. package/dist/index.js +22 -0
  4. package/dist/index.js.map +1 -0
  5. package/dist/src/app.module.d.ts +4 -0
  6. package/dist/src/app.module.js +49 -0
  7. package/dist/src/app.module.js.map +1 -0
  8. package/dist/src/assets/startup.plist.d.ts +1 -0
  9. package/dist/src/assets/startup.plist.js +41 -0
  10. package/dist/src/assets/startup.plist.js.map +1 -0
  11. package/dist/src/common/infrastructure/http/controllers/health.controller.d.ts +5 -0
  12. package/dist/src/common/infrastructure/http/controllers/health.controller.js +29 -0
  13. package/dist/src/common/infrastructure/http/controllers/health.controller.js.map +1 -0
  14. package/dist/src/common/infrastructure/http/middleware/requestlogger.middleware.d.ts +5 -0
  15. package/dist/src/common/infrastructure/http/middleware/requestlogger.middleware.js +27 -0
  16. package/dist/src/common/infrastructure/http/middleware/requestlogger.middleware.js.map +1 -0
  17. package/dist/src/main.d.ts +2 -0
  18. package/dist/src/main.js +44 -0
  19. package/dist/src/main.js.map +1 -0
  20. package/dist/src/sentry.d.ts +1 -0
  21. package/dist/src/sentry.js +13 -0
  22. package/dist/src/sentry.js.map +1 -0
  23. package/dist/src/v1/activities/activities.service.d.ts +21 -0
  24. package/dist/src/v1/activities/activities.service.js +174 -0
  25. package/dist/src/v1/activities/activities.service.js.map +1 -0
  26. package/dist/src/v1/activities/pulse.controller.d.ts +19 -0
  27. package/dist/src/v1/activities/pulse.controller.js +92 -0
  28. package/dist/src/v1/activities/pulse.controller.js.map +1 -0
  29. package/dist/src/v1/activities/wakatimeProxy.controller.d.ts +13 -0
  30. package/dist/src/v1/activities/wakatimeProxy.controller.js +64 -0
  31. package/dist/src/v1/activities/wakatimeProxy.controller.js.map +1 -0
  32. package/dist/src/v1/database/__tests__/knex.test.d.ts +1 -0
  33. package/dist/src/v1/database/__tests__/knex.test.js +18 -0
  34. package/dist/src/v1/database/__tests__/knex.test.js.map +1 -0
  35. package/dist/src/v1/database/__tests__/pulse.repo.test.d.ts +1 -0
  36. package/dist/src/v1/database/__tests__/pulse.repo.test.js +141 -0
  37. package/dist/src/v1/database/__tests__/pulse.repo.test.js.map +1 -0
  38. package/dist/src/v1/database/knex.d.ts +5 -0
  39. package/dist/src/v1/database/knex.js +87 -0
  40. package/dist/src/v1/database/knex.js.map +1 -0
  41. package/dist/src/v1/database/migrations.d.ts +1 -0
  42. package/dist/src/v1/database/migrations.js +16 -0
  43. package/dist/src/v1/database/migrations.js.map +1 -0
  44. package/dist/src/v1/database/pulse.repo.d.ts +17 -0
  45. package/dist/src/v1/database/pulse.repo.js +115 -0
  46. package/dist/src/v1/database/pulse.repo.js.map +1 -0
  47. package/dist/src/v1/database/queries/getCategoryTimeOverview.sql +6 -0
  48. package/dist/src/v1/database/queries/getLongestDayInRangeMinutes.sql +11 -0
  49. package/dist/src/v1/database/queries/getStatusBarDetails.sql +42 -0
  50. package/dist/src/v1/dtos/createWakatimePulse.dto.d.ts +19 -0
  51. package/dist/src/v1/dtos/createWakatimePulse.dto.js +97 -0
  52. package/dist/src/v1/dtos/createWakatimePulse.dto.js.map +1 -0
  53. package/dist/src/v1/dtos/getCategoryTimeOverview.dto.d.ts +4 -0
  54. package/dist/src/v1/dtos/getCategoryTimeOverview.dto.js +25 -0
  55. package/dist/src/v1/dtos/getCategoryTimeOverview.dto.js.map +1 -0
  56. package/dist/src/v1/dtos/getWeekOverview.dto.d.ts +3 -0
  57. package/dist/src/v1/dtos/getWeekOverview.dto.js +21 -0
  58. package/dist/src/v1/dtos/getWeekOverview.dto.js.map +1 -0
  59. package/dist/src/v1/startup/darwinStartup.service.d.ts +8 -0
  60. package/dist/src/v1/startup/darwinStartup.service.js +114 -0
  61. package/dist/src/v1/startup/darwinStartup.service.js.map +1 -0
  62. package/dist/src/v1/startup/linuxStartup.service.d.ts +8 -0
  63. package/dist/src/v1/startup/linuxStartup.service.js +104 -0
  64. package/dist/src/v1/startup/linuxStartup.service.js.map +1 -0
  65. package/dist/src/v1/startup/startup.controller.d.ts +8 -0
  66. package/dist/src/v1/startup/startup.controller.js +46 -0
  67. package/dist/src/v1/startup/startup.controller.js.map +1 -0
  68. package/dist/src/v1/startup/startup.util.d.ts +5 -0
  69. package/dist/src/v1/startup/startup.util.js +19 -0
  70. package/dist/src/v1/startup/startup.util.js.map +1 -0
  71. package/dist/src/v1/startup/startupService.factory.d.ts +9 -0
  72. package/dist/src/v1/startup/startupService.factory.js +41 -0
  73. package/dist/src/v1/startup/startupService.factory.js.map +1 -0
  74. package/dist/src/v1/startup/unsupportedStartup.service.d.ts +6 -0
  75. package/dist/src/v1/startup/unsupportedStartup.service.js +29 -0
  76. package/dist/src/v1/startup/unsupportedStartup.service.js.map +1 -0
  77. package/dist/src/v1/v1.module.d.ts +2 -0
  78. package/dist/src/v1/v1.module.js +41 -0
  79. package/dist/src/v1/v1.module.js.map +1 -0
  80. package/dist/tsconfig.build.tsbuildinfo +1 -0
  81. package/dist/utils/__tests__/activites.util.test.d.ts +1 -0
  82. package/dist/utils/__tests__/activites.util.test.js +18 -0
  83. package/dist/utils/__tests__/activites.util.test.js.map +1 -0
  84. package/dist/utils/__tests__/helpers.util.test.d.ts +1 -0
  85. package/dist/utils/__tests__/helpers.util.test.js +120 -0
  86. package/dist/utils/__tests__/helpers.util.test.js.map +1 -0
  87. package/dist/utils/__tests__/wakatime.util.test.d.ts +1 -0
  88. package/dist/utils/__tests__/wakatime.util.test.js +210 -0
  89. package/dist/utils/__tests__/wakatime.util.test.js.map +1 -0
  90. package/dist/utils/activities.util.d.ts +15 -0
  91. package/dist/utils/activities.util.js +147 -0
  92. package/dist/utils/activities.util.js.map +1 -0
  93. package/dist/utils/allExceptions.filter.d.ts +7 -0
  94. package/dist/utils/allExceptions.filter.js +39 -0
  95. package/dist/utils/allExceptions.filter.js.map +1 -0
  96. package/dist/utils/codeClimberErrors.d.ts +16 -0
  97. package/dist/utils/codeClimberErrors.js +27 -0
  98. package/dist/utils/codeClimberErrors.js.map +1 -0
  99. package/dist/utils/constants.d.ts +1 -0
  100. package/dist/utils/constants.js +5 -0
  101. package/dist/utils/constants.js.map +1 -0
  102. package/dist/utils/environment.util.d.ts +1 -0
  103. package/dist/utils/environment.util.js +6 -0
  104. package/dist/utils/environment.util.js.map +1 -0
  105. package/dist/utils/helpers.util.d.ts +7 -0
  106. package/dist/utils/helpers.util.js +116 -0
  107. package/dist/utils/helpers.util.js.map +1 -0
  108. package/dist/utils/node.util.d.ts +7 -0
  109. package/dist/utils/node.util.js +26 -0
  110. package/dist/utils/node.util.js.map +1 -0
  111. package/dist/utils/sql.util.d.ts +1 -0
  112. package/dist/utils/sql.util.js +11 -0
  113. package/dist/utils/sql.util.js.map +1 -0
  114. package/dist/utils/sqlReader.util.d.ts +5 -0
  115. package/dist/utils/sqlReader.util.js +34 -0
  116. package/dist/utils/sqlReader.util.js.map +1 -0
  117. package/dist/utils/wakatime.util.d.ts +6 -0
  118. package/dist/utils/wakatime.util.js +63 -0
  119. package/dist/utils/wakatime.util.js.map +1 -0
  120. package/index.ts +5 -0
  121. package/jest.config.js +8 -0
  122. package/knexfile.js +14 -0
  123. package/nest-cli.json +15 -0
  124. package/package.json +77 -0
  125. package/src/app.module.ts +37 -0
  126. package/src/assets/startup.plist.ts +36 -0
  127. package/src/common/infrastructure/http/controllers/health.controller.ts +9 -0
  128. package/src/common/infrastructure/http/middleware/requestlogger.middleware.ts +22 -0
  129. package/src/main.ts +51 -0
  130. package/src/sentry.ts +14 -0
  131. package/src/types/activities.api.d.ts +18 -0
  132. package/src/types/time.api.d.ts +23 -0
  133. package/src/types/utils.d.ts +8 -0
  134. package/src/types/wakatimeProxy.api.d.ts +55 -0
  135. package/src/v1/activities/activities.service.ts +213 -0
  136. package/src/v1/activities/pulse.controller.ts +68 -0
  137. package/src/v1/activities/wakatimeProxy.controller.ts +33 -0
  138. package/src/v1/database/__tests__/knex.test.ts +18 -0
  139. package/src/v1/database/__tests__/pulse.repo.test.ts +209 -0
  140. package/src/v1/database/knex.ts +107 -0
  141. package/src/v1/database/migrations.ts +13 -0
  142. package/src/v1/database/models/pulse.d.ts +24 -0
  143. package/src/v1/database/pulse.repo.ts +132 -0
  144. package/src/v1/database/queries/getCategoryTimeOverview.sql +6 -0
  145. package/src/v1/database/queries/getLongestDayInRangeMinutes.sql +11 -0
  146. package/src/v1/database/queries/getStatusBarDetails.sql +42 -0
  147. package/src/v1/dtos/createWakatimePulse.dto.ts +66 -0
  148. package/src/v1/dtos/getCategoryTimeOverview.dto.ts +9 -0
  149. package/src/v1/dtos/getWeekOverview.dto.ts +6 -0
  150. package/src/v1/startup/darwinStartup.service.ts +114 -0
  151. package/src/v1/startup/linuxStartup.service.ts +101 -0
  152. package/src/v1/startup/startup.controller.ts +23 -0
  153. package/src/v1/startup/startup.util.ts +21 -0
  154. package/src/v1/startup/startupService.factory.ts +28 -0
  155. package/src/v1/startup/unsupportedStartup.service.ts +21 -0
  156. package/src/v1/v1.module.ts +28 -0
  157. package/test/app.e2e-spec.ts +24 -0
  158. package/test/jest-e2e.json +9 -0
  159. package/test/jest.globalSetup.js +15 -0
  160. package/test/jest.globalTeardown.js +8 -0
  161. package/tsconfig.build.json +4 -0
  162. package/tsconfig.json +22 -0
  163. package/utils/__tests__/activites.util.test.ts +18 -0
  164. package/utils/__tests__/helpers.util.test.ts +155 -0
  165. package/utils/__tests__/wakatime.util.test.ts +222 -0
  166. package/utils/activities.util.ts +193 -0
  167. package/utils/allExceptions.filter.ts +43 -0
  168. package/utils/codeClimberErrors.ts +32 -0
  169. package/utils/constants.ts +1 -0
  170. package/utils/environment.util.ts +1 -0
  171. package/utils/helpers.util.ts +131 -0
  172. package/utils/node.util.ts +29 -0
  173. package/utils/sql.util.ts +13 -0
  174. package/utils/sqlReader.util.ts +49 -0
  175. package/utils/wakatime.util.ts +78 -0
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.PulseController = void 0;
16
+ const common_1 = require("@nestjs/common");
17
+ const activities_service_1 = require("./activities.service");
18
+ const getCategoryTimeOverview_dto_1 = require("../dtos/getCategoryTimeOverview.dto");
19
+ const getWeekOverview_dto_1 = require("../dtos/getWeekOverview.dto");
20
+ let PulseController = class PulseController {
21
+ constructor(activitiesService) {
22
+ this.activitiesService = activitiesService;
23
+ this.activitiesService = activitiesService;
24
+ }
25
+ async latestPulses() {
26
+ const pulse = await this.activitiesService.getLatestPulses();
27
+ return { message: 'success', data: pulse };
28
+ }
29
+ async getWeekOverview(dto) {
30
+ const result = await this.activitiesService.getWeekOverview(dto.date);
31
+ return { message: 'success', data: result };
32
+ }
33
+ async getCategoryTimeOverview(times) {
34
+ const result = await this.activitiesService.getCategoryTimeOverview(times.startDate, times.endDate);
35
+ return { message: 'success', data: result };
36
+ }
37
+ async getSources() {
38
+ const sources = await this.activitiesService.getSources();
39
+ return { message: 'success', data: sources };
40
+ }
41
+ async exportPulses(response) {
42
+ try {
43
+ const csvBuffer = await this.activitiesService.generatePulsesCSV();
44
+ response.setHeader('Content-Type', 'text/csv');
45
+ response.setHeader('Content-Disposition', 'attachment; filename="pulses.csv"');
46
+ response.send(csvBuffer);
47
+ }
48
+ catch (error) {
49
+ console.error('Error exporting pulses CSV:', error);
50
+ response.status(500).send('Failed to export pulses');
51
+ }
52
+ }
53
+ };
54
+ exports.PulseController = PulseController;
55
+ __decorate([
56
+ (0, common_1.Get)('latest'),
57
+ __metadata("design:type", Function),
58
+ __metadata("design:paramtypes", []),
59
+ __metadata("design:returntype", Promise)
60
+ ], PulseController.prototype, "latestPulses", null);
61
+ __decorate([
62
+ (0, common_1.Get)('weekOverview'),
63
+ __param(0, (0, common_1.Query)()),
64
+ __metadata("design:type", Function),
65
+ __metadata("design:paramtypes", [getWeekOverview_dto_1.GetWeekOverviewDto]),
66
+ __metadata("design:returntype", Promise)
67
+ ], PulseController.prototype, "getWeekOverview", null);
68
+ __decorate([
69
+ (0, common_1.Get)('categoryTimeOverview'),
70
+ __param(0, (0, common_1.Query)()),
71
+ __metadata("design:type", Function),
72
+ __metadata("design:paramtypes", [getCategoryTimeOverview_dto_1.GetCategoryTimeOverviewDto]),
73
+ __metadata("design:returntype", Promise)
74
+ ], PulseController.prototype, "getCategoryTimeOverview", null);
75
+ __decorate([
76
+ (0, common_1.Get)('sources'),
77
+ __metadata("design:type", Function),
78
+ __metadata("design:paramtypes", []),
79
+ __metadata("design:returntype", Promise)
80
+ ], PulseController.prototype, "getSources", null);
81
+ __decorate([
82
+ (0, common_1.Get)('export'),
83
+ __param(0, (0, common_1.Res)()),
84
+ __metadata("design:type", Function),
85
+ __metadata("design:paramtypes", [Object]),
86
+ __metadata("design:returntype", Promise)
87
+ ], PulseController.prototype, "exportPulses", null);
88
+ exports.PulseController = PulseController = __decorate([
89
+ (0, common_1.Controller)('pulses'),
90
+ __metadata("design:paramtypes", [activities_service_1.ActivitiesService])
91
+ ], PulseController);
92
+ //# sourceMappingURL=pulse.controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pulse.controller.js","sourceRoot":"","sources":["../../../../src/v1/activities/pulse.controller.ts"],"names":[],"mappings":";;;;;;;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E,QAAQ,CAAC,SAAS,CAAC,cAAc,EAAE,UAAU,CAAC,CAAA;YAC9C,QAAQ,CAAC,SAAS,CAChB,qBAAqB,EACrB,mCAAmC,CACpC,CAAA;YACD,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;QAC1B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,6BAA6B,EAAE,KAAK,CAAC,CAAA;YACnD,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAA;QACtD,CAAC;IACH,CAAC;CACF,CAAA;AA5DY,0CAAe;AAKpB;IADL,IAAA,YAAG,EAAC,QAAQ,CAAC;;;;mDAOb;AAGK;IADL,IAAA,YAAG,EAAC,cAAc,CAAC;IAEjB,WAAA,IAAA,cAAK,GAAE,CAAA;;qCAAM,wCAAkB;;sDAKjC;AAGK;IADL,IAAA,YAAG,EAAC,sBAAsB,CAAC;IAEzB,WAAA,IAAA,cAAK,GAAE,CAAA;;qCAAQ,wDAA0B;;8DAQ3C;AAGK;IADL,IAAA,YAAG,EAAC,SAAS,CAAC;;;;iDASd;AAGK;IADL,IAAA,YAAG,EAAC,QAAQ,CAAC;IACM,WAAA,IAAA,YAAG,GAAE,CAAA;;;;mDAaxB;0BA3DU,eAAe;IAD3B,IAAA,mBAAU,EAAC,QAAQ,CAAC;qCAE6B,sCAAiB;GADtD,eAAe,CA4D3B"}
@@ -0,0 +1,13 @@
1
+ import { ActivitiesService } from './activities.service';
2
+ import { CreateWakatimePulseDto } from '../dtos/createWakatimePulse.dto';
3
+ export declare class WakatimeController {
4
+ private readonly activitiesService;
5
+ constructor(activitiesService: ActivitiesService);
6
+ getStatusBar(): Promise<CodeClimbers.ActivitiesStatusBar>;
7
+ createPulse(body: CreateWakatimePulseDto): Promise<{
8
+ Responses: number[][];
9
+ }>;
10
+ createPulses(body: CreateWakatimePulseDto[]): Promise<{
11
+ Responses: number[][];
12
+ }>;
13
+ }
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.WakatimeController = void 0;
16
+ const common_1 = require("@nestjs/common");
17
+ const activities_service_1 = require("./activities.service");
18
+ const createWakatimePulse_dto_1 = require("../dtos/createWakatimePulse.dto");
19
+ let WakatimeController = class WakatimeController {
20
+ constructor(activitiesService) {
21
+ this.activitiesService = activitiesService;
22
+ this.activitiesService = activitiesService;
23
+ }
24
+ async getStatusBar() {
25
+ const result = await this.activitiesService.getActivityStatusBar();
26
+ return result;
27
+ }
28
+ async createPulse(body) {
29
+ common_1.Logger.log(JSON.stringify(body), 'wakatimeProxy.controller');
30
+ const result = await this.activitiesService.createPulse(body);
31
+ return result;
32
+ }
33
+ async createPulses(body) {
34
+ common_1.Logger.log(JSON.stringify(body), 'wakatimeProxy.controller');
35
+ const result = await this.activitiesService.createPulses(body);
36
+ return result;
37
+ }
38
+ };
39
+ exports.WakatimeController = WakatimeController;
40
+ __decorate([
41
+ (0, common_1.Get)('users/current/statusbar/today'),
42
+ __metadata("design:type", Function),
43
+ __metadata("design:paramtypes", []),
44
+ __metadata("design:returntype", Promise)
45
+ ], WakatimeController.prototype, "getStatusBar", null);
46
+ __decorate([
47
+ (0, common_1.Post)('users/current/heartbeats'),
48
+ __param(0, (0, common_1.Body)()),
49
+ __metadata("design:type", Function),
50
+ __metadata("design:paramtypes", [createWakatimePulse_dto_1.CreateWakatimePulseDto]),
51
+ __metadata("design:returntype", Promise)
52
+ ], WakatimeController.prototype, "createPulse", null);
53
+ __decorate([
54
+ (0, common_1.Post)('users/current/heartbeats.bulk'),
55
+ __param(0, (0, common_1.Body)()),
56
+ __metadata("design:type", Function),
57
+ __metadata("design:paramtypes", [Array]),
58
+ __metadata("design:returntype", Promise)
59
+ ], WakatimeController.prototype, "createPulses", null);
60
+ exports.WakatimeController = WakatimeController = __decorate([
61
+ (0, common_1.Controller)('wakatime'),
62
+ __metadata("design:paramtypes", [activities_service_1.ActivitiesService])
63
+ ], WakatimeController);
64
+ //# sourceMappingURL=wakatimeProxy.controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wakatimeProxy.controller.js","sourceRoot":"","sources":["../../../../src/v1/activities/wakatimeProxy.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAoE;AACpE,6DAAwD;AACxD,6EAAwE;AAGjE,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAC7B,YAA6B,iBAAoC;QAApC,sBAAiB,GAAjB,iBAAiB,CAAmB;QAC/D,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAA;IAC5C,CAAC;IAEK,AAAN,KAAK,CAAC,YAAY;QAChB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,oBAAoB,EAAE,CAAA;QAClE,OAAO,MAAM,CAAA;IACf,CAAC;IAGK,AAAN,KAAK,CAAC,WAAW,CAAS,IAA4B;QAGpD,eAAM,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,0BAA0B,CAAC,CAAA;QAC5D,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;QAC7D,OAAO,MAAM,CAAA;IACf,CAAC;IAGK,AAAN,KAAK,CAAC,YAAY,CAAS,IAA8B;QAGvD,eAAM,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,0BAA0B,CAAC,CAAA;QAC5D,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;QAC9D,OAAO,MAAM,CAAA;IACf,CAAC;CACF,CAAA;AA3BY,gDAAkB;AAKvB;IADL,IAAA,YAAG,EAAC,+BAA+B,CAAC;;;;sDAIpC;AAGK;IADL,IAAA,aAAI,EAAC,0BAA0B,CAAC;IACd,WAAA,IAAA,aAAI,GAAE,CAAA;;qCAAO,gDAAsB;;qDAMrD;AAGK;IADL,IAAA,aAAI,EAAC,+BAA+B,CAAC;IAClB,WAAA,IAAA,aAAI,GAAE,CAAA;;;;sDAMzB;6BA1BU,kBAAkB;IAD9B,IAAA,mBAAU,EAAC,UAAU,CAAC;qCAE2B,sCAAiB;GADtD,kBAAkB,CA2B9B"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const knex_1 = require("../knex");
4
+ describe('knex', () => {
5
+ it('Should connect successfully', async () => {
6
+ await knex_1.knex.raw('SELECT 1').catch((e) => {
7
+ expect(e).toBeUndefined();
8
+ });
9
+ });
10
+ it('Should be using test path', () => {
11
+ expect(knex_1.knex.client.config.connection.filename).toEqual(knex_1.SQL_LITE_TEST_FILE);
12
+ });
13
+ });
14
+ afterAll((done) => {
15
+ knex_1.knex.destroy();
16
+ done();
17
+ });
18
+ //# sourceMappingURL=knex.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"knex.test.js","sourceRoot":"","sources":["../../../../../src/v1/database/__tests__/knex.test.ts"],"names":[],"mappings":";;AAAA,kCAAkD;AAElD,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE;IACpB,EAAE,CAAC,6BAA6B,EAAE,KAAK,IAAI,EAAE;QAC3C,MAAM,WAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;YACrC,MAAM,CAAC,CAAC,CAAC,CAAC,aAAa,EAAE,CAAA;QAC3B,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,2BAA2B,EAAE,GAAG,EAAE;QACnC,MAAM,CAAC,WAAI,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,yBAAkB,CAAC,CAAA;IAC5E,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA;AAEF,QAAQ,CAAC,CAAC,IAAI,EAAE,EAAE;IAChB,WAAI,CAAC,OAAO,EAAE,CAAA;IACd,IAAI,EAAE,CAAA;AACR,CAAC,CAAC,CAAA"}
@@ -0,0 +1,141 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const knex_1 = require("../knex");
4
+ const pulse_repo_1 = require("../pulse.repo");
5
+ const pulseRepo = new pulse_repo_1.PulseRepo(knex_1.knex);
6
+ describe('pulse.repo', () => {
7
+ const SECOND = 1_000;
8
+ const MINUTE = SECOND * 60;
9
+ const HOUR = MINUTE * 60;
10
+ const DAY = HOUR * 24;
11
+ const YEAR = DAY * 365;
12
+ const NOW = new Date();
13
+ NOW.setUTCHours(0, 0, 0, 0);
14
+ const TIMESTAMP = NOW.getTime();
15
+ it('Should get latest pulses', async () => {
16
+ const pulses = await pulseRepo.getLatestPulses();
17
+ expect(pulses.length).toEqual(10);
18
+ pulses.slice(0, 3).forEach((pulse) => {
19
+ expect(pulse.entity).toEqual('NEW');
20
+ });
21
+ });
22
+ it('Should get all pulses', async () => {
23
+ const pulses = await pulseRepo.getAllPulses();
24
+ expect(pulses.length).toEqual(102);
25
+ });
26
+ it('Should get minutes in range', async () => {
27
+ const endDate = new Date();
28
+ const startDate = new Date(endDate.getTime() - HOUR * 2);
29
+ const minutes = await pulseRepo.getRangeMinutes(startDate, endDate);
30
+ expect(minutes).toEqual(2);
31
+ });
32
+ it('Should get the longest day in minutes range', async () => {
33
+ const TEN_DAYS = DAY * 10;
34
+ const endDate = new Date();
35
+ endDate.setUTCHours(0, 0, 0, 0);
36
+ const startDate = new Date(endDate.getTime() - TEN_DAYS);
37
+ startDate.setUTCHours(0, 0, 0, 0);
38
+ const longestDay = await pulseRepo.getLongestDayInRangeMinutes(startDate, endDate);
39
+ expect(longestDay).toEqual(2);
40
+ });
41
+ it('Should get category time overview', async () => {
42
+ const TEN_DAYS = DAY * 10;
43
+ const endDate = new Date();
44
+ const startDate = new Date(endDate.getTime() - TEN_DAYS);
45
+ const categoryTimeOverview = await pulseRepo.getCategoryTimeOverview(startDate.toISOString(), endDate.toISOString());
46
+ expect(categoryTimeOverview.length).toEqual(2);
47
+ });
48
+ it('Should get the last project', async () => {
49
+ const lastProject = await pulseRepo.getLatestProject();
50
+ expect(lastProject).toEqual('Latest Project');
51
+ });
52
+ it('Should get unique user agents and last active', async () => {
53
+ const uniqueUserAgents = await pulseRepo.getUniqueUserAgentsAndLastActive();
54
+ expect(uniqueUserAgents.length).toEqual(3);
55
+ const vscode = uniqueUserAgents.find((n) => n.userAgent === 'vscode');
56
+ const VSCODE_LAST_ACTIVE = new Date(TIMESTAMP - DAY);
57
+ expect(vscode).toBeTruthy();
58
+ expect(vscode.lastActive).toEqual(VSCODE_LAST_ACTIVE.toISOString());
59
+ const chrome = uniqueUserAgents.find((n) => n.userAgent === 'chrome-chrome_extension');
60
+ const CHROME_LAST_ACTIVE = new Date(TIMESTAMP - DAY * 3);
61
+ expect(chrome).toBeTruthy();
62
+ expect(chrome.lastActive).toEqual(CHROME_LAST_ACTIVE.toISOString());
63
+ });
64
+ const dummyPulse = (time) => ({
65
+ userId: '1',
66
+ entity: 'NEW',
67
+ category: 'NEW',
68
+ time: time ?? new Date().toISOString(),
69
+ createdAt: time ?? new Date().toISOString(),
70
+ project: 'NEW',
71
+ type: '',
72
+ isWrite: false,
73
+ editor: '',
74
+ operatingSystem: '',
75
+ machine: '',
76
+ userAgent: '',
77
+ hash: String(Math.floor(new Date().getTime() / Math.random())),
78
+ });
79
+ it('Should create a pulse', async () => {
80
+ const createdPulse = await pulseRepo.createPulse(dummyPulse());
81
+ expect(createdPulse).toBeTruthy();
82
+ expect(createdPulse).toHaveLength(1);
83
+ });
84
+ it('Should create pulses', async () => {
85
+ const createdPulses = await pulseRepo.createPulses([
86
+ dummyPulse(),
87
+ dummyPulse(),
88
+ ]);
89
+ expect(createdPulses).toBeTruthy();
90
+ expect(createdPulses).toHaveLength(2);
91
+ });
92
+ it('Should group many heartbeats within a 2 minute period correctly', async () => {
93
+ const interval = SECOND * 10;
94
+ const timePeriod = 12;
95
+ const startDate = new Date(TIMESTAMP - YEAR);
96
+ const endDate = new Date(TIMESTAMP - YEAR + interval * timePeriod);
97
+ const pulses = [];
98
+ for (let i = 0; i < timePeriod; i++) {
99
+ pulses.push(dummyPulse(new Date(startDate.getTime() + i * interval).toISOString()));
100
+ }
101
+ await pulseRepo.createPulses(pulses);
102
+ const minutes = await pulseRepo.getRangeMinutes(startDate, endDate);
103
+ expect(minutes).toEqual(2);
104
+ });
105
+ it('Should group many heart beats at a different intervals correctly', async () => {
106
+ const timeAgo = TIMESTAMP - YEAR - DAY * 2;
107
+ const startDate = new Date(timeAgo);
108
+ const endDate = new Date(timeAgo + MINUTE * 45);
109
+ await pulseRepo.createPulses([
110
+ dummyPulse(new Date(startDate.getTime()).toISOString()),
111
+ dummyPulse(new Date(startDate.getTime() + MINUTE * 10).toISOString()),
112
+ dummyPulse(new Date(startDate.getTime() + MINUTE * 10 + SECOND * 9).toISOString()),
113
+ dummyPulse(new Date(startDate.getTime() + MINUTE * 10 + SECOND * 5).toISOString()),
114
+ dummyPulse(new Date(startDate.getTime() + MINUTE * 20).toISOString()),
115
+ dummyPulse(new Date(startDate.getTime() + MINUTE * 20 + SECOND * 5).toISOString()),
116
+ dummyPulse(new Date(startDate.getTime() + MINUTE * 30).toISOString()),
117
+ ]);
118
+ const minutes = await pulseRepo.getRangeMinutes(startDate, endDate);
119
+ expect(minutes).toEqual(8);
120
+ });
121
+ it('Should group heartbeats at the end of the day correctly', async () => {
122
+ const timeAgo = TIMESTAMP - YEAR - DAY * 14;
123
+ const startDate = new Date(timeAgo);
124
+ const endDate = new Date(timeAgo + DAY * 7);
125
+ await pulseRepo.createPulses([
126
+ dummyPulse(new Date(startDate.getTime()).toISOString()),
127
+ dummyPulse(new Date(startDate.getTime() - MINUTE).toISOString()),
128
+ dummyPulse(new Date(startDate.getTime() + DAY - MINUTE).toISOString()),
129
+ dummyPulse(new Date(startDate.getTime() + DAY).toISOString()),
130
+ dummyPulse(new Date(startDate.getTime() + DAY + MINUTE).toISOString()),
131
+ dummyPulse(new Date(startDate.getTime() + DAY + MINUTE * 2).toISOString()),
132
+ ]);
133
+ const minutes = await pulseRepo.getLongestDayInRangeMinutes(startDate, endDate);
134
+ expect(minutes).toEqual(3);
135
+ });
136
+ });
137
+ afterAll((done) => {
138
+ knex_1.knex.destroy();
139
+ done();
140
+ });
141
+ //# sourceMappingURL=pulse.repo.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pulse.repo.test.js","sourceRoot":"","sources":["../../../../../src/v1/database/__tests__/pulse.repo.test.ts"],"names":[],"mappings":";;AAAA,kCAA8B;AAC9B,8CAAyC;AAEzC,MAAM,SAAS,GAAG,IAAI,sBAAS,CAAC,WAAI,CAAC,CAAA;AAErC,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,MAAM,MAAM,GAAG,KAAK,CAAA;IACpB,MAAM,MAAM,GAAG,MAAM,GAAG,EAAE,CAAA;IAC1B,MAAM,IAAI,GAAG,MAAM,GAAG,EAAE,CAAA;IACxB,MA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,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC;YACtE,UAAU,CAAC,IAAI,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,GAAG,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;YAC7D,UAAU,CAAC,IAAI,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,GAAG,GAAG,GAAG,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC;YACtE,UAAU,CACR,IAAI,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,GAAG,GAAG,GAAG,MAAM,GAAG,CAAC,CAAC,CAAC,WAAW,EAAE,CAC/D;SACF,CAAC,CAAA;QAEF,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,2BAA2B,CACzD,SAAS,EACT,OAAO,CACR,CAAA;QAED,MAAM,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;IAC5B,CAAC,CAAC,CAAA;AAGJ,CAAC,CAAC,CAAA;AAEF,QAAQ,CAAC,CAAC,IAAI,EAAE,EAAE;IAChB,WAAI,CAAC,OAAO,EAAE,CAAA;IACd,IAAI,EAAE,CAAA;AACR,CAAC,CAAC,CAAA"}
@@ -0,0 +1,5 @@
1
+ import Knex from 'knex';
2
+ export declare const SQL_LITE_TEST_FILE = "codeclimber.test.sqlite";
3
+ export declare const knex: Knex.Knex<any, unknown[]>;
4
+ export declare class DbModule {
5
+ }
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.DbModule = exports.knex = exports.SQL_LITE_TEST_FILE = void 0;
10
+ const knex_1 = require("knex");
11
+ const common_1 = require("@nestjs/common");
12
+ const nestjs_knex_1 = require("nestjs-knex");
13
+ const path = require("path");
14
+ const helpers_util_1 = require("../../../utils/helpers.util");
15
+ const node_util_1 = require("../../../utils/node.util");
16
+ const deepMapKeys = function (obj, fn) {
17
+ const x = {};
18
+ (0, helpers_util_1.forOwn)(obj, function (v, k) {
19
+ if (Array.isArray(v)) {
20
+ v = v.map(function (x) {
21
+ return (0, helpers_util_1.isPlainObject)(x) ? deepMapKeys(x, fn) : x;
22
+ });
23
+ }
24
+ if ((0, helpers_util_1.isPlainObject)(v)) {
25
+ v = deepMapKeys(v, fn);
26
+ }
27
+ x[fn(v, k)] = v;
28
+ });
29
+ return x;
30
+ };
31
+ const postProcessResponse = (result) => {
32
+ if (!result) {
33
+ return result;
34
+ }
35
+ return camelCaseKeys(result);
36
+ };
37
+ const wrapIdentifier = (value, origImpl) => {
38
+ if ((0, helpers_util_1.snakeCase)(value)) {
39
+ return origImpl((0, helpers_util_1.snakeCase)(value));
40
+ }
41
+ else {
42
+ return origImpl(value);
43
+ }
44
+ };
45
+ const camelCaseKeys = (obj) => {
46
+ if (Array.isArray(obj)) {
47
+ return obj.map((row) => {
48
+ return deepMapKeys(row, (v, k) => (0, helpers_util_1.camelCase)(k));
49
+ });
50
+ }
51
+ else {
52
+ return deepMapKeys(obj, (v, k) => (0, helpers_util_1.camelCase)(k));
53
+ }
54
+ };
55
+ const IS_TEST = process.env.NODE_ENV === 'test';
56
+ (0, node_util_1.initDBDir)();
57
+ exports.SQL_LITE_TEST_FILE = 'codeclimber.test.sqlite';
58
+ const knexConfig = {
59
+ client: 'sqlite3',
60
+ connection: {
61
+ filename: IS_TEST ? exports.SQL_LITE_TEST_FILE : node_util_1.DB_PATH,
62
+ },
63
+ migrations: {
64
+ directory: path.join(node_util_1.BIN_PATH, 'migrations'),
65
+ tableName: 'knex_migrations',
66
+ },
67
+ seeds: {
68
+ directory: path.join(node_util_1.BIN_PATH, 'seeds'),
69
+ },
70
+ useNullAsDefault: true,
71
+ postProcessResponse,
72
+ wrapIdentifier,
73
+ };
74
+ exports.knex = (0, knex_1.default)(knexConfig);
75
+ const knexModule = nestjs_knex_1.KnexModule.forRoot({
76
+ config: knexConfig,
77
+ });
78
+ let DbModule = class DbModule {
79
+ };
80
+ exports.DbModule = DbModule;
81
+ exports.DbModule = DbModule = __decorate([
82
+ (0, common_1.Module)({
83
+ imports: [knexModule],
84
+ exports: [knexModule],
85
+ })
86
+ ], DbModule);
87
+ //# sourceMappingURL=knex.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"knex.js","sourceRoot":"","sources":["../../../../src/v1/database/knex.ts"],"names":[],"mappings":";;;;;;;;;AACA,+BAA8C;AAE9C,2CAAuC;AACvC,6CAAwC;AACxC,6BAA4B;AAC5B,8DAKoC;AACpC,wDAAuE;AAEvE,MAAM,WAAW,GAAG,UAAU,GAAQ,EAAE,EAAO;IAC7C,MAAM,CAAC,GAA2B,EAAE,CAAA;IAEpC,IAAA,qBAAM,EAAC,GAAG,EAAE,UAAU,CAAC,EAAE,CAAC;QACxB,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;YACrB,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC;gBACnB,OAAO,IAAA,4BAAa,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;YAClD,CAAC,CAAC,CAAA;QACJ,CAAC;QACD,IAAI,IAAA,4BAAa,EAAC,CAAC,CAAC,EAAE,CAAC;YACrB,CAAC,GAAG,WAAW,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;QACxB,CAAC;QACD,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG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AU,EAAE;QACV,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,0BAAkB,CAAC,CAAC,CAAC,mBAAO;KACjD;IACD,UAAU,EAAE;QACV,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,oBAAQ,EAAE,YAAY,CAAC;QAC5C,SAAS,EAAE,iBAAiB;KAC7B;IACD,KAAK,EAAE;QACL,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,oBAAQ,EAAE,OAAO,CAAC;KACxC;IACD,gBAAgB,EAAE,IAAI;IACtB,mBAAmB;IACnB,cAAc;CAgBf,CAAA;AAEY,QAAA,IAAI,GAAG,IAAA,cAAI,EAAC,UAAU,CAAC,CAAA;AAEpC,MAAM,UAAU,GAAG,wBAAU,CAAC,OAAO,CAAC;IACpC,MAAM,EAAE,UAAU;CACnB,CAAC,CAAA;AAMK,IAAM,QAAQ,GAAd,MAAM,QAAQ;CAAG,CAAA;AAAX,4BAAQ;mBAAR,QAAQ;IAJpB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,UAAU,CAAC;QACrB,OAAO,EAAE,CAAC,UAAU,CAAC;KACtB,CAAC;GACW,QAAQ,CAAG"}
@@ -0,0 +1 @@
1
+ export declare const startMigrations: () => Promise<void>;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.startMigrations = void 0;
4
+ const common_1 = require("@nestjs/common");
5
+ const knex_1 = require("./knex");
6
+ const startMigrations = async () => {
7
+ common_1.Logger.log('Running Migrations');
8
+ try {
9
+ await knex_1.knex.migrate.latest();
10
+ }
11
+ finally {
12
+ common_1.Logger.log('Migrations Complete');
13
+ }
14
+ };
15
+ exports.startMigrations = startMigrations;
16
+ //# sourceMappingURL=migrations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrations.js","sourceRoot":"","sources":["../../../../src/v1/database/migrations.ts"],"names":[],"mappings":";;;AAAA,2CAAuC;AACvC,iCAA6B;AAEtB,MAAM,eAAe,GAAG,KAAK,IAAI,EAAE;IACxC,eAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAA;IAEhC,IAAI,CAAC;QAEH,MAAM,WAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAA;IAC7B,CAAC;YAAS,CAAC;QACT,eAAM,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAA;IACnC,CAAC;AACH,CAAC,CAAA;AATY,QAAA,eAAe,mBAS3B"}
@@ -0,0 +1,17 @@
1
+ import { Knex } from 'nestjs-knex';
2
+ export declare class PulseRepo {
3
+ private readonly knex;
4
+ constructor(knex: Knex);
5
+ tableName: string;
6
+ getStatusBarDetails(): Promise<CodeClimbers.WakatimePulseStatusDao[]>;
7
+ getLatestPulses(): Promise<CodeClimbers.Pulse[] | undefined>;
8
+ getAllPulses(): Promise<CodeClimbers.Pulse[] | undefined>;
9
+ getMinutesInRangeQuery(startDate: Date, endDate: Date): import("knex").Knex.QueryBuilder<{}, any>;
10
+ getLongestDayInRangeMinutes(startDate: Date, endDate: Date): Promise<number>;
11
+ getRangeMinutes(startDate: Date, endDate: Date): Promise<number>;
12
+ getCategoryTimeOverview(startDate: string, endDate: string): Promise<CodeClimbers.TimeOverview[]>;
13
+ createPulse(pulse: CodeClimbers.Pulse): Promise<CodeClimbers.Pulse[]>;
14
+ createPulses(pulses: CodeClimbers.Pulse[]): Promise<CodeClimbers.Pulse[]>;
15
+ getUniqueUserAgentsAndLastActive(): Promise<any[]>;
16
+ getLatestProject(): Promise<string | undefined>;
17
+ }
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.PulseRepo = void 0;
16
+ const common_1 = require("@nestjs/common");
17
+ const nestjs_knex_1 = require("nestjs-knex");
18
+ const sqlReader_util_1 = require("../../../utils/sqlReader.util");
19
+ const dayjs = require("dayjs");
20
+ let PulseRepo = class PulseRepo {
21
+ constructor(knex) {
22
+ this.knex = knex;
23
+ this.tableName = 'activities_pulse';
24
+ }
25
+ async getStatusBarDetails() {
26
+ const startOfDay = dayjs().startOf('day').toISOString();
27
+ const endOfDay = dayjs().endOf('day').toISOString();
28
+ const getTimeQuery = await sqlReader_util_1.default.getFileContentAsString('getStatusBarDetails.sql');
29
+ return this.knex.raw(getTimeQuery, { startOfDay, endOfDay });
30
+ }
31
+ async getLatestPulses() {
32
+ const res = await this.knex(this.tableName)
33
+ .orderBy('created_at', 'desc')
34
+ .limit(10);
35
+ return res;
36
+ }
37
+ async getAllPulses() {
38
+ const res = await this.knex(this.tableName).orderBy('created_at', 'desc');
39
+ return res;
40
+ }
41
+ getMinutesInRangeQuery(startDate, endDate) {
42
+ return this.knex(this.tableName)
43
+ .select(this.knex.raw('count(*) * 2 as minutes'))
44
+ .from(this.tableName)
45
+ .whereBetween('time', [startDate.toISOString(), endDate.toISOString()])
46
+ .groupBy(this.knex.raw("strftime('%s', time) / 120"));
47
+ }
48
+ async getLongestDayInRangeMinutes(startDate, endDate) {
49
+ const getLongestDayMinutesQuery = await sqlReader_util_1.default.getFileContentAsString('getLongestDayInRangeMinutes.sql');
50
+ const [result] = await this.knex.raw(getLongestDayMinutesQuery, {
51
+ startDate: startDate.toISOString(),
52
+ endDate: endDate.toISOString(),
53
+ });
54
+ return result.minutes;
55
+ }
56
+ async getRangeMinutes(startDate, endDate) {
57
+ const result = await this.knex(this.tableName)
58
+ .with('getMinutes', this.getMinutesInRangeQuery(startDate, endDate))
59
+ .select(this.knex.raw('count(*) * 2 as minutes'))
60
+ .first()
61
+ .from('getMinutes');
62
+ return result.minutes;
63
+ }
64
+ async getCategoryTimeOverview(startDate, endDate) {
65
+ const query = this.knex(this.tableName)
66
+ .select(this.knex.raw('category, count(*) * 2'))
67
+ .from(this.tableName)
68
+ .whereBetween('time', [startDate, endDate])
69
+ .groupBy(this.knex.raw("strftime('%s', time) / 120"));
70
+ return await this.knex(this.tableName)
71
+ .with('getMinutes', query)
72
+ .select(this.knex.raw('category, count() * 2 as minutes'))
73
+ .groupBy('category')
74
+ .from('getMinutes');
75
+ }
76
+ async createPulse(pulse) {
77
+ common_1.Logger.log('Creating pulse', 'pulse.repo');
78
+ const res = await this.knex(this.tableName)
79
+ .insert(pulse)
80
+ .returning('*');
81
+ return res;
82
+ }
83
+ async createPulses(pulses) {
84
+ common_1.Logger.log('Creating pulses', 'pulse.repo');
85
+ const res = await this.knex(this.tableName)
86
+ .insert(pulses)
87
+ .returning('*');
88
+ common_1.Logger.log(`created ${pulses.length} pulses`, 'pulse.repo');
89
+ return res;
90
+ }
91
+ async getUniqueUserAgentsAndLastActive() {
92
+ const res = await this.knex(this.tableName)
93
+ .select('user_agent', this.knex.raw('MAX(created_at) as last_active'))
94
+ .groupBy('user_agent')
95
+ .orderBy('last_active', 'desc');
96
+ return res;
97
+ }
98
+ async getLatestProject() {
99
+ const res = await this.knex(this.tableName)
100
+ .select('project')
101
+ .whereNotNull('project')
102
+ .whereNotIn('project', ['', '<<LAST_PROJECT>>'])
103
+ .andWhere('time', '<', "datetime('now', '-15 minutes')")
104
+ .orderBy('time', 'desc')
105
+ .first();
106
+ return await res?.project;
107
+ }
108
+ };
109
+ exports.PulseRepo = PulseRepo;
110
+ exports.PulseRepo = PulseRepo = __decorate([
111
+ (0, common_1.Injectable)(),
112
+ __param(0, (0, nestjs_knex_1.InjectKnex)()),
113
+ __metadata("design:paramtypes", [Function])
114
+ ], PulseRepo);
115
+ //# sourceMappingURL=pulse.repo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pulse.repo.js","sourceRoot":"","sources":["../../../../src/v1/database/pulse.repo.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAmD;AACnD,6CAA8C;AAC9C,kEAAyD;AACzD,+BAA8B;AAOvB,IAAM,SAAS,GAAf,MAAM,SAAS;IACpB,YAA0B,IAA2B;QAAV,SAAI,GAAJ,IAAI,CAAM;QAErD,cAAS,GAAG,kBAAkB,CAAA;IAF0B,CAAC;IAIzD,KAAK,CAAC,mBAAmB;QACvB,MAAM,UAAU,GAAG,KAAK,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAA;QACvD,MAAM,QAAQ,GAAG,KAAK,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAA;QACnD,MAAM,YAAY,GAAG,MAAM,wBAAa,CAAC,sBAAsB,CAC7D,yBAAyB,CAC1B,CAAA;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC,CAAA;IAC9D,CAAC;IAED,KAAK,CAAC,eAAe;QACnB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAqB,IAAI,CAAC,SAAS,CAAC;aAC5D,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC;aAC7B,KAAK,CAAC,EAAE,CAAC,CAAA;QACZ,OAAO,GAAG,CAAA;IACZ,CAAC;IAED,KAAK,CAAC,YAAY;QAChB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAqB,IAAI,CAAC,SAAS,CAAC,CAAC,OAAO,CACrE,YAAY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AAM,SAAS,EAAE,YAAY,CAAC,CAAA;QAC3D,OAAO,GAAG,CAAA;IACZ,CAAC;IAGD,KAAK,CAAC,gCAAgC;QACpC,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAqB,IAAI,CAAC,SAAS,CAAC;aAC5D,MAAM,CAAC,YAAY,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;aACrE,OAAO,CAAC,YAAY,CAAC;aACrB,OAAO,CAAC,aAAa,EAAE,MAAM,CAAC,CAAA;QACjC,OAAO,GAAG,CAAA;IACZ,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAqB,IAAI,CAAC,SAAS,CAAC;aAC5D,MAAM,CAAC,SAAS,CAAC;aACjB,YAAY,CAAC,SAAS,CAAC;aACvB,UAAU,CAAC,SAAS,EAAE,CAAC,EAAE,EAAE,kBAAkB,CAAC,CAAC;aAC/C,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE,gCAAgC,CAAC;aACvD,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC;aACvB,KAAK,EAAE,CAAA;QAEV,OAAO,MAAM,GAAG,EAAE,OAAO,CAAA;IAC3B,CAAC;CACF,CAAA;AAzHY,8BAAS;oBAAT,SAAS;IADrB,IAAA,mBAAU,GAAE;IAEE,WAAA,IAAA,wBAAU,GAAE,CAAA;;GADd,SAAS,CAyHrB"}
@@ -0,0 +1,6 @@
1
+ SELECT category, count() AS minutes
2
+ FROM (SELECT category, count()
3
+ FROM activities_pulse
4
+ WHERE date(activities_pulse.time) BETWEEN :startDate AND :endDate
5
+ GROUP BY strftime('%s', time) / 60)
6
+ GROUP BY category