Skip to content

Commit

Permalink
refactor(wp): deprecate OWID_API_ENDPOINT
Browse files Browse the repository at this point in the history
  • Loading branch information
mlbrgl committed Feb 13, 2024
1 parent c01ee56 commit 3b47356
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
10 changes: 5 additions & 5 deletions db/DEPRECATEDwpdb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@ import {
JsonError,
Topic,
} from "@ourworldindata/types"
import { BLOG_SLUG } from "../settings/serverSettings.js"
import { BLOG_SLUG, WORDPRESS_URL } from "../settings/serverSettings.js"
import {
FOR_SYNC_ONLY_WP_API_ENDPOINT,
FOR_SYNC_ONLY_apiQuery,
FOR_SYNC_ONLY_getPostApiBySlugFromApi,
isWordpressAPIEnabled,
singleton,
OWID_API_ENDPOINT,
FOR_SYNC_ONLY_getEndpointSlugFromType,
FOR_SYNC_ONLY_getBlockApiFromApi,
FOR_SYNC_ONLY_graphqlQuery,
} from "./wpdb.js"
import { getFullPost } from "./model/Post.js"

const ENTRIES_CATEGORY_ID = 44
const DEPRECATED_ENTRIES_CATEGORY_ID = 44
const DEPRECATED_OWID_API_ENDPOINT = `${WORDPRESS_URL}/wp-json/owid/v1`

// Limit not supported with multiple post types: When passing multiple post
// types, the limit is applied to the resulting array of sequentially sorted
Expand Down Expand Up @@ -193,7 +193,7 @@ export const DEPRECATEDgetPostType = async (
search: number | string
): Promise<string> => {
const paramName = typeof search === "number" ? "id" : "slug"
return FOR_SYNC_ONLY_apiQuery(`${OWID_API_ENDPOINT}/type`, {
return FOR_SYNC_ONLY_apiQuery(`${DEPRECATED_OWID_API_ENDPOINT}/type`, {
searchParams: [[paramName, search]],
})
}
Expand Down Expand Up @@ -233,7 +233,7 @@ export const DEPRECATEDgetTopics = async (
if (!isWordpressAPIEnabled) return []

const query = `query {
pages (first: 100, after:"${cursor}", where: {categoryId:${ENTRIES_CATEGORY_ID}} ) {
pages (first: 100, after:"${cursor}", where: {categoryId:${DEPRECATED_ENTRIES_CATEGORY_ID}} ) {
pageInfo {
hasNextPage
endCursor
Expand Down
1 change: 0 additions & 1 deletion db/wpdb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ class WPDB {
export const singleton = new WPDB()

export const FOR_SYNC_ONLY_WP_API_ENDPOINT = `${WORDPRESS_URL}/wp-json/wp/v2`
export const OWID_API_ENDPOINT = `${WORDPRESS_URL}/wp-json/owid/v1`
export const FOR_SYNC_ONLY_WP_GRAPHQL_ENDPOINT = `${WORDPRESS_URL}/wp/graphql`

/* Wordpress GraphQL API query
Expand Down

0 comments on commit 3b47356

Please sign in to comment.