Skip to content

Commit

Permalink
Merge pull request #832 from factly/ref/migrationID-field
Browse files Browse the repository at this point in the history
ref: changed 'is_migration' field in post entities to migration_id
  • Loading branch information
shreeharsha-factly authored Dec 23, 2022
2 parents a97e21a + 63cd756 commit 16a0578
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 15 deletions.
8 changes: 4 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ services:
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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion server/service/core/action/page/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,13 @@ func create(w http.ResponseWriter, r *http.Request) {
FooterCode: page.FooterCode,
SpaceID: uint(sID),
DescriptionAMP: page.DescriptionAMP,
IsMigrated: page.IsMigrated,
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)
}
Expand Down
2 changes: 1 addition & 1 deletion server/service/core/action/page/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
4 changes: 3 additions & 1 deletion server/service/core/action/page/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,12 @@ func update(w http.ResponseWriter, r *http.Request) {
"header_code": page.HeaderCode,
"footer_code": page.FooterCode,
"is_featured": page.IsFeatured,
"is_migrated": page.IsMigrated,
"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 {
Expand Down
5 changes: 4 additions & 1 deletion server/service/core/action/post/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
IsMigrated: post.IsMigrated,
MigratedHTML: post.MigratedHTML,
}

if post.MigrationID != nil {
result.Post.MigrationID = *post.MigrationID
}

if status == "publish" {
if post.PublishedDate == nil {
currTime := time.Now()
Expand Down
2 changes: 1 addition & 1 deletion server/service/core/action/post/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
5 changes: 4 additions & 1 deletion server/service/core/action/post/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,14 @@ func update(w http.ResponseWriter, r *http.Request) {
"header_code": post.HeaderCode,
"footer_code": post.FooterCode,
"meta_fields": post.MetaFields,
"is_migrated": post.IsMigrated,
"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
Expand Down
2 changes: 1 addition & 1 deletion server/service/core/model/post.go
Original file line number Diff line number Diff line change
Expand Up @@ -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: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"`
Expand Down
2 changes: 1 addition & 1 deletion server/service/fact-check/action/claim/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand Down
2 changes: 1 addition & 1 deletion server/service/fact-check/action/claim/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}

Expand Down
6 changes: 5 additions & 1 deletion server/service/fact-check/action/claim/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,14 @@ func update(w http.ResponseWriter, r *http.Request) {
"header_code": claim.HeaderCode,
"footer_code": claim.FooterCode,
"medium_id": claim.MediumID,
"is_migrated": claim.IsMigrated,
"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
}
Expand Down
2 changes: 1 addition & 1 deletion server/service/fact-check/model/claim.go
Original file line number Diff line number Diff line change
Expand Up @@ -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: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"`
Expand Down

0 comments on commit 16a0578

Please sign in to comment.