Skip to content

Commit

Permalink
Reflect indices' status in maintenance view
Browse files Browse the repository at this point in the history
  • Loading branch information
bkis committed Aug 16, 2024
1 parent 9f0b918 commit c138bdb
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 8 deletions.
13 changes: 9 additions & 4 deletions Tekst-API/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -10691,6 +10691,10 @@
}
],
"title": "Createdat"
},
"upToDate": {
"type": "boolean",
"title": "Uptodate"
}
},
"type": "object",
Expand All @@ -10700,7 +10704,8 @@
"size",
"searches",
"fields",
"createdAt"
"createdAt",
"upToDate"
],
"title": "IndexInfo"
},
Expand Down Expand Up @@ -15060,7 +15065,7 @@
"format": "date-time",
"title": "Contentschangedat",
"description": "The last time contents of any resource on this text changed",
"default": "2024-08-16T12:31:33.367147"
"default": "2024-08-16T15:10:30.500337"
},
"indexCreatedAt": {
"type": "string",
Expand Down Expand Up @@ -15192,7 +15197,7 @@
"format": "date-time",
"title": "Contentschangedat",
"description": "The last time contents of any resource on this text changed",
"default": "2024-08-16T12:31:33.367147"
"default": "2024-08-16T15:10:30.500337"
},
"indexCreatedAt": {
"type": "string",
Expand Down Expand Up @@ -15372,7 +15377,7 @@
"format": "date-time",
"title": "Contentschangedat",
"description": "The last time contents of any resource on this text changed",
"default": "2024-08-16T12:31:33.367147"
"default": "2024-08-16T15:10:30.500337"
},
"indexCreatedAt": {
"type": "string",
Expand Down
1 change: 1 addition & 0 deletions Tekst-API/tekst/models/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,3 +220,4 @@ class IndexInfo(ModelBase):
searches: int
fields: int
created_at: datetime | None
up_to_date: bool
1 change: 1 addition & 0 deletions Tekst-API/tekst/search/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ async def get_indices_info() -> list[IndexInfo]:
"text_id": text_id if text else None,
"created_at": text.index_created_at if text else None,
"fields": await _get_mapped_fields_count(idx_name),
"up_to_date": text.index_created_at > text.contents_changed_at,
**await _get_index_stats(idx_name),
}
)
Expand Down
8 changes: 5 additions & 3 deletions Tekst-Web/src/api/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2375,6 +2375,8 @@ export interface components {
fields: number;
/** Createdat */
createdAt: string | null;
/** Uptodate */
upToDate: boolean;
};
/** LineLabellingConfig */
LineLabellingConfig: {
Expand Down Expand Up @@ -4648,7 +4650,7 @@ export interface components {
* Contentschangedat
* Format: date-time
* @description The last time contents of any resource on this text changed
* @default 2024-08-16T12:31:33.367147
* @default 2024-08-16T15:10:30.500337
*/
contentsChangedAt?: string;
/**
Expand Down Expand Up @@ -4734,7 +4736,7 @@ export interface components {
* Contentschangedat
* Format: date-time
* @description The last time contents of any resource on this text changed
* @default 2024-08-16T12:31:33.367147
* @default 2024-08-16T15:10:30.500337
*/
contentsChangedAt?: string;
/**
Expand Down Expand Up @@ -4826,7 +4828,7 @@ export interface components {
* Contentschangedat
* Format: date-time
* @description The last time contents of any resource on this text changed
* @default 2024-08-16T12:31:33.367147
* @default 2024-08-16T15:10:30.500337
*/
contentsChangedAt?: string;
/**
Expand Down
23 changes: 22 additions & 1 deletion Tekst-Web/src/views/admin/AdminSystemMaintenanceView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ onBeforeMount(() => {
</tr>
</thead>
<template v-for="(value, key) in indexInfo" :key="key">
<tr v-if="!['createdAt', 'textId', 'fields'].includes(key)">
<tr v-if="!['createdAt', 'textId', 'fields', 'upToDate'].includes(key)">
<th style="font-weight: var(--font-weight-normal)">
{{ $t(`admin.system.maintenance.indices.${key}`) }}
</th>
Expand Down Expand Up @@ -196,6 +196,18 @@ onBeforeMount(() => {
<span v-else>???</span>
</td>
</tr>
<tr>
<th style="font-weight: var(--font-weight-normal)">
{{ $t(`general.status`) }}
</th>
<td>
<span :class="{ 'index-ood': !indexInfo.upToDate, 'index-utd': indexInfo.upToDate }">{{
indexInfo.upToDate
? $t('admin.system.maintenance.indices.utd')
: $t('admin.system.maintenance.indices.ood')
}}</span>
</td>
</tr>
</template>
</n-table>
Expand Down Expand Up @@ -354,4 +366,13 @@ onBeforeMount(() => {
color: var(--col-error);
font-weight: var(--font-weight-bold);
}
.index-ood {
color: var(--col-error);
font-weight: var(--font-weight-bold);
}
.index-utd {
color: var(--col-success);
}
</style>
2 changes: 2 additions & 0 deletions Tekst-Web/translations/ui/deDE.yml
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,8 @@ admin:
searches: Suchen
fields: Felder
createdAt: Erzeugt
utd: Aktuell
ood: Veraltet
actionCreate: Neuindexierung
actionCreateStarted: Die Suchindizes werden im Hintergrund aktualisiert. @:general.takeAWhile
actionCreateSuccess: Suchindizes wurden aktualisiert
Expand Down
2 changes: 2 additions & 0 deletions Tekst-Web/translations/ui/enUS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,8 @@ admin:
searches: Searches
fields: Fields
createdAt: Created
utd: Up to date
ood: Out of date
actionCreate: Reindex
actionCreateStarted: The search indices will be updated in the background. @:general.takeAWhile
actionCreateSuccess: Search indices have been updated
Expand Down

0 comments on commit c138bdb

Please sign in to comment.