Skip to content

Commit

Permalink
🐝 remove obsolete code
Browse files Browse the repository at this point in the history
  • Loading branch information
danyx23 committed Mar 26, 2024
1 parent e9db6b4 commit 1a011bc
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 163 deletions.
26 changes: 0 additions & 26 deletions db/model/Origin.ts

This file was deleted.

20 changes: 0 additions & 20 deletions db/model/Pageview.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,10 @@
import { keyBy } from "lodash"
import { Entity, Column, BaseEntity } from "typeorm"
import { RawPageview } from "@ourworldindata/utils"
import * as db from "../db.js"
import {
DbPlainAnalyticsPageview,
AnalyticsPageviewsTableName,
} from "@ourworldindata/types"

@Entity("analytics_pageviews")
export class Pageview extends BaseEntity implements RawPageview {
/** The last day with pageview data that is included in the sum */
@Column({ primary: true }) day!: Date
/**
* The _absolute_ URL of the page, e.g. `https://ourworldindata.org/grapher/life-expectancy`.
* Does not include any query parameters.
* Usually does not include a trailing slash, except for the homepage (`/`) and 404s.
*/
@Column({ primary: true }) url!: string
/** Sum of pageviews over the last 7 days. */
@Column() views_7d!: number
/** Sum of pageviews over the last 14 days. */
@Column() views_14d!: number
/** Sum of pageviews over the last 365 days. */
@Column() views_365d!: number
}

export async function getAnalyticsPageviewsByUrlObj(
knex: db.KnexReadonlyTransaction
): Promise<{
Expand Down
10 changes: 0 additions & 10 deletions db/model/Source.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
import { Entity, PrimaryGeneratedColumn, Column, BaseEntity } from "typeorm"
import {
DbEnrichedSource,
DbRawSource,
SourcesTableName,
parseSourcesRow,
} from "@ourworldindata/types"
import { KnexReadonlyTransaction } from "../db.js"

@Entity("sources")
export class Source extends BaseEntity {
@PrimaryGeneratedColumn() id!: number
@Column() datasetId!: number
@Column() name!: string
@Column({ default: "{}", type: "json" }) description!: any
}

export async function getSourceById(
knex: KnexReadonlyTransaction,
sourceId: number
Expand Down
108 changes: 1 addition & 107 deletions db/model/Variable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,118 +21,12 @@ import {
OwidVariableId,
ChartTypeName,
DimensionProperty,
OwidLicense,
GrapherInterface,
OwidProcessingLevel,
DbRawVariable,
} from "@ourworldindata/types"
import { knexRaw, knexRawFirst } from "../db.js"

export interface VariableRow {
id: number
name: string
shortName?: string
code: string | null
unit: string
shortUnit: string | null
description: string | null
createdAt: Date
updatedAt: Date
datasetId: number
sourceId: number
display: OwidVariableDisplayConfigInterface
coverage?: string
timespan?: string
columnOrder?: number
catalogPath?: string
dimensions?: Dimensions
schemaVersion?: number
processingLevel?: OwidProcessingLevel
titlePublic?: string
titleVariant?: string
attributionShort?: string
citationInline?: string
descriptionShort?: string
descriptionFromProducer?: string
descriptionKey?: string[] // this is json in the db but by convention it is always a list of strings
descriptionProcessing?: string
licenses?: OwidLicense[]
grapherConfigAdmin?: GrapherInterface
grapherConfigETL?: GrapherInterface
license?: OwidLicense
updatePeriodDays?: number
datasetVersion?: string
version?: string

// missing here but existsin the DB:
// originalMetadata
}

interface Dimensions {
originalName: string
originalShortName: string
filters: {
name: string
value: string
}[]
}

export type UnparsedVariableRow = Omit<
VariableRow,
| "display"
| "descriptionKey"
| "grapherConfigAdmin"
| "grapherConfigETL"
| "license"
| "licenses"
> & {
display: string
descriptionKey?: string
grapherConfigAdmin?: string
grapherConfigETL?: string
license?: string
licenses?: string
}

export type VariableQueryRow = Readonly<
Omit<UnparsedVariableRow, "dimensions"> & {
display: string
datasetName: string
nonRedistributable: number
sourceName: string
sourceDescription: string
dimensions: string
}
>

export type Field = keyof VariableRow

export function parseVariableRows(
plainRows: UnparsedVariableRow[]
): VariableRow[] {
const parsedRows: VariableRow[] = []
for (const plainRow of plainRows) {
const row = {
...plainRow,
display: plainRow.display
? JSON.parse(plainRow.display)
: undefined,
descriptionKey: plainRow.descriptionKey
? JSON.parse(plainRow.descriptionKey)
: [],
grapherConfigAdmin: plainRow.grapherConfigAdmin
? JSON.parse(plainRow.grapherConfigAdmin)
: [],
grapherConfigETL: plainRow.grapherConfigETL
? JSON.parse(plainRow.grapherConfigETL)
: [],
licenses: plainRow.licenses ? JSON.parse(plainRow.licenses) : [],
license: plainRow.license ? JSON.parse(plainRow.license) : [],
}
parsedRows.push(row)
}
return parsedRows
}
//export type Field = keyof VariableRow

export async function getMergedGrapherConfigForVariable(
variableId: number,
Expand Down

0 comments on commit 1a011bc

Please sign in to comment.