Skip to content

Commit

Permalink
🐝 run biome format --write on project
Browse files Browse the repository at this point in the history
  • Loading branch information
ikesau committed Jan 25, 2024
1 parent dac1399 commit 7dbb9d1
Show file tree
Hide file tree
Showing 85 changed files with 13,670 additions and 4,493 deletions.
6 changes: 3 additions & 3 deletions _routes.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": 1,
"include": ["/grapher/*", "/donation/*"],
"exclude": ["/grapher/embedCharts.js", "/grapher/_grapherRedirects.json"]
"version": 1,
"include": ["/grapher/*", "/donation/*"],
"exclude": ["/grapher/embedCharts.js", "/grapher/_grapherRedirects.json"]
}
3 changes: 1 addition & 2 deletions adminSiteClient/EditorBasicTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,7 @@ class DimensionSlotView extends React.Component<{
? undefined
: action(
() =>
(this.isSelectingVariables =
true)
(this.isSelectingVariables = true)
)
}
onRemove={
Expand Down
4 changes: 2 additions & 2 deletions adminSiteClient/EditorColorScaleSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,8 @@ class NumericBinView extends React.Component<{
{bin.props.isOpenLeft
? "≤"
: bin.props.isFirst
? "≥"
: ">"}
? "≥"
: ">"}
{bin.min} ⁠–⁠ {"≤"}
</span>
<NumberField
Expand Down
5 changes: 2 additions & 3 deletions adminSiteClient/EditorTextTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,8 @@ export class EditorTextTab extends React.Component<{ editor: ChartEditor }> {
keys.forEach((key) => {
const references = invalidDetailReferences[key]
if (references.length) {
errorMessages[
key
] = `Invalid detail(s) specified: ${references.join(", ")}`
errorMessages[key] =
`Invalid detail(s) specified: ${references.join(", ")}`
}
})
return errorMessages
Expand Down
4 changes: 2 additions & 2 deletions adminSiteClient/GdocsPreviewPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,8 @@ export const GdocsPreviewPage = ({ match, history }: GdocsMatchProps) => {
hasErrors
? OwidGdocErrorMessageType.Error
: hasWarnings
? OwidGdocErrorMessageType.Warning
: null
? OwidGdocErrorMessageType.Warning
: null
}
>
<Button onClick={() => setSettingsOpen(true)}>
Expand Down
14 changes: 7 additions & 7 deletions adminSiteClient/PostsIndexPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ interface PostIndexMeta {
}

enum GdocStatus {
"MISSING_NO_SLUG_SUCCESSOR" = "MISSING_NO_SLUG_SUCCESSOR",
"MISSING_WITH_SLUG_SUCCESSOR" = "MISSING_WITH_SLUG_SUCCESSOR",
"CONVERTING" = "CONVERTING",
"CONVERTED" = "CONVERTED",
MISSING_NO_SLUG_SUCCESSOR = "MISSING_NO_SLUG_SUCCESSOR",
MISSING_WITH_SLUG_SUCCESSOR = "MISSING_WITH_SLUG_SUCCESSOR",
CONVERTING = "CONVERTING",
CONVERTED = "CONVERTED",
}

interface PostRowProps {
Expand All @@ -68,9 +68,9 @@ class PostRow extends React.Component<PostRowProps> {
this.postGdocStatus = props.post.gdocSuccessorId
? GdocStatus.CONVERTED
: props.post.gdocSlugSuccessors &&
props.post.gdocSlugSuccessors.length > 0
? GdocStatus.MISSING_WITH_SLUG_SUCCESSOR
: GdocStatus.MISSING_NO_SLUG_SUCCESSOR
props.post.gdocSlugSuccessors.length > 0
? GdocStatus.MISSING_WITH_SLUG_SUCCESSOR
: GdocStatus.MISSING_NO_SLUG_SUCCESSOR
}

async saveTags(tags: ChartTagJoin[]) {
Expand Down
4 changes: 2 additions & 2 deletions adminSiteClient/SaveButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export class SaveButtons extends React.Component<{ editor: ChartEditor }> {
{grapher.isPublished
? "Update chart"
: grapher.id
? "Save draft"
: "Create draft"}
? "Save draft"
: "Create draft"}
</button>{" "}
<button
className="btn btn-secondary"
Expand Down
10 changes: 2 additions & 8 deletions adminSiteServer/adminRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -217,17 +217,11 @@ adminRouter.get("/posts/compare/:postId", async (req, res) => {
<div>
<div style="width: 50%; float: left;">
<h1>WP</h1>
<iframe srcdoc="${wpPage.replaceAll(
'"',
"&quot;"
)}" style="width: 100%; height: 100vh;"></iframe>
<iframe srcdoc="${wpPage.replaceAll('"', "&quot;")}" style="width: 100%; height: 100vh;"></iframe>
</div>
<div style="width: 50%; float: left;">
<h1>ArchieML</h1>
<iframe srcdoc="${archieMlPage.replaceAll(
'"',
"&quot;"
)}" style="width: 100%; height: 100vh;"></iframe>
<iframe srcdoc="${archieMlPage.replaceAll('"', "&quot;")}" style="width: 100%; height: 100vh;"></iframe>
</div>
</div>
</body>
Expand Down
10 changes: 4 additions & 6 deletions adminSiteServer/apiRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1515,8 +1515,7 @@ apiRouter.get(
// careful there to only allow carefully guarded vocabularies from being used, not
// arbitrary user input
const whereClause = filterSExpr?.toSql() ?? "true"
const resultsWithStringGrapherConfigs =
await db.queryMysql(`SELECT charts.id as id,
const resultsWithStringGrapherConfigs = await db.queryMysql(`SELECT charts.id as id,
charts.config as config,
charts.createdAt as createdAt,
charts.updatedAt as updatedAt,
Expand Down Expand Up @@ -1603,8 +1602,7 @@ apiRouter.get(
// careful there to only allow carefully guarded vocabularies from being used, not
// arbitrary user input
const whereClause = filterSExpr?.toSql() ?? "true"
const resultsWithStringGrapherConfigs =
await db.queryMysql(`SELECT variables.id as id,
const resultsWithStringGrapherConfigs = await db.queryMysql(`SELECT variables.id as id,
variables.name as name,
variables.grapherConfigAdmin as config,
d.name as datasetname,
Expand Down Expand Up @@ -2604,8 +2602,8 @@ apiRouter.put("/gdocs/:id", async (req, res) => {
prevJson.published && nextJson.published
? "Updating"
: !prevJson.published && nextJson.published
? "Publishing"
: "Unpublishing"
? "Publishing"
: "Unpublishing"
await triggerStaticBuild(res.locals.user, `${action} ${nextJson.slug}`)
}

Expand Down
4 changes: 2 additions & 2 deletions adminSiteServer/testPageRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ async function propsFromQueryParams(
const page = params.page
? expectInt(params.page)
: params.random
? Math.floor(1 + Math.random() * 180) // Sample one of 180 pages. Some charts won't ever get picked but good enough.
: 1
? Math.floor(1 + Math.random() * 180) // Sample one of 180 pages. Some charts won't ever get picked but good enough.
: 1
const perPage = parseIntOrUndefined(params.perPage) ?? 20
const ids = parseIntArrayOrUndefined(params.ids)
const datasetIds = parseIntArrayOrUndefined(params.datasetIds)
Expand Down
1 change: 0 additions & 1 deletion baker/formatWordpressPost.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,6 @@ export const formatWordpressPost = async (
container.append(parent.children())
parent.append(container)
}

// Nesting for sticky columns that have been manually created
;(["left", "right"] as const).forEach((side) => {
cheerioEl(`.wp-block-columns.is-style-sticky-${side}`).each(
Expand Down
24 changes: 12 additions & 12 deletions baker/siteRenderers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -600,12 +600,12 @@ export const renderProminentLinks = async (
(!isCanonicalInternalUrl(resolvedUrl)
? null // attempt fallback for internal urls only
: resolvedUrl.isExplorer
? await getExplorerTitleByUrl(resolvedUrl)
: resolvedUrl.isGrapher && resolvedUrl.slug
? (await Chart.getBySlug(resolvedUrl.slug))?.config
?.title // optim?
: resolvedUrl.slug &&
(await getPostBySlug(resolvedUrl.slug)).title)
? await getExplorerTitleByUrl(resolvedUrl)
: resolvedUrl.isGrapher && resolvedUrl.slug
? (await Chart.getBySlug(resolvedUrl.slug))
?.config?.title // optim?
: resolvedUrl.slug &&
(await getPostBySlug(resolvedUrl.slug)).title)
} finally {
if (!title) {
logErrorAndMaybeSendToBugsnag(
Expand All @@ -625,12 +625,12 @@ export const renderProminentLinks = async (
(!isCanonicalInternalUrl(resolvedUrl)
? null
: resolvedUrl.isExplorer
? renderExplorerDefaultThumbnail()
: resolvedUrl.isGrapher && resolvedUrl.slug
? renderGrapherThumbnailByResolvedChartSlug(
resolvedUrl.slug
)
: await renderPostThumbnailBySlug(resolvedUrl.slug))
? renderExplorerDefaultThumbnail()
: resolvedUrl.isGrapher && resolvedUrl.slug
? renderGrapherThumbnailByResolvedChartSlug(
resolvedUrl.slug
)
: await renderPostThumbnailBySlug(resolvedUrl.slug))

const rendered = ReactDOMServer.renderToStaticMarkup(
<div className="block-wrapper">
Expand Down
4 changes: 2 additions & 2 deletions datapage/Datapage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ export const getDatapageGdoc = async (
const googleDocId = isPlainGoogleId
? googleDocEditLinkOrId
: getLinkType(googleDocEditLinkOrId) === "gdoc"
? getUrlTarget(googleDocEditLinkOrId)
: null
? getUrlTarget(googleDocEditLinkOrId)
: null

if (!googleDocId) return null

Expand Down
16 changes: 4 additions & 12 deletions db/contentGraph.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,11 @@ const getContent = (slugs: string[]): string => {
return `
<p>Sed lacinia vehicula commodo. Praesent vehicula ipsum nec justo vulputate, at
pellentesque nisi lacinia. Mauris dapibus non orci ut blandit. Maecenas nibh
${getLink(
slugs[0]
)} diam, condimentum sed maximus a, egestas sed eros. Ut et massa vulputate lacus
volutpat lectus. Interdum ${getIframe(
slugs[1]
)} et malesuada fames ac ante ipsum primis in faucibus.
${getLink(slugs[0])} diam, condimentum sed maximus a, egestas sed eros. Ut et massa vulputate lacus
volutpat lectus. Interdum ${getIframe(slugs[1])} et malesuada fames ac ante ipsum primis in faucibus.
Donec venenatis volutpat velit, a tempor risus mattis ac.
This is data from Schutte, A. E. (2017). ${getIframe(
slugs[0]
)}Global, regional, and national age-sex specific mortality
for 264 causes of death, 1980-2016: a ${getIframe(
slugs[2]
)}systematic analysis for the Global Burden of Disease Study 2016.
This is data from Schutte, A. E. (2017). ${getIframe(slugs[0])}Global, regional, and national age-sex specific mortality
for 264 causes of death, 1980-2016: a ${getIframe(slugs[2])}systematic analysis for the Global Burden of Disease Study 2016.
Available <a href=\"http:\/\/www.thelancet.com\/pdfs\/journals\/lancet\/PIIS0140-6736(17)32152-9.pdf\">online<\/a>.
{\/ref}<\/p>
`
Expand Down
2 changes: 1 addition & 1 deletion db/migration/1701450183524-TagTopicSlug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ const manualSlugMap: Record<string, string> = {
// The result of running resolveSlugs() on 2023-12-01
// Plus manualSlugMap resolutions
// Minus topicsThatAreNoLongerTopics
// prettier-ignore
// biome-ignore format: easier multiline editing w/ quotes for all keys
const tagNameSlugResolutions = {
...manualSlugMap,
"Child & Infant Mortality": "child-and-infant-mortality",
Expand Down
15 changes: 12 additions & 3 deletions db/model/Chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,20 @@ export class Chart extends BaseEntity {
@Column() updatedAt!: Date
@Column() isExplorable!: boolean

@ManyToOne(() => User, (user) => user.lastEditedCharts)
@ManyToOne(
() => User,
(user) => user.lastEditedCharts
)
lastEditedByUser!: Relation<User>
@ManyToOne(() => User, (user) => user.publishedCharts)
@ManyToOne(
() => User,
(user) => user.publishedCharts
)
publishedByUser!: Relation<User>
@OneToMany(() => ChartRevision, (rev) => rev.chart)
@OneToMany(
() => ChartRevision,
(rev) => rev.chart
)
logs!: Relation<ChartRevision[]>

static table: string = "charts"
Expand Down
10 changes: 8 additions & 2 deletions db/model/ChartRevision.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,15 @@ export class ChartRevision extends BaseEntity {
@Column() createdAt!: Date
@Column() updatedAt!: Date

@ManyToOne(() => User, (user) => user.editedCharts)
@ManyToOne(
() => User,
(user) => user.editedCharts
)
user!: Relation<User>

@ManyToOne(() => Chart, (chart) => chart.logs)
@ManyToOne(
() => Chart,
(chart) => chart.logs
)
chart!: Relation<Chart>
}
5 changes: 4 additions & 1 deletion db/model/Dataset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ export class Dataset extends BaseEntity {
@Column({ default: false }) isPrivate!: boolean
@Column({ default: false }) nonRedistributable!: boolean

@ManyToOne(() => User, (user) => user.createdDatasets)
@ManyToOne(
() => User,
(user) => user.createdDatasets
)
createdByUser!: Relation<User>

// Export dataset variables to CSV (not including metadata)
Expand Down
5 changes: 4 additions & 1 deletion db/model/Gdoc/GdocBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ export class Tag extends BaseEntity implements TagInterface {
@Column() isBulkImport!: boolean
@Column({ type: "varchar", nullable: true }) slug!: string | null
@Column() specialType!: string
@ManyToMany(() => GdocBase, (gdoc) => gdoc.tags)
@ManyToMany(
() => GdocBase,
(gdoc) => gdoc.tags
)
gdocs!: GdocBase[]
}

Expand Down
12 changes: 6 additions & 6 deletions db/model/Gdoc/enrichedToMarkdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,12 @@ ${b.url}`
const imageOrChart = insight.filename
? `![](${insight.filename})`
: insight.url
? markdownComponent(
"Chart",
{ url: insight.url },
exportComponents
)
: undefined
? markdownComponent(
"Chart",
{ url: insight.url },
exportComponents
)
: undefined
const content =
enrichedBlocksToMarkdown(
insight.content,
Expand Down
11 changes: 5 additions & 6 deletions db/model/Gdoc/rawToEnriched.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1492,12 +1492,11 @@ export function parseFaqs(
id: faq.id,
content: enrichedText,
parseErrors: compact([
...enrichedText.flatMap(
(block) =>
block?.parseErrors.map((parseError) => ({
...parseError,
message: `Block parse error in faq with id "${faq.id}": ${parseError.message}`,
}))
...enrichedText.flatMap((block) =>
block?.parseErrors.map((parseError) => ({
...parseError,
message: `Block parse error in faq with id "${faq.id}": ${parseError.message}`,
}))
),
]),
}
Expand Down
6 changes: 5 additions & 1 deletion db/model/Link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ import { formatUrls } from "../../site/formatting.js"
@Entity("posts_gdocs_links")
export class Link extends BaseEntity implements OwidGdocLinkJSON {
@PrimaryGeneratedColumn() id!: number
@ManyToOne(() => GdocBase, (gdoc) => gdoc.id) source!: Relation<GdocBase>
@ManyToOne(
() => GdocBase,
(gdoc) => gdoc.id
)
source!: Relation<GdocBase>
@Column() linkType!: "gdoc" | "url" | "grapher" | "explorer"
@Column() target!: string
@Column() queryString!: string
Expand Down
20 changes: 16 additions & 4 deletions db/model/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,28 @@ export class User extends BaseEntity {
@Column() lastLogin!: Date
@Column() lastSeen!: Date

@OneToMany(() => Chart, (chart) => chart.lastEditedByUser)
@OneToMany(
() => Chart,
(chart) => chart.lastEditedByUser
)
lastEditedCharts!: Relation<Chart[]>

@OneToMany(() => Chart, (chart) => chart.publishedByUser)
@OneToMany(
() => Chart,
(chart) => chart.publishedByUser
)
publishedCharts!: Relation<Chart[]>

@OneToMany(() => ChartRevision, (rev) => rev.user)
@OneToMany(
() => ChartRevision,
(rev) => rev.user
)
editedCharts!: Relation<ChartRevision[]>

@OneToMany(() => Dataset, (dataset) => dataset.createdByUser)
@OneToMany(
() => Dataset,
(dataset) => dataset.createdByUser
)
createdDatasets!: Relation<Dataset[]>

async setPassword(password: string): Promise<void> {
Expand Down
2 changes: 1 addition & 1 deletion devTools/cypress/cypress.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"baseUrl": "http://localhost:3030"
"baseUrl": "http://localhost:3030"
}
Loading

0 comments on commit 7dbb9d1

Please sign in to comment.