Skip to content

Commit

Permalink
feat: add snapshot verification
Browse files Browse the repository at this point in the history
  • Loading branch information
rikdepeuter authored and ArneD committed Jul 29, 2024
1 parent 4545b10 commit c816f72
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 41 deletions.
4 changes: 2 additions & 2 deletions site/src/modules/status/components/StatusCategory.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
v-for="(item, key) in getItems"
:key="key"
:play="item.play"
:planed="item.planed"
:planned="item.planned"
:paused="item.paused"
:stopped="item.stopped"
:hide-prepand-icon="item.hidePrepandIcon"
Expand Down Expand Up @@ -118,7 +118,7 @@ export default Vue.extend({
interface StatusItem {
play: boolean;
paused: boolean;
planed: boolean;
planned: boolean;
stopped: boolean;
hideAppendIcon: boolean;
hidePrepandIcon: boolean;
Expand Down
10 changes: 5 additions & 5 deletions site/src/modules/status/components/StatusItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default Vue.extend({
type: Boolean,
default: false,
},
planed: {
planned: {
type: Boolean,
default: false,
},
Expand Down Expand Up @@ -97,7 +97,7 @@ export default Vue.extend({
},
computed: {
prepandIcon(): string {
if(this.planed)
if(this.planned)
return "synchronize-timeout";
if(this.play)
return "play";
Expand All @@ -106,7 +106,7 @@ export default Vue.extend({
return "stop"
},
prepandHoverText(): string {
if(this.planed)
if(this.planned)
return "Gepland";
if(this.play)
return "Actief";
Expand All @@ -118,7 +118,7 @@ export default Vue.extend({
if(this.success){
return "calendar_check";
}
if (this.play || this.planed || this.stopped) {
if (this.play || this.planned || this.stopped) {
return "warning";
}
return "question-mark"
Expand All @@ -128,7 +128,7 @@ export default Vue.extend({
return {color:"green"};
}
if (this.play || this.planed || this.stopped) {
if (this.play || this.planned || this.stopped) {
return {color:"orange"};
}
Expand Down
116 changes: 82 additions & 34 deletions site/src/modules/status/views/Status.vue
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ export default Vue.extend({
title: "Cache",
loaded: false,
},
{
name: "snapshot",
title: "Snapshot",
loaded: false,
},
] as Array<{ name: StatusType; title: string; loaded: boolean }>,
syndicationTranslations: [
Expand Down Expand Up @@ -207,30 +212,31 @@ export default Vue.extend({
},
methods: {
async init() {
this.refresh("projections", () => this.refresh("syndication"));
this.refresh("producer");
this.refresh("consumer");
this.refresh("feed");
this.refresh("import");
this.refresh("cache");
this.refresh("importerGrb");
this.refresh("backOfficeProjections");
this.refresh("projections", () => this.refresh("syndication"));
this.refresh("producer");
this.refresh("consumer");
this.refresh("feed");
this.refresh("import");
this.refresh("cache");
this.refresh("importerGrb");
this.refresh("backOfficeProjections");
this.refresh("snapshot");
},
async refresh(statusType: StatusType, callback: any = undefined) {
const type = this.statusTypes.find((i: { name: StatusType; loaded: boolean }) => i.name == statusType);
type!.loaded = false;
let data = {} as any;
try{
try {
switch (statusType) {
case "projections":
case "feed":
data = await PublicApiClient.getProjectionStatus();
break;
case "producer":
data = await PublicApiClient.getProducerStatus();
data = await PublicApiClient.getProducerStatus();
break;
case "consumer":
data = await PublicApiClient.getConsumerStatus();
data = await PublicApiClient.getConsumerStatus();
break;
case "cache":
data = await PublicApiClient.getCacheStatus();
Expand All @@ -247,18 +253,17 @@ export default Vue.extend({
case "backOfficeProjections":
data = await PublicApiClient.getBackOfficeProjectionsStatus();
break;
case "snapshot":
data = await PublicApiClient.getSnapshotStatus();
break;
}
} catch {
data = {};
this.registries.forEach(registry => {
data[`${registry}Registry`] = null;
});
}
catch{
data = {
"addressRegistry": null,
"buildingRegistry": null,
"municipalityRegistry": null,
"parcelRegistry": null,
"streetNameRegistry": null,
"postalRegistry": null
}
}
Object.keys(data).forEach((r: string) => {
const registryId = r.replace("Registry", "").toLowerCase();
this.statusItems[registryId] = Object.assign(this.statusItems[registryId] || {}, { [statusType]: data[r] });
Expand Down Expand Up @@ -345,6 +350,13 @@ export default Vue.extend({
ret.push({ success: false, error: e } as StatusItem);
}
}
if (statusType === "snapshot") {
try {
ret.push(...this.getSnapshotItems(statusType, data));
} catch (e) {
ret.push({ success: false, error: e } as StatusItem);
}
}
return ret;
},
Expand Down Expand Up @@ -384,7 +396,7 @@ export default Vue.extend({
i.name;
if (!p.projections) {
return {
planed: false,
planned: false,
paused: false,
play: false,
stopped: false,
Expand All @@ -408,7 +420,7 @@ export default Vue.extend({
}
const info = this.getRightTextInfo(currentPosition, streamPosition || 0);
const item: StatusItem = {
planed: false,
planned: false,
paused: false,
play: true,
stopped: false,
Expand Down Expand Up @@ -446,7 +458,6 @@ export default Vue.extend({
};
}
const projectionsResponse = this.statusItems;
const items =
backOfficeProjectionsResponse &&
backOfficeProjectionsResponse.projections.map((i) => {
Expand All @@ -467,7 +478,7 @@ export default Vue.extend({
}
const info = this.getRightTextInfo(currentPosition, streamPosition || 0);
const item: StatusItem = {
planed: false,
planned: false,
paused: false,
play: true,
stopped: false,
Expand Down Expand Up @@ -505,7 +516,7 @@ export default Vue.extend({
const success = i.numberOfRecordsToProcess == 0;
const rightText = success ? "" : `Aantal niet gecachte objecten: ${i.numberOfRecordsToProcess}`;
const item: StatusItem = {
planed: false,
planned: false,
paused: false,
play: false,
stopped: !success,
Expand Down Expand Up @@ -550,7 +561,7 @@ export default Vue.extend({
.map((i) => {
const info = this.getRightTextInfo(i.currentPosition, projectionResponse.streamPosition);
const item: StatusItem = {
planed: false,
planned: false,
paused: i.state == "crashed" || i.state == "unknown",
play: i.state == "catchingUp" || i.state == "subscribed",
stopped: i.state == "stopped",
Expand Down Expand Up @@ -595,7 +606,7 @@ export default Vue.extend({
.map((i) => {
const info = this.getRightTextInfo(i.currentPosition, ProducerResponse.streamPosition);
const item: StatusItem = {
planed: false,
planned: false,
paused: i.state == "crashed" || i.state == "unknown",
play: i.state == "catchingUp" || i.state == "subscribed",
stopped: i.state == "stopped",
Expand Down Expand Up @@ -640,7 +651,7 @@ export default Vue.extend({
d.getMinutes())}:${twoDigit(d.getSeconds())}`;
var deltaInHours = moment().diff(moment(i.dateProcessed, 'YYYY-MM-DD hh:mm:ss'), 'hours');
const item: StatusItem = {
planed: false,
planned: false,
paused: false,
play: deltaInHours < 24,
stopped: deltaInHours >= 24,
Expand All @@ -658,6 +669,42 @@ export default Vue.extend({
});
return items;
},
getSnapshotItems(statusType: StatusType, data: any) {
const snapshotResponse = data[statusType] as
| {
name: String;
failedSnapshotsCount: number;
differenceInDaysOfLastVerification: number;
}
| null
| undefined;
if (!snapshotResponse) {
throw {
title: "Snapshot status ophalen is mislukt",
text: "Er is iets fout gelopen tijdens het ophalen van de status van de snapshot. Probeer het later opnieuw.",
inline: false,
};
}
var isError = snapshotResponse.failedSnapshotsCount > 0 || snapshotResponse.differenceInDaysOfLastVerification > 1;
const item: StatusItem = {
planned: false,
paused: false,
play: !isError,
stopped: isError,
hideAppendIcon: false,
hidePrepandIcon: false,
disableHoverText: false,
hoverText: `${snapshotResponse.failedSnapshotsCount} foutieve snapshot(s)`,
prependHoverText: "",
text: 'Snapshot verificatie',
rightText: `Laatste wijziging: ${snapshotResponse.differenceInDaysOfLastVerification == 1 ? '1 dag' : `${snapshotResponse.differenceInDaysOfLastVerification} dagen`} geleden`,
success: !isError,
error: undefined,
};
return [item];
},
getFeedItems(statusType: StatusType, data: any) {
const projectionResponse = data[statusType] as
| {
Expand Down Expand Up @@ -686,7 +733,7 @@ export default Vue.extend({
.map((i) => {
const info = this.getRightTextInfo(i.currentPosition, projectionResponse.streamPosition);
const item: StatusItem = {
planed: false,
planned: false,
paused: i.state == "stopped" || i.state == "crashed" || i.state == "unknown",
play: i.state == "catchingUp" || i.state == "subscribed",
stopped: false,
Expand Down Expand Up @@ -734,7 +781,7 @@ export default Vue.extend({
const d = new Date(i.lastCompletedImport.until);
const datetime = dateTimeToString(d);
const item: StatusItem = {
planed: true,
planned: true,
paused: false,
play: false,
stopped: false,
Expand Down Expand Up @@ -782,7 +829,7 @@ export default Vue.extend({
const d = new Date(i.lastCompletedImport.until);
const datetime = dateTimeToString(d);
const item: StatusItem = {
planed: true,
planned: true,
paused: false,
play: false,
stopped: false,
Expand Down Expand Up @@ -818,7 +865,7 @@ export default Vue.extend({
},
});
type StatusType = "projections" | "producer" | "consumer" | "feed" | "cache" | "import" | "syndication" | "importerGrb" | "backOfficeProjections";
type StatusType = "projections" | "producer" | "consumer" | "feed" | "cache" | "import" | "syndication" | "importerGrb" | "backOfficeProjections" | "snapshot";
interface RegistryItem<T> {
projections: T;
Expand All @@ -830,12 +877,13 @@ interface RegistryItem<T> {
syndication: T;
importerGrb: T;
backOfficeProjections: T;
snapshot: T;
}
interface StatusItem {
play: boolean;
paused: boolean;
planed: boolean;
planned: boolean;
stopped: boolean;
hideAppendIcon: boolean;
hidePrepandIcon: boolean;
Expand Down
4 changes: 4 additions & 0 deletions site/src/services/public-api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ export const PublicApiClient= {
const path = `/basisregisters-api/v2/status/backoffice`;
return (await apiClient.get<any>(path)).data;
},
getSnapshotStatus: async (): Promise<any> => {
const path = `/basisregisters-api/v2/status/snapshot`;
return (await apiClient.get<any>(path)).data;
},
getErrorDetail: async (id: string): Promise<string> => {
const path = `/basisregisters-api/foutmeldingen/${id}`;
try {
Expand Down

0 comments on commit c816f72

Please sign in to comment.