• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

teableio / teable / 11517127595

25 Oct 2024 11:12AM UTC coverage: 84.655% (-0.05%) from 84.702%
11517127595

Pull #1026

github

web-flow
Merge 5d20e9fa1 into 706b1c8d0
Pull Request #1026: feat: queue job

5820 of 6110 branches covered (95.25%)

242 of 291 new or added lines in 14 files covered. (83.16%)

14 existing lines in 1 file now uncovered.

38358 of 45311 relevant lines covered (84.65%)

1638.41 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

91.67
/apps/nestjs-backend/src/features/attachments/attachments-table.processor.ts
1
import { InjectQueue, Processor } from '@nestjs/bullmq';
4✔
2
import { Injectable, Logger } from '@nestjs/common';
4✔
3
import { UploadType } from '@teable/openapi';
4✔
4
import { Queue } from 'bullmq';
4✔
5
import type { Job } from 'bullmq';
4✔
6
import { AttachmentsStorageService } from '../attachments/attachments-storage.service';
4✔
7
import StorageAdapter from '../attachments/plugins/adapter';
4✔
8

4✔
9
export enum AttachmentJobName {
4✔
10
  CropImage = 'cropImage',
4✔
11
}
4✔
12

4✔
13
interface IRecordImageJob {
4✔
14
  tableId: string;
4✔
15
  attachmentItem?: {
4✔
16
    path: string;
4✔
17
    mimetype: string;
4✔
18
    lgThumbnailUrl?: string;
4✔
19
    smThumbnailUrl?: string;
4✔
20
  };
4✔
21
}
4✔
22

4✔
23
export const ATTACHMENTS_TABLE_QUEUE = 'attachments-table-queue';
4✔
24

4✔
25
@Injectable()
4✔
26
@Processor(ATTACHMENTS_TABLE_QUEUE)
4✔
27
export class AttachmentsTableQueueProcessor {
4✔
28
  private logger = new Logger(AttachmentsTableQueueProcessor.name);
395✔
29
  constructor(
395✔
30
    private readonly attachmentsStorageService: AttachmentsStorageService,
395✔
31
    @InjectQueue(ATTACHMENTS_TABLE_QUEUE) public readonly queue: Queue<IRecordImageJob>
395✔
32
  ) {}
395✔
33

395✔
34
  public async process(job: Job<IRecordImageJob>) {
395✔
35
    const { tableId, attachmentItem } = job.data;
2✔
36
    if (!attachmentItem) {
2✔
NEW
37
      return;
×
NEW
38
    }
×
39
    const tableBucket = StorageAdapter.getBucket(UploadType.Table);
2✔
40
    const { path, mimetype, lgThumbnailUrl, smThumbnailUrl } = attachmentItem;
2✔
41
    if (mimetype.startsWith('image/') && !smThumbnailUrl && !lgThumbnailUrl) {
2✔
42
      await this.attachmentsStorageService.cropTableImage(tableBucket, path);
2✔
43
      this.logger.log(`crop table(${tableId}) path(${path}) thumbnails success`);
2✔
44
      return;
2✔
45
    }
2✔
NEW
46
    this.logger.log(`table(${tableId}) path(${path}) image is not a image`);
×
NEW
47
  }
×
48
}
395✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc