-
-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
284 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { MigrationInterface, QueryRunner } from "typeorm" | ||
|
||
export class CreateDonors1733228214376 implements MigrationInterface { | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`-- sql | ||
CREATE TABLE donors ( | ||
id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, | ||
name VARCHAR(255) NOT NULL, | ||
originalName VARCHAR(255) NOT NULL, | ||
shouldPublish BOOLEAN NOT NULL DEFAULT (false), | ||
comment TEXT DEFAULT (''), | ||
createdAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP, | ||
updatedAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, | ||
UNIQUE KEY (originalName) | ||
) | ||
`) | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`-- sql | ||
DROP TABLE donors | ||
`) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { DbPlainDonor, DonorsTableName } from "@ourworldindata/types" | ||
import * as db from "../db" | ||
|
||
export async function getPublicDonorNames( | ||
knex: db.KnexReadonlyTransaction | ||
): Promise<string[]> { | ||
const donors = await knex<DbPlainDonor>(DonorsTableName) | ||
.select("name") | ||
.where({ shouldPublish: true }) | ||
.orderBy("name") | ||
.distinct() | ||
return donors.map((donor) => donor.name) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { | ||
OwidGdocAboutContent, | ||
OwidGdocAboutInterface, | ||
OwidGdocBaseInterface, | ||
} from "@ourworldindata/types" | ||
import { traverseEnrichedBlock } from "@ourworldindata/utils" | ||
import * as db from "../../db.js" | ||
import { getPublicDonorNames } from "../Donor.js" | ||
import { GdocBase } from "./GdocBase.js" | ||
|
||
export class GdocAbout extends GdocBase implements OwidGdocAboutInterface { | ||
content!: OwidGdocAboutContent | ||
|
||
static create(obj: OwidGdocBaseInterface): GdocAbout { | ||
const gdoc = new GdocAbout(undefined) | ||
Object.assign(gdoc, obj) | ||
return gdoc | ||
} | ||
|
||
async _loadSubclassAttachments( | ||
knex: db.KnexReadonlyTransaction | ||
): Promise<void> { | ||
let hasDonors = false | ||
for (const enrichedBlockSource of this.enrichedBlockSources) { | ||
for (const block of enrichedBlockSource) { | ||
traverseEnrichedBlock(block, (block) => { | ||
if (block.type === "donors") { | ||
hasDonors = true | ||
} | ||
}) | ||
} | ||
} | ||
if (hasDonors) { | ||
this.donors = await getPublicDonorNames(knex) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.