-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
migration: postgres moissonneur (#92)
* migration: postgres moissonneur * correct extra.sourceId of revision * add migration config outdatedHarvestSources * correct sording * correct migration sonarcloud
- Loading branch information
Showing
14 changed files
with
265 additions
and
196 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,45 @@ | ||
import Link from 'next/link' | ||
import Link from "next/link"; | ||
|
||
import type {RevisionMoissoneurType} from '../../types/moissoneur' | ||
import UpdateStatusBadge from '@/components/update-status-badge' | ||
import {RevisionPublication} from '@/components/revision-publication' | ||
import MongoId from '@/components/mongo-id' | ||
import Tooltip from '@/components/tooltip' | ||
import type { RevisionMoissoneurType } from "../../types/moissoneur"; | ||
import UpdateStatusBadge from "@/components/update-status-badge"; | ||
import { RevisionPublication } from "@/components/revision-publication"; | ||
import MongoId from "@/components/mongo-id"; | ||
import Tooltip from "@/components/tooltip"; | ||
|
||
export const RevisionItemMoissoneur = ( | ||
{_id, sourceId, nbRows, nbRowsWithErrors, updateStatus, updateRejectionReason, publication}: RevisionMoissoneurType, | ||
) => ( | ||
<tr key={_id}> | ||
<td className='fr-col fr-my-1v'> | ||
<MongoId id={_id} /> | ||
export const RevisionItemMoissoneur = ({ | ||
id, | ||
sourceId, | ||
validation, | ||
updateStatus, | ||
updateRejectionReason, | ||
publication, | ||
}: RevisionMoissoneurType) => ( | ||
<tr key={id}> | ||
<td className="fr-col fr-my-1v"> | ||
<MongoId id={id} /> | ||
</td> | ||
<td className='fr-col fr-my-1v'> | ||
<td className="fr-col fr-my-1v"> | ||
<Tooltip text={sourceId}> | ||
<Link legacyBehavior passHref href={{pathname: `/moissonneur-bal/sources/${sourceId}`}}> | ||
<Link | ||
legacyBehavior | ||
passHref | ||
href={{ pathname: `/moissonneur-bal/sources/${sourceId}` }} | ||
> | ||
{sourceId} | ||
</Link> | ||
</Tooltip> | ||
</td> | ||
<td className='fr-col fr-my-1v'> | ||
{nbRows} | ||
</td> | ||
<td className='fr-col fr-my-1v'> | ||
{nbRowsWithErrors} | ||
</td> | ||
<td className="fr-col fr-my-1v">{validation.nbRows}</td> | ||
<td className="fr-col fr-my-1v">{validation.nbRowsWithErrors}</td> | ||
|
||
<td className='fr-col fr-my-1v'> | ||
<td className="fr-col fr-my-1v"> | ||
<UpdateStatusBadge | ||
updateStatus={updateStatus} | ||
updateRejectionReason={updateRejectionReason} | ||
/> | ||
</td> | ||
<td className='fr-col fr-my-1v'> | ||
<td className="fr-col fr-my-1v"> | ||
<RevisionPublication {...publication} /> | ||
</td> | ||
</tr> | ||
) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,97 @@ | ||
import Router from 'next/router' | ||
import Router from "next/router"; | ||
|
||
import Button from '@codegouvfr/react-dsfr/Button' | ||
import Badge from '@codegouvfr/react-dsfr/Badge' | ||
import Button from "@codegouvfr/react-dsfr/Button"; | ||
import Badge from "@codegouvfr/react-dsfr/Badge"; | ||
|
||
import Tooltip from '../tooltip' | ||
import {formatDate} from '@/lib/util/date' | ||
import {getFile} from '@/lib/api-moissonneur-bal' | ||
import Tooltip from "../tooltip"; | ||
import { formatDate } from "@/lib/util/date"; | ||
import { getFile } from "@/lib/api-moissonneur-bal"; | ||
|
||
import UpdateStatusBadge from '@/components/update-status-badge' | ||
import MongoId from '@/components/mongo-id' | ||
import { HarvestMoissonneurType, HarvestStatus } from 'types/moissoneur' | ||
import UpdateStatusBadge from "@/components/update-status-badge"; | ||
import MongoId from "@/components/mongo-id"; | ||
import { HarvestMoissonneurType, HarvestStatus } from "types/moissoneur"; | ||
|
||
interface StatusBadgeProps { | ||
status: HarvestStatus; | ||
error: string; | ||
} | ||
|
||
const StatusBadge = ({status, error}: StatusBadgeProps) => { | ||
const StatusBadge = ({ status, error }: StatusBadgeProps) => { | ||
if (status === HarvestStatus.ACTIVE) { | ||
return <Badge severity='info' noIcon>En cours…</Badge> | ||
return ( | ||
<Badge severity="info" noIcon> | ||
En cours… | ||
</Badge> | ||
); | ||
} | ||
|
||
if (status === HarvestStatus.FAILED) { | ||
return ( | ||
<Tooltip text={error}> | ||
<Badge severity='error' noIcon>Échec</Badge> | ||
<Badge severity="error" noIcon> | ||
Échec | ||
</Badge> | ||
</Tooltip> | ||
) | ||
); | ||
} | ||
|
||
if (status === HarvestStatus.COMPLETED) { | ||
return <Badge severity='success' noIcon>Terminé</Badge> | ||
return ( | ||
<Badge severity="success" noIcon> | ||
Terminé | ||
</Badge> | ||
); | ||
} | ||
} | ||
}; | ||
|
||
const HarvestItem = ({_id, startedAt, finishedAt, status, error, updateStatus, updateRejectionReason, fileId}: HarvestMoissonneurType) => { | ||
const HarvestItem = ({ | ||
id, | ||
startedAt, | ||
finishedAt, | ||
status, | ||
error, | ||
updateStatus, | ||
updateRejectionReason, | ||
fileId, | ||
}: HarvestMoissonneurType) => { | ||
const downloadFile = async () => { | ||
const file = await getFile(fileId) | ||
Router.push(file.url) | ||
} | ||
const file = await getFile(fileId); | ||
Router.push(file.url); | ||
}; | ||
|
||
return ( | ||
<tr> | ||
<td className='fr-col fr-my-1v'> | ||
<MongoId id={_id} /> | ||
<td className="fr-col fr-my-1v"> | ||
<MongoId id={id} /> | ||
</td> | ||
<td className='fr-col fr-my-1v'> | ||
<td className="fr-col fr-my-1v"> | ||
<a>{formatDate(startedAt)}</a> | ||
</td> | ||
<td className='fr-col fr-my-1v'> | ||
<a>{finishedAt ? formatDate(finishedAt) : '…'}</a> | ||
<td className="fr-col fr-my-1v"> | ||
<a>{finishedAt ? formatDate(finishedAt) : "…"}</a> | ||
</td> | ||
<td className='fr-col fr-my-1v'> | ||
<td className="fr-col fr-my-1v"> | ||
<StatusBadge status={status} error={error} /> | ||
</td> | ||
<td className='fr-col fr-my-1v'> | ||
<td className="fr-col fr-my-1v"> | ||
<UpdateStatusBadge | ||
updateStatus={updateStatus} | ||
updateRejectionReason={updateRejectionReason} | ||
/> | ||
</td> | ||
<td className='fr-col fr-my-1v'> | ||
<td className="fr-col fr-my-1v"> | ||
{fileId && ( | ||
<Button | ||
iconId='fr-icon-download-line' | ||
iconPosition='right' | ||
iconId="fr-icon-download-line" | ||
iconPosition="right" | ||
onClick={downloadFile} | ||
> | ||
Télécharger | ||
</Button> | ||
)} | ||
</td> | ||
</tr> | ||
) | ||
} | ||
); | ||
}; | ||
|
||
export default HarvestItem | ||
export default HarvestItem; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.