diff --git a/api/model/snapshot_model.go b/api/model/snapshot_model.go index 998aa21de..fcca70be3 100644 --- a/api/model/snapshot_model.go +++ b/api/model/snapshot_model.go @@ -26,7 +26,7 @@ type Snapshot interface { GetOCR() *S3Object GetEntities() *S3Object GetMosaic() *S3Object - GetMobile() *S3Object + GetSegmentation() *S3Object GetThumbnail() *S3Object GetTaskID() *string HasOriginal() bool @@ -35,7 +35,7 @@ type Snapshot interface { HasOCR() bool HasEntities() bool HasMosaic() bool - HasMobile() bool + HasSegmentation() bool HasThumbnail() bool GetStatus() string GetLanguage() *string @@ -49,7 +49,7 @@ type Snapshot interface { SetOCR(*S3Object) SetEntities(*S3Object) SetMosaic(*S3Object) - SetMobile(*S3Object) + SetSegmentation(*S3Object) SetThumbnail(*S3Object) SetStatus(string) SetLanguage(string) diff --git a/api/repo/snapshot_repo.go b/api/repo/snapshot_repo.go index dc04478e1..92c0e2016 100644 --- a/api/repo/snapshot_repo.go +++ b/api/repo/snapshot_repo.go @@ -56,21 +56,21 @@ func NewSnapshot() model.Snapshot { } type snapshotEntity struct { - ID string `gorm:"column:id;size:36" json:"id"` - Version int64 `gorm:"column:version" json:"version"` - Original datatypes.JSON `gorm:"column:original" json:"original,omitempty"` - Preview datatypes.JSON `gorm:"column:preview" json:"preview,omitempty"` - Text datatypes.JSON `gorm:"column:text" json:"text,omitempty"` - OCR datatypes.JSON `gorm:"column:ocr" json:"ocr,omitempty"` - Entities datatypes.JSON `gorm:"column:entities" json:"entities,omitempty"` - Mosaic datatypes.JSON `gorm:"column:mosaic" json:"mosaic,omitempty"` - Mobile datatypes.JSON `gorm:"column:mobile" json:"mobile,omitempty"` - Thumbnail datatypes.JSON `gorm:"column:thumbnail" json:"thumbnail,omitempty"` - Status string `gorm:"column,status" json:"status,omitempty"` - Language *string `gorm:"column:language" json:"language,omitempty"` - TaskID *string `gorm:"column:task_id" json:"taskId,omitempty"` - CreateTime string `gorm:"column:create_time" json:"createTime"` - UpdateTime *string `gorm:"column:update_time" json:"updateTime,omitempty"` + ID string `gorm:"column:id;size:36" json:"id"` + Version int64 `gorm:"column:version" json:"version"` + Original datatypes.JSON `gorm:"column:original" json:"original,omitempty"` + Preview datatypes.JSON `gorm:"column:preview" json:"preview,omitempty"` + Text datatypes.JSON `gorm:"column:text" json:"text,omitempty"` + OCR datatypes.JSON `gorm:"column:ocr" json:"ocr,omitempty"` + Entities datatypes.JSON `gorm:"column:entities" json:"entities,omitempty"` + Mosaic datatypes.JSON `gorm:"column:mosaic" json:"mosaic,omitempty"` + Segmentation datatypes.JSON `gorm:"column:segmentation" json:"segmentation,omitempty"` + Thumbnail datatypes.JSON `gorm:"column:thumbnail" json:"thumbnail,omitempty"` + Status string `gorm:"column,status" json:"status,omitempty"` + Language *string `gorm:"column:language" json:"language,omitempty"` + TaskID *string `gorm:"column:task_id" json:"taskId,omitempty"` + CreateTime string `gorm:"column:create_time" json:"createTime"` + UpdateTime *string `gorm:"column:update_time" json:"updateTime,omitempty"` } func (*snapshotEntity) TableName() string { @@ -168,12 +168,12 @@ func (s *snapshotEntity) GetMosaic() *model.S3Object { return &res } -func (s *snapshotEntity) GetMobile() *model.S3Object { - if s.Mobile.String() == "" { +func (s *snapshotEntity) GetSegmentation() *model.S3Object { + if s.Segmentation.String() == "" { return nil } res := model.S3Object{} - if err := json.Unmarshal([]byte(s.Mobile.String()), &res); err != nil { + if err := json.Unmarshal([]byte(s.Segmentation.String()), &res); err != nil { log.GetLogger().Fatal(err) return nil } @@ -302,16 +302,16 @@ func (s *snapshotEntity) SetMosaic(m *model.S3Object) { } } -func (s *snapshotEntity) SetMobile(m *model.S3Object) { +func (s *snapshotEntity) SetSegmentation(m *model.S3Object) { if m == nil { - s.Mobile = nil + s.Segmentation = nil } else { b, err := json.Marshal(m) if err != nil { log.GetLogger().Fatal(err) return } - if err := s.Mobile.UnmarshalJSON(b); err != nil { + if err := s.Segmentation.UnmarshalJSON(b); err != nil { log.GetLogger().Fatal(err) } } @@ -368,8 +368,8 @@ func (s *snapshotEntity) HasMosaic() bool { return s.Mosaic != nil } -func (s *snapshotEntity) HasMobile() bool { - return s.Mobile != nil +func (s *snapshotEntity) HasSegmentation() bool { + return s.Segmentation != nil } func (s *snapshotEntity) HasThumbnail() bool { @@ -468,32 +468,32 @@ func (repo *snapshotRepo) Delete(id string) error { } type SnapshotUpdateOptions struct { - Fields []string `json:"fields"` - Original *model.S3Object - Preview *model.S3Object - Text *model.S3Object - OCR *model.S3Object - Entities *model.S3Object - Mosaic *model.S3Object - Mobile *model.S3Object - Thumbnail *model.S3Object - Status *string - Language *string - TaskID *string + Fields []string `json:"fields"` + Original *model.S3Object + Preview *model.S3Object + Text *model.S3Object + OCR *model.S3Object + Entities *model.S3Object + Mosaic *model.S3Object + Segmentation *model.S3Object + Thumbnail *model.S3Object + Status *string + Language *string + TaskID *string } const ( - SnapshotFieldOriginal = "original" - SnapshotFieldPreview = "preview" - SnapshotFieldText = "text" - SnapshotFieldOCR = "ocr" - SnapshotFieldEntities = "entities" - SnapshotFieldMosaic = "mosaic" - SnapshotFieldMobile = "mobile" - SnapshotFieldThumbnail = "thumbnail" - SnapshotFieldStatus = "status" - SnapshotFieldLanguage = "language" - SnapshotFieldTaskID = "taskId" + SnapshotFieldOriginal = "original" + SnapshotFieldPreview = "preview" + SnapshotFieldText = "text" + SnapshotFieldOCR = "ocr" + SnapshotFieldEntities = "entities" + SnapshotFieldMosaic = "mosaic" + SnapshotFieldSegmentation = "segmentation" + SnapshotFieldThumbnail = "thumbnail" + SnapshotFieldStatus = "status" + SnapshotFieldLanguage = "language" + SnapshotFieldTaskID = "taskId" ) func (repo *snapshotRepo) Update(id string, opts SnapshotUpdateOptions) error { @@ -519,8 +519,8 @@ func (repo *snapshotRepo) Update(id string, opts SnapshotUpdateOptions) error { if slices.Contains(opts.Fields, SnapshotFieldMosaic) { snapshot.SetMosaic(opts.Mosaic) } - if slices.Contains(opts.Fields, SnapshotFieldMobile) { - snapshot.SetMobile(opts.Mobile) + if slices.Contains(opts.Fields, SnapshotFieldSegmentation) { + snapshot.SetSegmentation(opts.Segmentation) } if slices.Contains(opts.Fields, SnapshotFieldThumbnail) { snapshot.SetThumbnail(opts.Thumbnail) diff --git a/api/router/file_router.go b/api/router/file_router.go index 9a123cc41..ce3ceb554 100644 --- a/api/router/file_router.go +++ b/api/router/file_router.go @@ -88,8 +88,8 @@ func (r *FileRouter) AppendNonJWTRoutes(g fiber.Router) { g.Get("/:id/original:ext", r.DownloadOriginal) g.Get("/:id/preview:ext", r.DownloadPreview) g.Get("/:id/thumbnail:ext", r.DownloadThumbnail) - g.Get("/:id/mobile/pages/:page.pdf", r.DownloadMobilePage) - g.Get("/:id/mobile/thumbnails/:page.png", r.DownloadMobileThumbnail) + g.Get("/:id/segmentation/pages/:page.pdf", r.DownloadSegmentationPage) + g.Get("/:id/segmentation/thumbnails/:page.png", r.DownloadSegmentationThumbnail) g.Post("/create_from_s3", r.CreateFromS3) g.Patch("/:id/patch_from_s3", r.PatchFromS3) } @@ -984,20 +984,20 @@ func (r *FileRouter) DownloadThumbnail(c *fiber.Ctx) error { return c.Send(b) } -// DownloadMobilePage godoc +// DownloadSegmentationPage godoc // -// @Summary Download Mobile Page -// @Description Download Mobile Page +// @Summary Download Segmentation Page +// @Description Download Segmentation Page // @Tags Files -// @Id files_download_mobile_page +// @Id files_download_segmentation_page // @Produce json // @Param id path string true "ID" // @Param page path string true "Page" // @Param access_token query string true "Access Token" // @Failure 404 {object} errorpkg.ErrorResponse // @Failure 500 {object} errorpkg.ErrorResponse -// @Router /files/{id}/mobile/pages/{page}.png [get] -func (r *FileRouter) DownloadMobilePage(c *fiber.Ctx) error { +// @Router /files/{id}/segmentation/pages/{page}.png [get] +func (r *FileRouter) DownloadSegmentationPage(c *fiber.Ctx) error { accessToken := c.Cookies(r.accessTokenCookieName) if accessToken == "" { accessToken = c.Query("access_token") @@ -1017,7 +1017,7 @@ func (r *FileRouter) DownloadMobilePage(c *fiber.Ctx) error { if err != nil { return errorpkg.NewInvalidQueryParamError("page") } - buf, file, err := r.fileSvc.DownloadMobilePageBuffer(id, page, userID) + buf, file, err := r.fileSvc.DownloadSegmentationPageBuffer(id, page, userID) if err != nil { return err } @@ -1027,20 +1027,20 @@ func (r *FileRouter) DownloadMobilePage(c *fiber.Ctx) error { return c.Send(b) } -// DownloadMobileThumbnail godoc +// DownloadSegmentationThumbnail godoc // -// @Summary Download Mobile Thumbnail -// @Description Download Mobile Thumbnail +// @Summary Download Segmentation Thumbnail +// @Description Download Segmentation Thumbnail // @Tags Files -// @Id files_download_mobile_thumbnail +// @Id files_download_segmentation_thumbnail // @Produce json // @Param id path string true "ID" // @Param page path string true "Page" // @Param access_token query string true "Access Token" // @Failure 404 {object} errorpkg.ErrorResponse // @Failure 500 {object} errorpkg.ErrorResponse -// @Router /files/{id}/mobile/thumbnails/{page}.png [get] -func (r *FileRouter) DownloadMobileThumbnail(c *fiber.Ctx) error { +// @Router /files/{id}/segmentation/thumbnails/{page}.png [get] +func (r *FileRouter) DownloadSegmentationThumbnail(c *fiber.Ctx) error { accessToken := c.Cookies(r.accessTokenCookieName) if accessToken == "" { accessToken = c.Query("access_token") @@ -1060,7 +1060,7 @@ func (r *FileRouter) DownloadMobileThumbnail(c *fiber.Ctx) error { if err != nil { return errorpkg.NewInvalidQueryParamError("page") } - buf, file, err := r.fileSvc.DownloadMobileThumbnailBuffer(id, page, userID) + buf, file, err := r.fileSvc.DownloadSegmentationThumbnailBuffer(id, page, userID) if err != nil { return err } diff --git a/api/service/file_service.go b/api/service/file_service.go index 5386c5799..2065efc5e 100644 --- a/api/service/file_service.go +++ b/api/service/file_service.go @@ -426,7 +426,7 @@ func (svc *FileService) DownloadThumbnailBuffer(id string, userID string) (*byte } } -func (svc *FileService) DownloadMobilePageBuffer(id string, page int, userID string) (*bytes.Buffer, model.File, error) { +func (svc *FileService) DownloadSegmentationPageBuffer(id string, page int, userID string) (*bytes.Buffer, model.File, error) { file, err := svc.fileCache.Get(id) if err != nil { return nil, nil, err @@ -441,8 +441,8 @@ func (svc *FileService) DownloadMobilePageBuffer(id string, page int, userID str if err != nil { return nil, nil, err } - if snapshot.HasMobile() { - buf, _, err := svc.s3.GetObject(filepath.FromSlash(snapshot.GetMobile().Key+fmt.Sprintf("/pages/%d.pdf", page)), snapshot.GetMobile().Bucket, minio.GetObjectOptions{}) + if snapshot.HasSegmentation() { + buf, _, err := svc.s3.GetObject(filepath.FromSlash(snapshot.GetSegmentation().Key+fmt.Sprintf("/pages/%d.pdf", page)), snapshot.GetSegmentation().Bucket, minio.GetObjectOptions{}) if err != nil { return nil, nil, err } @@ -452,7 +452,7 @@ func (svc *FileService) DownloadMobilePageBuffer(id string, page int, userID str } } -func (svc *FileService) DownloadMobileThumbnailBuffer(id string, page int, userID string) (*bytes.Buffer, model.File, error) { +func (svc *FileService) DownloadSegmentationThumbnailBuffer(id string, page int, userID string) (*bytes.Buffer, model.File, error) { file, err := svc.fileCache.Get(id) if err != nil { return nil, nil, err @@ -467,8 +467,8 @@ func (svc *FileService) DownloadMobileThumbnailBuffer(id string, page int, userI if err != nil { return nil, nil, err } - if snapshot.HasMobile() { - buf, _, err := svc.s3.GetObject(filepath.FromSlash(snapshot.GetMobile().Key+fmt.Sprintf("/thumbnails/%d.png", page)), snapshot.GetMobile().Bucket, minio.GetObjectOptions{}) + if snapshot.HasSegmentation() { + buf, _, err := svc.s3.GetObject(filepath.FromSlash(snapshot.GetSegmentation().Key+fmt.Sprintf("/thumbnails/%d.png", page)), snapshot.GetSegmentation().Bucket, minio.GetObjectOptions{}) if err != nil { return nil, nil, err } diff --git a/api/service/snapshot_service.go b/api/service/snapshot_service.go index 88b18e822..10b81d3cb 100644 --- a/api/service/snapshot_service.go +++ b/api/service/snapshot_service.go @@ -63,22 +63,22 @@ type SnapshotListOptions struct { } type Snapshot struct { - ID string `json:"id"` - Version int64 `json:"version"` - Original *Download `json:"original,omitempty"` - Preview *Download `json:"preview,omitempty"` - OCR *Download `json:"ocr,omitempty"` - Text *Download `json:"text,omitempty"` - Entities *Download `json:"entities,omitempty"` - Mosaic *Download `json:"mosaic,omitempty"` - Mobile *Download `json:"mobile,omitempty"` - Thumbnail *Download `json:"thumbnail,omitempty"` - Language *string `json:"language,omitempty"` - Status string `json:"status,omitempty"` - IsActive bool `json:"isActive"` - Task *TaskInfo `json:"task,omitempty"` - CreateTime string `json:"createTime"` - UpdateTime *string `json:"updateTime,omitempty"` + ID string `json:"id"` + Version int64 `json:"version"` + Original *Download `json:"original,omitempty"` + Preview *Download `json:"preview,omitempty"` + OCR *Download `json:"ocr,omitempty"` + Text *Download `json:"text,omitempty"` + Entities *Download `json:"entities,omitempty"` + Mosaic *Download `json:"mosaic,omitempty"` + Segmentation *Download `json:"segmentation,omitempty"` + Thumbnail *Download `json:"thumbnail,omitempty"` + Language *string `json:"language,omitempty"` + Status string `json:"status,omitempty"` + IsActive bool `json:"isActive"` + Task *TaskInfo `json:"task,omitempty"` + CreateTime string `json:"createTime"` + UpdateTime *string `json:"updateTime,omitempty"` } type TaskInfo struct { @@ -291,18 +291,18 @@ func (svc *SnapshotService) Detach(id string, opts SnapshotDetachOptions, userID } type SnapshotPatchOptions struct { - Options client.PipelineRunOptions `json:"options"` - Fields []string `json:"fields"` - Original *model.S3Object `json:"original"` - Preview *model.S3Object `json:"preview"` - Text *model.S3Object `json:"text"` - OCR *model.S3Object `json:"ocr"` - Entities *model.S3Object `json:"entities"` - Mosaic *model.S3Object `json:"mosaic"` - Mobile *model.S3Object `json:"mobile"` - Thumbnail *model.S3Object `json:"thumbnail"` - Status *string `json:"status"` - TaskID *string `json:"taskId"` + Options client.PipelineRunOptions `json:"options"` + Fields []string `json:"fields"` + Original *model.S3Object `json:"original"` + Preview *model.S3Object `json:"preview"` + Text *model.S3Object `json:"text"` + OCR *model.S3Object `json:"ocr"` + Entities *model.S3Object `json:"entities"` + Mosaic *model.S3Object `json:"mosaic"` + Segmentation *model.S3Object `json:"segmentation"` + Thumbnail *model.S3Object `json:"thumbnail"` + Status *string `json:"status"` + TaskID *string `json:"taskId"` } func (svc *SnapshotService) Patch(id string, opts SnapshotPatchOptions) (*Snapshot, error) { @@ -310,16 +310,16 @@ func (svc *SnapshotService) Patch(id string, opts SnapshotPatchOptions) (*Snapsh return nil, errorpkg.NewPathVariablesAndBodyParametersNotConsistent() } if err := svc.snapshotRepo.Update(id, repo.SnapshotUpdateOptions{ - Original: opts.Original, - Fields: opts.Fields, - Preview: opts.Preview, - Text: opts.Text, - OCR: opts.OCR, - Entities: opts.Entities, - Mosaic: opts.Mosaic, - Mobile: opts.Mobile, - Thumbnail: opts.Thumbnail, - Status: opts.Status, + Original: opts.Original, + Fields: opts.Fields, + Preview: opts.Preview, + Text: opts.Text, + OCR: opts.OCR, + Entities: opts.Entities, + Mosaic: opts.Mosaic, + Segmentation: opts.Segmentation, + Thumbnail: opts.Thumbnail, + Status: opts.Status, }); err != nil { return nil, err } @@ -397,8 +397,8 @@ func (mp *SnapshotMapper) mapOne(m model.Snapshot) *Snapshot { if m.HasMosaic() { s.Mosaic = mp.mapS3Object(m.GetMosaic()) } - if m.HasMobile() { - s.Mobile = mp.mapS3Object(m.GetMobile()) + if m.HasSegmentation() { + s.Segmentation = mp.mapS3Object(m.GetSegmentation()) } if m.HasThumbnail() { s.Thumbnail = mp.mapS3Object(m.GetThumbnail()) diff --git a/conversion/client/api_client/snapshot_client.go b/conversion/client/api_client/snapshot_client.go index 5aa832d07..113b0d035 100644 --- a/conversion/client/api_client/snapshot_client.go +++ b/conversion/client/api_client/snapshot_client.go @@ -32,18 +32,18 @@ func NewSnapshotClient() *SnapshotClient { } type SnapshotPatchOptions struct { - Options PipelineRunOptions `json:"options"` - Fields []string `json:"fields"` - Original *S3Object `json:"original"` - Preview *S3Object `json:"preview"` - Text *S3Object `json:"text"` - OCR *S3Object `json:"ocr"` - Entities *S3Object `json:"entities"` - Mosaic *S3Object `json:"mosaic"` - Mobile *S3Object `json:"mobile"` - Thumbnail *S3Object `json:"thumbnail"` - Status *string `json:"status"` - TaskID *string `json:"taskId"` + Options PipelineRunOptions `json:"options"` + Fields []string `json:"fields"` + Original *S3Object `json:"original"` + Preview *S3Object `json:"preview"` + Text *S3Object `json:"text"` + OCR *S3Object `json:"ocr"` + Entities *S3Object `json:"entities"` + Mosaic *S3Object `json:"mosaic"` + Segmentation *S3Object `json:"segmentation"` + Thumbnail *S3Object `json:"thumbnail"` + Status *string `json:"status"` + TaskID *string `json:"taskId"` } const ( @@ -54,17 +54,17 @@ const ( ) const ( - SnapshotFieldOriginal = "original" - SnapshotFieldPreview = "preview" - SnapshotFieldText = "text" - SnapshotFieldOCR = "ocr" - SnapshotFieldEntities = "entities" - SnapshotFieldMosaic = "mosaic" - SnapshotFieldMobile = "mobile" - SnapshotFieldThumbnail = "thumbnail" - SnapshotFieldStatus = "status" - SnapshotFieldLanguage = "language" - SnapshotFieldTaskID = "taskId" + SnapshotFieldOriginal = "original" + SnapshotFieldPreview = "preview" + SnapshotFieldText = "text" + SnapshotFieldOCR = "ocr" + SnapshotFieldEntities = "entities" + SnapshotFieldMosaic = "mosaic" + SnapshotFieldSegmentation = "segmentation" + SnapshotFieldThumbnail = "thumbnail" + SnapshotFieldStatus = "status" + SnapshotFieldLanguage = "language" + SnapshotFieldTaskID = "taskId" ) type PipelineRunOptions struct { diff --git a/conversion/pipeline/pdf_pipeline.go b/conversion/pipeline/pdf_pipeline.go index d185cddc8..eacf5ad2a 100644 --- a/conversion/pipeline/pdf_pipeline.go +++ b/conversion/pipeline/pdf_pipeline.go @@ -89,11 +89,11 @@ func (p *pdfPipeline) Run(opts api_client.PipelineRunOptions) error { } if err := p.taskClient.Patch(opts.TaskID, api_client.TaskPatchOptions{ Fields: []string{api_client.TaskFieldName}, - Name: helper.ToPtr("Optimizing for mobile."), + Name: helper.ToPtr("Performing segmentation."), }); err != nil { return err } - if err := p.optimizeForMobile(inputPath, opts); err != nil { + if err := p.performSegmentation(inputPath, opts); err != nil { return err } if err := p.taskClient.Patch(opts.TaskID, api_client.TaskPatchOptions{ @@ -201,7 +201,7 @@ func (p *pdfPipeline) updateSnapshot(inputPath string, opts api_client.PipelineR return nil } -func (p *pdfPipeline) optimizeForMobile(inputPath string, opts api_client.PipelineRunOptions) error { +func (p *pdfPipeline) performSegmentation(inputPath string, opts api_client.PipelineRunOptions) error { if err := p.splitPages(inputPath, opts); err != nil { return err } @@ -210,10 +210,10 @@ func (p *pdfPipeline) optimizeForMobile(inputPath string, opts api_client.Pipeli } if err := p.snapshotClient.Patch(api_client.SnapshotPatchOptions{ Options: opts, - Fields: []string{api_client.SnapshotFieldMobile}, - Mobile: &api_client.S3Object{ + Fields: []string{api_client.SnapshotFieldSegmentation}, + Segmentation: &api_client.S3Object{ Bucket: opts.Bucket, - Key: filepath.FromSlash(opts.SnapshotID + "/mobile"), + Key: filepath.FromSlash(opts.SnapshotID + "/segmentation"), }, }); err != nil { return err @@ -236,7 +236,7 @@ func (p *pdfPipeline) splitPages(inputPath string, opts api_client.PipelineRunOp if err := p.pdfProc.SplitPages(inputPath, pagesDir); err != nil { return err } - if err := p.s3.PutFolder(filepath.FromSlash(opts.SnapshotID+"/mobile/pages"), pagesDir, opts.Bucket); err != nil { + if err := p.s3.PutFolder(filepath.FromSlash(opts.SnapshotID+"/segmentation/pages"), pagesDir, opts.Bucket); err != nil { return err } return nil @@ -257,7 +257,7 @@ func (p *pdfPipeline) splitThumbnails(inputPath string, opts api_client.Pipeline if err := p.pdfProc.SplitThumbnails(inputPath, thumbnailsDir); err != nil { return err } - if err := p.s3.PutFolder(filepath.FromSlash(opts.SnapshotID+"/mobile/thumbnails"), thumbnailsDir, opts.Bucket); err != nil { + if err := p.s3.PutFolder(filepath.FromSlash(opts.SnapshotID+"/segmentation/thumbnails"), thumbnailsDir, opts.Bucket); err != nil { return err } return nil diff --git a/migrations/src/lib.rs b/migrations/src/lib.rs index fa72deda5..b161e787c 100644 --- a/migrations/src/lib.rs +++ b/migrations/src/lib.rs @@ -24,7 +24,7 @@ mod m20240718_000008_create_task; mod m20240718_000009_create_grouppermission; mod m20240718_000010_create_userpermission; mod m20240726_000001_normalize_schema; -mod m20240807_000001_add_mobile_column; +mod m20240807_000001_add_segmentation_column; #[async_trait::async_trait] impl MigratorTrait for Migrator { @@ -41,7 +41,7 @@ impl MigratorTrait for Migrator { Box::new(m20240718_000009_create_grouppermission::Migration), Box::new(m20240718_000010_create_userpermission::Migration), Box::new(m20240726_000001_normalize_schema::Migration), - Box::new(m20240807_000001_add_mobile_column::Migration), + Box::new(m20240807_000001_add_segmentation_column::Migration), ] } } diff --git a/migrations/src/m20240807_000001_add_mobile_column.rs b/migrations/src/m20240807_000001_add_segmentation_column.rs similarity index 66% rename from migrations/src/m20240807_000001_add_mobile_column.rs rename to migrations/src/m20240807_000001_add_segmentation_column.rs index 46a20d23a..2efdbaf15 100644 --- a/migrations/src/m20240807_000001_add_mobile_column.rs +++ b/migrations/src/m20240807_000001_add_segmentation_column.rs @@ -24,7 +24,23 @@ impl MigrationTrait for Migration { .alter_table( Table::alter() .table(Snapshot::Table) - .add_column(ColumnDef::new(Snapshot::Mobile).json_binary()) + .add_column(ColumnDef::new(Snapshot::Segmentation).json_binary()) + .to_owned(), + ) + .await?; + + Ok(()) + } + + async fn down( + &self, + manager: &SchemaManager, + ) -> Result<(), DbErr> { + manager + .alter_table( + Table::alter() + .table(Snapshot::Table) + .drop_column(Snapshot::Segmentation) .to_owned(), ) .await?; diff --git a/migrations/src/models/v1/snapshot.rs b/migrations/src/models/v1/snapshot.rs index 9f44c8a2d..5af0c1d10 100644 --- a/migrations/src/models/v1/snapshot.rs +++ b/migrations/src/models/v1/snapshot.rs @@ -20,7 +20,7 @@ pub enum Snapshot { Ocr, Entities, Mosaic, - Mobile, + Segmentation, Thumbnail, Language, Status, diff --git a/ui/src/client/api/snapshot.ts b/ui/src/client/api/snapshot.ts index 338981db6..4813755d3 100644 --- a/ui/src/client/api/snapshot.ts +++ b/ui/src/client/api/snapshot.ts @@ -20,6 +20,7 @@ export type Snapshot = { text?: Download entities?: Download mosaic?: Download + segmentation?: Download thumbnail?: Download language?: string isActive: boolean