Sfoglia il codice sorgente

Merge branch 'feat/7015-cache-CRUD' into fix/7183-enable-view-submission-in-check-command-permission-middleware

Taichi Masuyama 4 anni fa
parent
commit
315d747b9b

+ 2 - 7
packages/slackbot-proxy/src/entities/relation-mock.ts

@@ -1,7 +1,7 @@
+import { differenceInMilliseconds } from 'date-fns';
 import {
 import {
   Column, CreateDateColumn, Entity, PrimaryGeneratedColumn, UpdateDateColumn, ManyToOne, Index,
   Column, CreateDateColumn, Entity, PrimaryGeneratedColumn, UpdateDateColumn, ManyToOne, Index,
 } from 'typeorm';
 } from 'typeorm';
-import { differenceInMilliseconds } from 'date-fns';
 import { Installation } from './installation';
 import { Installation } from './installation';
 
 
 
 
@@ -50,14 +50,9 @@ export class RelationMock {
   @Column({ type: 'json' })
   @Column({ type: 'json' })
   permittedChannelsForEachCommand : PermittedChannelsForEachCommand
   permittedChannelsForEachCommand : PermittedChannelsForEachCommand
 
 
-  @CreateDateColumn()
+  @Column({ type: 'timestamp' })
   expiredAtCommands: Date;
   expiredAtCommands: Date;
 
 
-  isExpiredCommands():boolean {
-    const now = Date.now();
-    return this.expiredAtCommands.getTime() < now;
-  }
-
   getDistanceInMillisecondsToExpiredAt(baseDate:Date):number {
   getDistanceInMillisecondsToExpiredAt(baseDate:Date):number {
     return differenceInMilliseconds(this.expiredAtCommands, baseDate);
     return differenceInMilliseconds(this.expiredAtCommands, baseDate);
   }
   }

+ 3 - 7
packages/slackbot-proxy/src/entities/relation.ts

@@ -1,7 +1,7 @@
+import { differenceInMilliseconds } from 'date-fns';
 import {
 import {
   Column, CreateDateColumn, Entity, PrimaryGeneratedColumn, UpdateDateColumn, ManyToOne, Index,
   Column, CreateDateColumn, Entity, PrimaryGeneratedColumn, UpdateDateColumn, ManyToOne, Index,
 } from 'typeorm';
 } from 'typeorm';
-import { differenceInMilliseconds } from 'date-fns';
 import { Installation } from './installation';
 import { Installation } from './installation';
 
 
 @Entity()
 @Entity()
@@ -37,15 +37,11 @@ export class Relation {
   @Column('simple-array')
   @Column('simple-array')
   supportedCommandsForSingleUse: string[];
   supportedCommandsForSingleUse: string[];
 
 
-  @CreateDateColumn()
+  @Column({ type: 'timestamp' })
   expiredAtCommands: Date;
   expiredAtCommands: Date;
 
 
-  isExpiredCommands():boolean {
-    const now = Date.now();
-    return this.expiredAtCommands.getTime() < now;
-  }
-
   getDistanceInMillisecondsToExpiredAt(baseDate:Date):number {
   getDistanceInMillisecondsToExpiredAt(baseDate:Date):number {
+    // differenceInMilliseconds uses Date.prototype.getTime() internally
     return differenceInMilliseconds(this.expiredAtCommands, baseDate);
     return differenceInMilliseconds(this.expiredAtCommands, baseDate);
   }
   }
 
 

+ 1 - 1
packages/slackbot-proxy/src/services/RelationsService.ts

@@ -90,7 +90,7 @@ export class RelationsService {
     }
     }
 
 
     // 24 hours
     // 24 hours
-    if (distanceMillisecondsToExpiredAt < 1000 * 60 * 60 * 24) {
+    if (distanceMillisecondsToExpiredAt < 24 * 60 * 60 * 1000) {
       try {
       try {
         this.syncSupportedGrowiCommands(relationMock);
         this.syncSupportedGrowiCommands(relationMock);
       }
       }