Skip to content

Commit

Permalink
fix(gdoc): do not override subclass props if defined
Browse files Browse the repository at this point in the history
  • Loading branch information
mlbrgl committed May 9, 2024
1 parent f90a5a9 commit c6d2547
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion db/model/Gdoc/GdocDataInsight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
OwidGdocMinimalPostInterface,
OwidGdocBaseInterface,
excludeNullish,
defaults,
} from "@ourworldindata/utils"
import { GdocBase } from "./GdocBase.js"
import * as db from "../../../db/db.js"
Expand All @@ -27,7 +28,7 @@ export class GdocDataInsight

static create(obj: OwidGdocBaseInterface): GdocDataInsight {
const gdoc = new GdocDataInsight()
Object.assign(gdoc, obj)
defaults(gdoc, obj) // see GdocAuthor.ts for rationale
return gdoc
}

Expand Down
3 changes: 2 additions & 1 deletion db/model/Gdoc/GdocHomepage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
OwidGdocHomepageInterface,
OwidGdocMinimalPostInterface,
OwidGdocType,
defaults,
} from "@ourworldindata/utils"
import { GdocBase } from "./GdocBase.js"
import * as db from "../../db.js"
Expand All @@ -28,7 +29,7 @@ export class GdocHomepage

static create(obj: OwidGdocBaseInterface): GdocHomepage {
const gdoc = new GdocHomepage()
Object.assign(gdoc, obj)
defaults(gdoc, obj) // see GdocAuthor.ts for rationale
return gdoc
}

Expand Down
3 changes: 2 additions & 1 deletion db/model/Gdoc/GdocPost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
OwidGdocMinimalPostInterface,
OwidGdocBaseInterface,
excludeNullish,
defaults,
} from "@ourworldindata/utils"
import { GDOCS_DETAILS_ON_DEMAND_ID } from "../../../settings/serverSettings.js"
import {
Expand All @@ -37,7 +38,7 @@ export class GdocPost extends GdocBase implements OwidGdocPostInterface {
}
static create(obj: OwidGdocBaseInterface): GdocPost {
const gdoc = new GdocPost()
Object.assign(gdoc, obj)
defaults(gdoc, obj) // see GdocAuthor.ts for rationale
return gdoc
}
linkedDocuments: Record<string, OwidGdocMinimalPostInterface> = {}
Expand Down

0 comments on commit c6d2547

Please sign in to comment.