From 8333c5b2f384585a6c004c8c16970465e81567db Mon Sep 17 00:00:00 2001 From: vsumit89 Date: Fri, 23 Dec 2022 12:03:58 +0530 Subject: [PATCH 1/4] replaced is_migrated field with migration_id in all post entities --- docker-compose.yml | 8 ++++---- server/service/core/action/page/create.go | 2 +- server/service/core/action/page/route.go | 2 +- server/service/core/action/page/update.go | 2 +- server/service/core/action/post/create.go | 2 +- server/service/core/action/post/route.go | 2 +- server/service/core/action/post/update.go | 2 +- server/service/core/model/post.go | 2 +- server/service/fact-check/action/claim/create.go | 2 +- server/service/fact-check/action/claim/route.go | 2 +- server/service/fact-check/action/claim/update.go | 2 +- server/service/fact-check/model/claim.go | 2 +- 12 files changed, 15 insertions(+), 15 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index bc6d8635..2643f06b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -112,7 +112,7 @@ services: ####### SEARCH SERVICES ####### ########################################################################### meilisearch: - image: getmeili/meilisearch:v0.28.0 + image: getmeili/meilisearch:v0.28.2 ports: - "7700:7700" volumes: @@ -237,7 +237,7 @@ services: - kavach-migrate ports: - 5001:8000 - image: factly/kavach-server:0.27.4 + image: factly/kavach-server:0.28.2 volumes: - type: bind source: ./volumes/kavach-server/data @@ -281,7 +281,7 @@ services: - postgres - keto - kratos - image: factly/kavach-server:0.27.4 + image: factly/kavach-server:0.28.2 volumes: - type: bind source: ./volumes/kavach-server/data @@ -321,7 +321,7 @@ services: - dega kavach-web: - image: factly/kavach-web:0.27.4-dev + image: factly/kavach-web:0.28.2-dev volumes: - type: bind source: ./volumes/kavach-web/config.js diff --git a/server/service/core/action/page/create.go b/server/service/core/action/page/create.go index 558b1451..13a51491 100644 --- a/server/service/core/action/page/create.go +++ b/server/service/core/action/page/create.go @@ -127,7 +127,7 @@ func create(w http.ResponseWriter, r *http.Request) { FooterCode: page.FooterCode, SpaceID: uint(sID), DescriptionAMP: page.DescriptionAMP, - IsMigrated: page.IsMigrated, + MigrationID: page.MigrationID, MigratedHTML: page.MigratedHTML, } diff --git a/server/service/core/action/page/route.go b/server/service/core/action/page/route.go index 74665d22..4bcd2e5e 100644 --- a/server/service/core/action/page/route.go +++ b/server/service/core/action/page/route.go @@ -31,7 +31,7 @@ type page struct { FooterCode string `json:"footer_code"` MetaFields postgres.Jsonb `json:"meta_fields" swaggertype:"primitive,string"` DescriptionAMP string `json:"description_amp"` - IsMigrated bool `json:"is_migrated"` + MigrationID uint `json:"migration_id"` MigratedHTML string `json:"migrated_html"` SpaceID uint `json:"space_id"` CategoryIDs []uint `json:"category_ids"` diff --git a/server/service/core/action/page/update.go b/server/service/core/action/page/update.go index 7fd746c9..1b190bb6 100644 --- a/server/service/core/action/page/update.go +++ b/server/service/core/action/page/update.go @@ -191,7 +191,7 @@ func update(w http.ResponseWriter, r *http.Request) { "header_code": page.HeaderCode, "footer_code": page.FooterCode, "is_featured": page.IsFeatured, - "is_migrated": page.IsMigrated, + "migration_id": page.MigrationID, "description_amp": page.DescriptionAMP, "migrated_html": page.MigratedHTML, } diff --git a/server/service/core/action/post/create.go b/server/service/core/action/post/create.go index d2788ff2..7c39bd1a 100644 --- a/server/service/core/action/post/create.go +++ b/server/service/core/action/post/create.go @@ -218,7 +218,7 @@ func createPost(ctx context.Context, post post, status string, r *http.Request) MetaFields: post.MetaFields, SpaceID: uint(sID), DescriptionAMP: post.DescriptionAMP, - IsMigrated: post.IsMigrated, + MigrationID: post.MigrationID, MigratedHTML: post.MigratedHTML, } diff --git a/server/service/core/action/post/route.go b/server/service/core/action/post/route.go index 93246457..53c4eb69 100644 --- a/server/service/core/action/post/route.go +++ b/server/service/core/action/post/route.go @@ -34,7 +34,7 @@ type post struct { FooterCode string `json:"footer_code"` MetaFields postgres.Jsonb `json:"meta_fields" swaggertype:"primitive,string"` DescriptionAMP string `json:"description_amp"` - IsMigrated bool `json:"is_migrated"` + MigrationID uint `json:"migration_id"` MigratedHTML string `json:"migrated_html"` CategoryIDs []uint `json:"category_ids"` TagIDs []uint `json:"tag_ids"` diff --git a/server/service/core/action/post/update.go b/server/service/core/action/post/update.go index cba15619..921915b2 100644 --- a/server/service/core/action/post/update.go +++ b/server/service/core/action/post/update.go @@ -201,7 +201,7 @@ func update(w http.ResponseWriter, r *http.Request) { "header_code": post.HeaderCode, "footer_code": post.FooterCode, "meta_fields": post.MetaFields, - "is_migrated": post.IsMigrated, + "migration_id": post.MigrationID, "description_amp": post.DescriptionAMP, "migrated_html": post.MigratedHTML, } diff --git a/server/service/core/model/post.go b/server/service/core/model/post.go index 430a9969..79be4fd5 100644 --- a/server/service/core/model/post.go +++ b/server/service/core/model/post.go @@ -35,7 +35,7 @@ type Post struct { HeaderCode string `gorm:"column:header_code" json:"header_code"` FooterCode string `gorm:"column:footer_code" json:"footer_code"` DescriptionAMP string `gorm:"column:description_amp" json:"description_amp"` - IsMigrated bool `gorm:"column:is_migrated;default:false;" json:"is_migrated"` + MigrationID uint `gorm:"column:migration_id;default:false;" json:"migration_id"` MigratedHTML string `gorm:"column:migrated_html" json:"migrated_html"` MetaFields postgres.Jsonb `gorm:"column:meta_fields" json:"meta_fields" swaggertype:"primitive,string"` Tags []Tag `gorm:"many2many:post_tags;" json:"tags"` diff --git a/server/service/fact-check/action/claim/create.go b/server/service/fact-check/action/claim/create.go index 68507b94..f2b49f52 100644 --- a/server/service/fact-check/action/claim/create.go +++ b/server/service/fact-check/action/claim/create.go @@ -135,7 +135,7 @@ func create(w http.ResponseWriter, r *http.Request) { SpaceID: uint(sID), MediumID: mediumID, DescriptionAMP: claim.DescriptionAMP, - IsMigrated: claim.IsMigrated, + MigrationID: claim.MigrationID, MigratedHTML: claim.MigratedHTML, } diff --git a/server/service/fact-check/action/claim/route.go b/server/service/fact-check/action/claim/route.go index 04835dea..3859d55c 100644 --- a/server/service/fact-check/action/claim/route.go +++ b/server/service/fact-check/action/claim/route.go @@ -29,7 +29,7 @@ type claim struct { HeaderCode string `json:"header_code"` FooterCode string `json:"footer_code"` DescriptionAMP string `json:"description_amp"` - IsMigrated bool `json:"is_migrated"` + MigrationID uint `json:"migration_id"` MigratedHTML string `json:"migrated_html"` } diff --git a/server/service/fact-check/action/claim/update.go b/server/service/fact-check/action/claim/update.go index 7084f54b..d19fda93 100644 --- a/server/service/fact-check/action/claim/update.go +++ b/server/service/fact-check/action/claim/update.go @@ -157,7 +157,7 @@ func update(w http.ResponseWriter, r *http.Request) { "header_code": claim.HeaderCode, "footer_code": claim.FooterCode, "medium_id": claim.MediumID, - "is_migrated": claim.IsMigrated, + "migration_id": claim.MigrationID, "description_amp": claim.DescriptionAMP, "migrated_html": claim.MigratedHTML, } diff --git a/server/service/fact-check/model/claim.go b/server/service/fact-check/model/claim.go index 6f0db876..b4d1f5b9 100644 --- a/server/service/fact-check/model/claim.go +++ b/server/service/fact-check/model/claim.go @@ -23,7 +23,7 @@ type Claim struct { Description postgres.Jsonb `gorm:"column:description" json:"description" swaggertype:"primitive,string"` DescriptionHTML string `gorm:"column:description_html" json:"description_html,omitempty"` DescriptionAMP string `gorm:"column:description_amp" json:"description_amp"` - IsMigrated bool `gorm:"column:is_migrated;default:false;" json:"is_migrated"` + MigrationID uint `gorm:"column:migration_id;default:false;" json:"migration_id"` MigratedHTML string `gorm:"column:migrated_html" json:"migrated_html"` ClaimantID uint `gorm:"column:claimant_id" json:"claimant_id"` Claimant Claimant `json:"claimant"` From 5d500fb0d71cc065bcfc799672bf545ecd146a19 Mon Sep 17 00:00:00 2001 From: vsumit89 Date: Fri, 23 Dec 2022 12:06:12 +0530 Subject: [PATCH 2/4] rolled back meilisearch chanages --- docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 2643f06b..c9d71c30 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -112,11 +112,11 @@ services: ####### SEARCH SERVICES ####### ########################################################################### meilisearch: - image: getmeili/meilisearch:v0.28.2 + image: getmeili/meilisearch:v0.28.0 ports: - "7700:7700" volumes: - - ~/factly/dega/meilisearch-0-27-1/data.ms/:/data.ms + - ~/factly/dega/meilisearch-0-28-0/data.ms/:/data.ms environment: # To put an upper limit of 100MB for the payload size during indexing - MEILI_HTTP_PAYLOAD_SIZE_LIMIT=104857600 From 19e7ee44448d36c8127c3aa98d291c8a4a41f990 Mon Sep 17 00:00:00 2001 From: vsumit89 Date: Fri, 23 Dec 2022 12:28:21 +0530 Subject: [PATCH 3/4] added checks for nil pointer errors --- server/service/core/action/page/create.go | 5 ++++- server/service/core/action/page/route.go | 2 +- server/service/core/action/page/update.go | 4 +++- server/service/core/action/post/create.go | 5 ++++- server/service/core/action/post/route.go | 2 +- server/service/core/action/post/update.go | 5 ++++- server/service/core/model/post.go | 2 +- server/service/fact-check/action/claim/create.go | 2 +- server/service/fact-check/action/claim/route.go | 2 +- server/service/fact-check/action/claim/update.go | 5 +++++ server/service/fact-check/model/claim.go | 2 +- 11 files changed, 26 insertions(+), 10 deletions(-) diff --git a/server/service/core/action/page/create.go b/server/service/core/action/page/create.go index 13a51491..a3db3cd1 100644 --- a/server/service/core/action/page/create.go +++ b/server/service/core/action/page/create.go @@ -127,10 +127,13 @@ func create(w http.ResponseWriter, r *http.Request) { FooterCode: page.FooterCode, SpaceID: uint(sID), DescriptionAMP: page.DescriptionAMP, - MigrationID: page.MigrationID, MigratedHTML: page.MigratedHTML, } + if page.MigrationID != nil { + result.Post.MigrationID = *page.MigrationID + } + if len(page.TagIDs) > 0 { config.DB.Model(&model.Tag{}).Where(page.TagIDs).Find(&result.Post.Tags) } diff --git a/server/service/core/action/page/route.go b/server/service/core/action/page/route.go index 4bcd2e5e..e7a75e30 100644 --- a/server/service/core/action/page/route.go +++ b/server/service/core/action/page/route.go @@ -31,7 +31,7 @@ type page struct { FooterCode string `json:"footer_code"` MetaFields postgres.Jsonb `json:"meta_fields" swaggertype:"primitive,string"` DescriptionAMP string `json:"description_amp"` - MigrationID uint `json:"migration_id"` + MigrationID *uint `json:"migration_id"` MigratedHTML string `json:"migrated_html"` SpaceID uint `json:"space_id"` CategoryIDs []uint `json:"category_ids"` diff --git a/server/service/core/action/page/update.go b/server/service/core/action/page/update.go index 1b190bb6..30333a8e 100644 --- a/server/service/core/action/page/update.go +++ b/server/service/core/action/page/update.go @@ -191,10 +191,12 @@ func update(w http.ResponseWriter, r *http.Request) { "header_code": page.HeaderCode, "footer_code": page.FooterCode, "is_featured": page.IsFeatured, - "migration_id": page.MigrationID, "description_amp": page.DescriptionAMP, "migrated_html": page.MigratedHTML, } + if page.MigrationID != nil { + updateMap["migration_id"] = *page.MigrationID + } result.Post.FeaturedMediumID = &page.FeaturedMediumID if page.FeaturedMediumID == 0 { diff --git a/server/service/core/action/post/create.go b/server/service/core/action/post/create.go index 7c39bd1a..9cc04a75 100644 --- a/server/service/core/action/post/create.go +++ b/server/service/core/action/post/create.go @@ -218,10 +218,13 @@ func createPost(ctx context.Context, post post, status string, r *http.Request) MetaFields: post.MetaFields, SpaceID: uint(sID), DescriptionAMP: post.DescriptionAMP, - MigrationID: post.MigrationID, MigratedHTML: post.MigratedHTML, } + if post.MigrationID != nil { + result.Post.MigrationID = *post.MigrationID + } + if status == "publish" { if post.PublishedDate == nil { currTime := time.Now() diff --git a/server/service/core/action/post/route.go b/server/service/core/action/post/route.go index 53c4eb69..da954670 100644 --- a/server/service/core/action/post/route.go +++ b/server/service/core/action/post/route.go @@ -34,7 +34,7 @@ type post struct { FooterCode string `json:"footer_code"` MetaFields postgres.Jsonb `json:"meta_fields" swaggertype:"primitive,string"` DescriptionAMP string `json:"description_amp"` - MigrationID uint `json:"migration_id"` + MigrationID *uint `json:"migration_id"` MigratedHTML string `json:"migrated_html"` CategoryIDs []uint `json:"category_ids"` TagIDs []uint `json:"tag_ids"` diff --git a/server/service/core/action/post/update.go b/server/service/core/action/post/update.go index 921915b2..a7e98619 100644 --- a/server/service/core/action/post/update.go +++ b/server/service/core/action/post/update.go @@ -201,11 +201,14 @@ func update(w http.ResponseWriter, r *http.Request) { "header_code": post.HeaderCode, "footer_code": post.FooterCode, "meta_fields": post.MetaFields, - "migration_id": post.MigrationID, "description_amp": post.DescriptionAMP, "migrated_html": post.MigratedHTML, } + if post.MigrationID != nil { + updateMap["migration_id"] = *post.MigrationID + } + result.Post.FeaturedMediumID = &post.FeaturedMediumID if post.FeaturedMediumID == 0 { updateMap["featured_medium_id"] = nil diff --git a/server/service/core/model/post.go b/server/service/core/model/post.go index 79be4fd5..3f7691b1 100644 --- a/server/service/core/model/post.go +++ b/server/service/core/model/post.go @@ -35,7 +35,7 @@ type Post struct { HeaderCode string `gorm:"column:header_code" json:"header_code"` FooterCode string `gorm:"column:footer_code" json:"footer_code"` DescriptionAMP string `gorm:"column:description_amp" json:"description_amp"` - MigrationID uint `gorm:"column:migration_id;default:false;" json:"migration_id"` + MigrationID uint `gorm:"column:migration_id;default:NULL;" json:"migration_id"` MigratedHTML string `gorm:"column:migrated_html" json:"migrated_html"` MetaFields postgres.Jsonb `gorm:"column:meta_fields" json:"meta_fields" swaggertype:"primitive,string"` Tags []Tag `gorm:"many2many:post_tags;" json:"tags"` diff --git a/server/service/fact-check/action/claim/create.go b/server/service/fact-check/action/claim/create.go index f2b49f52..159eba8f 100644 --- a/server/service/fact-check/action/claim/create.go +++ b/server/service/fact-check/action/claim/create.go @@ -135,7 +135,7 @@ func create(w http.ResponseWriter, r *http.Request) { SpaceID: uint(sID), MediumID: mediumID, DescriptionAMP: claim.DescriptionAMP, - MigrationID: claim.MigrationID, + MigrationID: claim.MigrationID, MigratedHTML: claim.MigratedHTML, } diff --git a/server/service/fact-check/action/claim/route.go b/server/service/fact-check/action/claim/route.go index 3859d55c..b6ecff22 100644 --- a/server/service/fact-check/action/claim/route.go +++ b/server/service/fact-check/action/claim/route.go @@ -29,7 +29,7 @@ type claim struct { HeaderCode string `json:"header_code"` FooterCode string `json:"footer_code"` DescriptionAMP string `json:"description_amp"` - MigrationID uint `json:"migration_id"` + MigrationID *uint `json:"migration_id"` MigratedHTML string `json:"migrated_html"` } diff --git a/server/service/fact-check/action/claim/update.go b/server/service/fact-check/action/claim/update.go index d19fda93..f3d5a147 100644 --- a/server/service/fact-check/action/claim/update.go +++ b/server/service/fact-check/action/claim/update.go @@ -161,6 +161,11 @@ func update(w http.ResponseWriter, r *http.Request) { "description_amp": claim.DescriptionAMP, "migrated_html": claim.MigratedHTML, } + + if claim.MigrationID != nil { + updateMap["migration_id"] = *claim.MigrationID + } + if claim.MediumID == 0 { updateMap["medium_id"] = nil } diff --git a/server/service/fact-check/model/claim.go b/server/service/fact-check/model/claim.go index b4d1f5b9..98815872 100644 --- a/server/service/fact-check/model/claim.go +++ b/server/service/fact-check/model/claim.go @@ -23,7 +23,7 @@ type Claim struct { Description postgres.Jsonb `gorm:"column:description" json:"description" swaggertype:"primitive,string"` DescriptionHTML string `gorm:"column:description_html" json:"description_html,omitempty"` DescriptionAMP string `gorm:"column:description_amp" json:"description_amp"` - MigrationID uint `gorm:"column:migration_id;default:false;" json:"migration_id"` + MigrationID *uint `gorm:"column:migration_id;default:NULL;" json:"migration_id"` MigratedHTML string `gorm:"column:migrated_html" json:"migrated_html"` ClaimantID uint `gorm:"column:claimant_id" json:"claimant_id"` Claimant Claimant `json:"claimant"` From 63cd7560a7fd24e165ec15358b193975879ae5a8 Mon Sep 17 00:00:00 2001 From: vsumit89 Date: Fri, 23 Dec 2022 12:58:26 +0530 Subject: [PATCH 4/4] removed migration_id from update_map --- server/service/fact-check/action/claim/update.go | 1 - 1 file changed, 1 deletion(-) diff --git a/server/service/fact-check/action/claim/update.go b/server/service/fact-check/action/claim/update.go index f3d5a147..cf8ea65c 100644 --- a/server/service/fact-check/action/claim/update.go +++ b/server/service/fact-check/action/claim/update.go @@ -157,7 +157,6 @@ func update(w http.ResponseWriter, r *http.Request) { "header_code": claim.HeaderCode, "footer_code": claim.FooterCode, "medium_id": claim.MediumID, - "migration_id": claim.MigrationID, "description_amp": claim.DescriptionAMP, "migrated_html": claim.MigratedHTML, }