You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/api-server/architecture/data-access-flow.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,7 +40,7 @@ This flow applies to requests for a collection of items.
40
40
This crucial middleware uses the `ModelConfig` to determine the required permission for a `GET` collection request. It checks if the authenticated user has this permission. If not, a `403 Forbidden` error is thrown.
The request finally reaches the handler. The handler uses the `DataOperationRegistry` to find the correct `readAll` function for the specified model and executes it, passing along any filter, sort, or pagination parameters.
43
+
The request finally reaches the handler. The handler uses the `DataOperationRegistry` to find the correct `readAll` function for the specified model and executes it. For the `country` model, if a `usage` filter is present, the request is delegated to the `CountryService` for specialized, non-paginated results; otherwise, it proceeds with standard pagination and sorting.
44
44
45
45
7.**Response**
46
46
The handler wraps the data from the repository in a standard `SuccessApiResponse` and sends it back to the client.
Copy file name to clipboardExpand all lines: src/content/docs/api-server/architecture/data-seeding-and-fixtures.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,7 @@ The primary goal of this system is to **guarantee a consistent and predictable s
13
13
14
14
This process is designed to be **lean and focused on system setup, not content population**. It handles two critical, one-time tasks:
15
15
16
-
1.**Ensuring Database Indexes:** It creates all necessary MongoDB indexes, including TTL (Time-To-Live) indexes for temporary data like verification codes and text indexes for search functionality.
16
+
1.**Ensuring Database Indexes:** It creates all necessary MongoDB indexes, including TTL (Time-To-Live) indexes for temporary data like verification codes, text indexes for search functionality, and compound indexes to optimize country-related aggregation queries.
17
17
2.**Initializing the Admin User:** It securely sets up the single administrator account based on the `OVERRIDE_ADMIN_EMAIL` environment variable.
Copy file name to clipboardExpand all lines: src/content/docs/api-server/features/data-management-api.mdx
+13-1Lines changed: 13 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,6 +23,18 @@ GET /api/v1/data?model=headline
23
23
GET /api/v1/data/some-topic-id?model=topic
24
24
```
25
25
26
+
**Example: Fetching countries by usage**
27
+
```http
28
+
GET /api/v1/data?model=country&filter={"usage":"eventCountry"}
29
+
```
30
+
This fetches countries that are referenced as 'event countries' in headlines. Similarly, `filter={"usage":"headquarters"}` can be used to fetch countries that are headquarters for sources.
31
+
32
+
<Asidetype="note"title="Why use the 'usage' filter for countries?">
33
+
The `usage` filter for the `country` model is designed to enhance the client-side user experience and optimize data retrieval. Instead of fetching a comprehensive list of all countries globally, this filter allows client applications to retrieve only those countries that are *relevant* to existing content.
34
+
35
+
For instance, when a user wants to filter headlines by the country where the news event occurred, it's often more practical to present a list of countries for which actual headlines exist. Similarly, when filtering by the headquarters of news sources, displaying only countries that host active sources provides a more focused and actionable selection. This approach avoids presenting users with a long list of irrelevant options, streamlining navigation and improving the efficiency of data display.
36
+
</Aside>
37
+
26
38
### The Dual Registry System
27
39
28
40
The power behind this generic endpoint comes from two central registries:
@@ -41,7 +53,7 @@ The generic data endpoint can manage the following models out-of-the-box:
41
53
-`headline`
42
54
-`topic`
43
55
-`source`
44
-
-`country`
56
+
-`country` (supports specialized filtering by `usage` for 'eventCountry' or 'headquarters')
Copy file name to clipboardExpand all lines: src/content/docs/api-server/reference/data-access.mdx
+17-2Lines changed: 17 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,7 @@ The following model names are supported:
23
23
-`headline`
24
24
-`topic`
25
25
-`source`
26
-
-`country`
26
+
-`country` (supports specialized filtering by `usage` for 'eventCountry' or 'headquarters')
27
27
-`language`
28
28
-`user`
29
29
-`user_app_settings`
@@ -32,7 +32,7 @@ The following model names are supported:
32
32
-`dashboard_summary`
33
33
34
34
<Asidetype="caution"title="Read-Only Models">
35
-
The `country` and `language` models are configured to be **read-only** through the API (i.e., they do not support `POST`, `PUT`, or `DELETE` requests). This is an intentional design choice, as this foundational data is managed via the database seeding process.
35
+
The `country` and `language` models are configured to be **read-only** through the API (i.e., they do not support `POST`, `PUT`, or `DELETE` requests). This is an intentional design choice. This foundational data is managed via the database seeding process.
36
36
</Aside>
37
37
38
38
<Asidetype="caution">
@@ -51,6 +51,14 @@ Retrieves a paginated list of items for a specific model.
51
51
#### Query Parameters
52
52
53
53
-**`filter`** (string, optional): A URL-encoded JSON string representing a MongoDB-style query.
54
+
<Asidetype="note"title="Special Filter for Country Model: 'usage'">
55
+
For the `country` model, the `filter` parameter supports a special `usage` key. This allows you to retrieve a curated list of countries that are relevant to existing content, rather than all countries globally. This is particularly useful for populating dynamic dropdowns or filters in client applications.
56
+
57
+
-`filter={"usage":"eventCountry"}`: Returns countries referenced as `eventCountry` in headlines.
58
+
-`filter={"usage":"headquarters"}`: Returns countries referenced as `headquarters` in sources.
59
+
60
+
When using the `usage` filter for the `country` model, the response will **not** be paginated and will return the complete filtered set of countries.
61
+
</Aside>
54
62
-**`sort`** (string, optional): A comma-separated list of fields to sort by (e.g., `createdAt:desc,title:asc`).
55
63
-**`limit`** (integer, optional): The maximum number of items to return.
56
64
-**`cursor`** (string, optional): The pagination cursor from a previous response to fetch the next page.
@@ -74,6 +82,13 @@ GET /api/v1/data?model=headline&filter={"topic.id":{"$in":["topicId1","topicId2"
74
82
```
75
83
This fetches headlines belonging to specific topics, sorted by creation date.
76
84
</TabItem>
85
+
<TabItemlabel="Country Usage Filter">
86
+
**Request:**
87
+
```
88
+
GET /api/v1/data?model=country&filter={"usage":"eventCountry"}
89
+
```
90
+
This fetches all countries that are referenced as 'event countries' in headlines.
0 commit comments