Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[do not merge] List documents to see when url are generated and if they return a 404 #43

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 120 additions & 0 deletions app/testDocuments/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
import * as React from "react";
import { getDossier } from "@/repository/database";
import {
Accordion,
AccordionSummary,
AccordionDetails,
Box,
} from "@mui/material";
import { getDocumentURL } from "@/domain/dataTransform";

const ids = [
"DLR5L16N47558",
"DLR5L16N45912",
"DLR5L16N45913",
"DLR5L16N45914",
"DLR5L16N45926",
"DLR5L16N47568",
"DLR5L16N47569",
"DLR5L16N47571",
"DLR5L16N45892",
"DLR5L16N45893",
"DLR5L16N45894",
"DLR5L16N45895",
"DLR5L16N45905",
"DLR5L16N45906",
"DLR5L16N45907",
"DLR5L16N45908",
"DLR5L16N45911",
"DLR5L16N45927",
"DLR5L16N45929",
"DLR5L16N45931",
"DLR5L16N45909",
"DLR5L16N45910",
"DLR5L16N45933",
"DLR5L16N45988",
"DLR5L16N46005",
"DLR5L16N46006",
"DLR5L16N46007",
"DLR5L16N46008",
"DLR5L16N46009",
"DLR5L16N46026",
"DLR5L16N46027",
"DLR5L16N46046",
"DLR5L16N45915",
"DLR5L16N45916",
"DLR5L16N45917",
"DLR5L16N45918",
"DLR5L16N46049",
"DLR5L16N46057",
"DLR5L16N46058",
"DLR5L16N45919",
"DLR5L16N45920",
"DLR5L16N45921",
"DLR5L16N45930",
"DLR5L16N46059",
"DLR5L16N45932",
"DLR5L16N45934",
"DLR5L16N45935",
"DLR5L16N45936",
"DLR5L16N45939",
"DLR5L16N45940",
];

async function getDocuments() {
const rep = [];

Check failure on line 65 in app/testDocuments/page.tsx

View workflow job for this annotation

GitHub Actions / build-check

Variable 'rep' implicitly has type 'any[]' in some locations where its type cannot be determined.
for (let i = 0; i < ids.length; i += 1) {
const d = await getDossier("16", ids[i]);
// console.log(d?.documents);
if (d?.documents) {
Object.values(d?.documents).forEach((doc) => rep.push(doc));
}
}
return rep;

Check failure on line 73 in app/testDocuments/page.tsx

View workflow job for this annotation

GitHub Actions / build-check

Variable 'rep' implicitly has an 'any[]' type.
}
export default async function Page() {
const documents = await getDocuments();
// console.log(documents);

documents.forEach((doc) => {
const url = getDocumentURL(doc);

console.log(
`${doc.uid}\t${doc.titrePrincipalCourt}\t${
url ?? "no data"
}\t${JSON.stringify(doc)}`
);
});
return (
<div>
{documents.map((doc) => {
const url = getDocumentURL(doc);

return (
<Accordion key={doc.uid}>
<AccordionSummary
// expandIcon={<ExpandMoreIcon />}
>
<Box sx={{ display: "flex", flexDirection: "column" }}>
{doc.titrePrincipalCourt} ({doc.uid})
<br />
<p style={{ color: "blue" }}>
{url ? (
<a href={url} target="_blank">
{url}
</a>
) : (
"no url"
)}
</p>
</Box>
</AccordionSummary>
<AccordionDetails>
<pre>{JSON.stringify(doc, null, 2)}</pre>
</AccordionDetails>
</Accordion>
);
})}
</div>
);
}
1 change: 1 addition & 0 deletions components/folderHomePage/DossierList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default async function DossierList(props: DossierListProps) {

const dossiers = await getDossiers({ legislature: 16 }, 50);

console.log(dossiers.map(d => d.uid))
const dossierMensuels = [{ date: "2024-03-01", dossiers }];
const dossierMensuelsFiltered = dossierMensuels
.map((month) => {
Expand Down
Loading
Loading