Skip to content

Commit

Permalink
Revert "feat: Remove displaying and querying legacy documents from ol…
Browse files Browse the repository at this point in the history
…d database"

This reverts commit 0bcec91.
  • Loading branch information
ptbrowne committed Aug 12, 2024
1 parent e0a37b9 commit d893813
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/components/operator-documents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,14 @@ export const OperatorDocuments = ({ id }: { id: string }) => {
variables: { locale, id },
});

const legacyDocuments =
documentsQuery.data?.operator?.documents ?? EMPTY_ARRAY;
const geverDocuments =
documentsQuery.data?.operator?.geverDocuments ?? EMPTY_ARRAY;

// Deduplicate documents taking in priority GEVER documents
const documents = uniqBy(
geverDocuments,
[...geverDocuments, ...legacyDocuments],
(doc) => `${doc.category} - ${doc.year}`
);

Expand Down
7 changes: 7 additions & 0 deletions src/graphql/queries.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,13 @@ query ObservationsWithAllPriceComponents(

query OperatorDocuments($id: String!, $locale: String!) {
operator(id: $id, locale: $locale) {
documents {
id
name
url
year
category
}
geverDocuments {
id
name
Expand Down
7 changes: 7 additions & 0 deletions src/graphql/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,12 @@ import {
SwissMedianObservationResolvers,
} from "./resolver-types";


const gfmSyntax = require("micromark-extension-gfm");
const gfmHtml = require("micromark-extension-gfm/html");



const expectedCubeDimensions = [
"https://energy.ld.admin.ch/elcom/electricityprice/dimension/category",
"https://energy.ld.admin.ch/elcom/electricityprice/dimension/municipality",
Expand Down Expand Up @@ -398,6 +401,10 @@ const Operator: OperatorResolvers = {
});
},

documents: async ({ id }) => {
return getOperatorDocuments({ operatorId: id });
},

geverDocuments: async ({ id: operatorId }) => {
const { data: operatorInfo } = await fetchOperatorInfo({ operatorId });
const uid = operatorInfo?.uid;
Expand Down

0 comments on commit d893813

Please sign in to comment.