Skip to content

Commit

Permalink
fix(alerts): fix corrupted data (#266)
Browse files Browse the repository at this point in the history
* fix(alerts): fix corrupted data

* fix: update

* fix(frontend): remove viewdiff for removed / added document
  • Loading branch information
lionelB committed Jan 14, 2021
1 parent 3e68007 commit c64f916
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 20 deletions.
11 changes: 8 additions & 3 deletions targets/alert-cli/src/diff/fiches-travail-data.js
Expand Up @@ -60,12 +60,17 @@ export function getChanges(previousJson, currentJson) {
const previousIds = previousJson.map(toId);
const currentIds = currentJson.map(toId);

const added = currentJson.filter((doc) => !previousIds.includes(doc.pubId));
const added = currentJson.filter(
(doc) => Boolean(doc.pubId) && !previousIds.includes(doc.pubId)
);
const addedIds = added.map(toId);
const removed = previousJson.filter((doc) => !currentIds.includes(doc.pubId));
const removed = previousJson.filter(
(doc) => Boolean(doc.pubId) && !currentIds.includes(doc.pubId)
);
const modified = currentJson.flatMap((doc) => {
const previousDoc = previousJson.find(
(previousDoc) => doc.pubId === previousDoc.pubId
(previousDoc) => Boolean(doc.pubId) && doc.pubId === previousDoc.pubId
// Boolean(doc.pubId) ensure that we have a valid pubId since there was pubId===null
);
if (
!addedIds.includes(doc.pubId) &&
Expand Down
37 changes: 20 additions & 17 deletions targets/frontend/src/components/changes/FicheTravailDataChange.js
Expand Up @@ -8,29 +8,32 @@ import { ViewDiff } from "./ViewDiff";

export function FicheTravailDiffchange({ change }) {
const [isVisible, setVisible] = useState(false);
const hasChange = (change.previousIntro && change.intro) || change.sections;
return (
<li>
<a target="_blank" rel="noreferrer noopener" href={change.url}>
{change.title}
</a>
<br />
<TButton
aria-controls={change.pubId}
aria-expanded={isVisible}
size="small"
variant="link"
sx={{
"&:hover": {
color: "link",
},
cursor: "pointer",
px: 0,
}}
onClick={() => setVisible(!isVisible)}
>
Voir les modifications{" "}
{isVisible ? <IoIosArrowDown /> : <IoIosArrowForward />}
</TButton>
{hasChange && (
<TButton
aria-controls={change.pubId}
aria-expanded={isVisible}
size="small"
variant="link"
sx={{
"&:hover": {
color: "link",
},
cursor: "pointer",
px: 0,
}}
onClick={() => setVisible(!isVisible)}
>
Voir les modifications{" "}
{isVisible ? <IoIosArrowDown /> : <IoIosArrowForward />}
</TButton>
)}
{isVisible && (
<Card id={change.pubId}>
{change.previousIntro && (
Expand Down
@@ -0,0 +1 @@
-- no down migration
@@ -0,0 +1,9 @@
--
-- Migrate data
-- Update tag field of sources table
--

UPDATE "public"."sources" SET tag = 'v2.24.0' WHERE repository = 'socialgouv/legi-data';
UPDATE "public"."sources" SET tag = 'v2.31.0' WHERE repository = 'socialgouv/kali-data';
UPDATE "public"."sources" SET tag = 'v2.55.0' WHERE repository = 'socialgouv/fiches-vdd';
UPDATE "public"."sources" SET tag = 'v4.37.0' WHERE repository = 'socialgouv/fiches-travail-data';

0 comments on commit c64f916

Please sign in to comment.