Skip to content

Commit

Permalink
Merge pull request #830 from factly/feat/migrate-fields
Browse files Browse the repository at this point in the history
feat: added fields required for migration
  • Loading branch information
shreeharsha-factly authored Dec 15, 2022
2 parents b0ac2a3 + 4b79812 commit a97e21a
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 19 deletions.
3 changes: 3 additions & 0 deletions server/service/core/action/page/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ func create(w http.ResponseWriter, r *http.Request) {
HeaderCode: page.HeaderCode,
FooterCode: page.FooterCode,
SpaceID: uint(sID),
DescriptionAMP: page.DescriptionAMP,
IsMigrated: page.IsMigrated,
MigratedHTML: page.MigratedHTML,
}

if len(page.TagIDs) > 0 {
Expand Down
3 changes: 3 additions & 0 deletions server/service/core/action/page/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ type page struct {
HeaderCode string `json:"header_code"`
FooterCode string `json:"footer_code"`
MetaFields postgres.Jsonb `json:"meta_fields" swaggertype:"primitive,string"`
DescriptionAMP string `json:"description_amp"`
IsMigrated bool `json:"is_migrated"`
MigratedHTML string `json:"migrated_html"`
SpaceID uint `json:"space_id"`
CategoryIDs []uint `json:"category_ids"`
TagIDs []uint `json:"tag_ids"`
Expand Down
3 changes: 3 additions & 0 deletions server/service/core/action/page/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ 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,
}

result.Post.FeaturedMediumID = &page.FeaturedMediumID
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 @@ -217,6 +217,9 @@ func createPost(ctx context.Context, post post, status string, r *http.Request)
FooterCode: post.FooterCode,
MetaFields: post.MetaFields,
SpaceID: uint(sID),
DescriptionAMP: post.DescriptionAMP,
IsMigrated: post.IsMigrated,
MigratedHTML: post.MigratedHTML,
}

if status == "publish" {
Expand Down Expand Up @@ -503,7 +506,7 @@ func createPost(ctx context.Context, post post, status string, r *http.Request)
if spaceObjectforDega.MobileIconID != nil {
schemaxSpace.SpaceSettings.MobileIconID = spaceObjectforDega.MobileIconID
}

schemas := schemax.GetSchemas(schemax.PostData{
Post: schemaxPost,
Authors: schemaxAuthors,
Expand Down
3 changes: 3 additions & 0 deletions server/service/core/action/post/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ type post struct {
HeaderCode string `json:"header_code"`
FooterCode string `json:"footer_code"`
MetaFields postgres.Jsonb `json:"meta_fields" swaggertype:"primitive,string"`
DescriptionAMP string `json:"description_amp"`
IsMigrated bool `json:"is_migrated"`
MigratedHTML string `json:"migrated_html"`
CategoryIDs []uint `json:"category_ids"`
TagIDs []uint `json:"tag_ids"`
ClaimIDs []uint `json:"claim_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,6 +201,9 @@ 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,
}

result.Post.FeaturedMediumID = &post.FeaturedMediumID
Expand Down Expand Up @@ -598,7 +601,7 @@ func update(w http.ResponseWriter, r *http.Request) {
if spaceObjectforDega.MobileIconID != nil {
schemaxSpace.SpaceSettings.MobileIconID = spaceObjectforDega.MobileIconID
}

schemas := schemax.GetSchemas(schemax.PostData{
Post: schemaxPost,
Authors: schemaxAuthors,
Expand Down
3 changes: 3 additions & 0 deletions server/service/core/model/post.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ type Post struct {
Meta postgres.Jsonb `gorm:"column:meta" json:"meta" swaggertype:"primitive,string"`
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"`
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"`
Categories []Category `gorm:"many2many:post_categories;" json:"categories"`
Expand Down
3 changes: 3 additions & 0 deletions server/service/fact-check/action/claim/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ func create(w http.ResponseWriter, r *http.Request) {
FooterCode: claim.FooterCode,
SpaceID: uint(sID),
MediumID: mediumID,
DescriptionAMP: claim.DescriptionAMP,
IsMigrated: claim.IsMigrated,
MigratedHTML: claim.MigratedHTML,
}

tx := config.DB.WithContext(context.WithValue(r.Context(), userContext, uID)).Begin()
Expand Down
37 changes: 20 additions & 17 deletions server/service/fact-check/action/claim/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,26 @@ import (
)

type claim struct {
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Claim string `json:"claim" validate:"required,max=5000"`
Slug string `json:"slug"`
ClaimDate *time.Time `json:"claim_date" `
CheckedDate *time.Time `json:"checked_date"`
ClaimSources postgres.Jsonb `json:"claim_sources" swaggertype:"primitive,string"`
Description postgres.Jsonb `json:"description" swaggertype:"primitive,string"`
ClaimantID uint `json:"claimant_id" validate:"required"`
RatingID uint `json:"rating_id" validate:"required"`
MediumID uint `json:"medium_id"`
Fact string `json:"fact"`
ReviewSources postgres.Jsonb `json:"review_sources" swaggertype:"primitive,string"`
MetaFields postgres.Jsonb `json:"meta_fields" swaggertype:"primitive,string"`
Meta postgres.Jsonb `json:"meta" swaggertype:"primitive,string"`
HeaderCode string `json:"header_code"`
FooterCode string `json:"footer_code"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Claim string `json:"claim" validate:"required,max=5000"`
Slug string `json:"slug"`
ClaimDate *time.Time `json:"claim_date" `
CheckedDate *time.Time `json:"checked_date"`
ClaimSources postgres.Jsonb `json:"claim_sources" swaggertype:"primitive,string"`
Description postgres.Jsonb `json:"description" swaggertype:"primitive,string"`
ClaimantID uint `json:"claimant_id" validate:"required"`
RatingID uint `json:"rating_id" validate:"required"`
MediumID uint `json:"medium_id"`
Fact string `json:"fact"`
ReviewSources postgres.Jsonb `json:"review_sources" swaggertype:"primitive,string"`
MetaFields postgres.Jsonb `json:"meta_fields" swaggertype:"primitive,string"`
Meta postgres.Jsonb `json:"meta" swaggertype:"primitive,string"`
HeaderCode string `json:"header_code"`
FooterCode string `json:"footer_code"`
DescriptionAMP string `json:"description_amp"`
IsMigrated bool `json:"is_migrated"`
MigratedHTML string `json:"migrated_html"`
}

var userContext config.ContextKey = "claim_user"
Expand Down
3 changes: 3 additions & 0 deletions server/service/fact-check/action/claim/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ 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.MediumID == 0 {
updateMap["medium_id"] = nil
Expand Down
3 changes: 3 additions & 0 deletions server/service/fact-check/model/claim.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ type Claim struct {
ClaimSources postgres.Jsonb `gorm:"column:claim_sources" json:"claim_sources" swaggertype:"primitive,string"`
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"`
MigratedHTML string `gorm:"column:migrated_html" json:"migrated_html"`
ClaimantID uint `gorm:"column:claimant_id" json:"claimant_id"`
Claimant Claimant `json:"claimant"`
RatingID uint `gorm:"column:rating_id" json:"rating_id"`
Expand Down

0 comments on commit a97e21a

Please sign in to comment.