Skip to content

Commit

Permalink
Merge pull request responsible-ai-collaborative#2412 from clari182/fe…
Browse files Browse the repository at this point in the history
…ature/dates-refactor-reports

Feature/dates refactor - REPORTS
  • Loading branch information
kepae authored Dec 26, 2023
2 parents b1a4672 + 96421b3 commit c6063da
Show file tree
Hide file tree
Showing 25 changed files with 262 additions and 99 deletions.
8 changes: 4 additions & 4 deletions mongo.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ Administering data requires administrative access to the database. This access i

### Dates

* `date_downloaded`:`2019-07-25` # (String) Date the report was downloaded.
* `date_submitted`:`2019-07-25` # (String) Date the report was submitted to the AIID. This determines citation order.
* `date_modified`: `2019-07-25` # (String) Date the report was edited.
* `date_published`: `2019-07-25` # (String) The publication date of the report.
* `date_downloaded`:`2019-07-25` # (Date) Date the report was downloaded.
* `date_submitted`:`2019-07-25` # (Date) Date the report was submitted to the AIID. This determines citation order.
* `date_modified`: `2019-07-25` # (Date) Date the report was edited.
* `date_published`: `2019-07-25` # (Date) The publication date of the report.
* `epoch_incident_date`: `1564016400` # (Int) Date the incident occurred in the Unix Epoch.
* `epoch_date_downloaded`:`1564016400` # (Int) Date the report was downloaded in the Unix Epoch.
* `epoch_date_submitted`:`1564016400` # (Int) Date the report was submitted to the AIID in the Unix Epoch.
Expand Down
14 changes: 7 additions & 7 deletions site/gatsby-site/cypress/e2e/incidentVariants.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
isCompleteReport,
VARIANT_STATUS,
} from '../../src/utils/variants';
import { format, getUnixTime } from 'date-fns';
import { getUnixTime } from 'date-fns';
const { gql } = require('@apollo/client');

const incidentId = 464;
Expand Down Expand Up @@ -192,14 +192,14 @@ describe('Variants pages', () => {
(req) =>
req.body.operationName == 'UpdateVariant' &&
req.body.variables.query.report_number === variant.report_number &&
req.body.variables.set.date_published === new_date_published &&
req.body.variables.set.date_published === new Date(new_date_published).toISOString() &&
req.body.variables.set.submitters[0] === variant.submitters[0] &&
req.body.variables.set.submitters[1] === variant.submitters[1] &&
req.body.variables.set.text === new_text &&
req.body.variables.set.inputs_outputs[0] === new_inputs_outputs_1 &&
req.body.variables.set.inputs_outputs[1] === new_inputs_outputs_2 &&
req.body.variables.set.tags.includes(VARIANT_STATUS.approved) &&
req.body.variables.set.date_modified == format(now, 'yyyy-MM-dd') &&
req.body.variables.set.date_modified == now.toISOString() &&
req.body.variables.set.epoch_date_modified == getUnixTime(now),
'updateVariant',
{
Expand Down Expand Up @@ -269,14 +269,14 @@ describe('Variants pages', () => {
(req) =>
req.body.operationName == 'UpdateVariant' &&
req.body.variables.query.report_number === variant.report_number &&
req.body.variables.set.date_published === new_date_published &&
req.body.variables.set.date_published === new Date(new_date_published).toISOString() &&
req.body.variables.set.submitters[0] === variant.submitters[0] &&
req.body.variables.set.submitters[1] === new_submitter &&
req.body.variables.set.text === new_text &&
req.body.variables.set.inputs_outputs[0] === new_inputs_outputs_1 &&
req.body.variables.set.inputs_outputs[1] === new_inputs_outputs_2 &&
req.body.variables.set.tags.includes(VARIANT_STATUS.rejected) &&
req.body.variables.set.date_modified == format(now, 'yyyy-MM-dd') &&
req.body.variables.set.date_modified == now.toISOString() &&
req.body.variables.set.epoch_date_modified == getUnixTime(now),
'updateVariant',
{
Expand Down Expand Up @@ -346,14 +346,14 @@ describe('Variants pages', () => {
(req) =>
req.body.operationName == 'UpdateVariant' &&
req.body.variables.query.report_number === variant.report_number &&
req.body.variables.set.date_published === new_date_published &&
req.body.variables.set.date_published === new Date(new_date_published).toISOString() &&
req.body.variables.set.submitters[0] === variant.submitters[0] &&
req.body.variables.set.submitters[1] === new_submitter &&
req.body.variables.set.text === new_text &&
req.body.variables.set.inputs_outputs[0] === new_inputs_outputs_1 &&
req.body.variables.set.inputs_outputs[1] === variant.inputs_outputs[1] &&
req.body.variables.set.tags == undefined &&
req.body.variables.set.date_modified == format(now, 'yyyy-MM-dd') &&
req.body.variables.set.date_modified == now.toISOString() &&
req.body.variables.set.epoch_date_modified == getUnixTime(now),
'updateVariant',
{
Expand Down
4 changes: 2 additions & 2 deletions site/gatsby-site/cypress/e2e/integration/apps/variants.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -499,14 +499,14 @@ describe('Variants App', () => {
(req) =>
req.body.operationName == 'UpdateVariant' &&
req.body.variables.query.report_number === variant.report_number &&
req.body.variables.set.date_published === new_date_published &&
req.body.variables.set.date_published === new Date(new_date_published).toISOString() &&
req.body.variables.set.submitters[0] === variant.submitters[0] &&
req.body.variables.set.submitters[1] === new_submitter &&
req.body.variables.set.text === new_text &&
req.body.variables.set.inputs_outputs[0] === new_inputs_outputs_1 &&
req.body.variables.set.inputs_outputs[1] === undefined &&
req.body.variables.set.tags.includes(VARIANT_STATUS.approved) &&
req.body.variables.set.date_modified == format(now, 'yyyy-MM-dd') &&
req.body.variables.set.date_modified == now.toISOString() &&
req.body.variables.set.epoch_date_modified == getUnixTime(now),
'updateVariant',
{
Expand Down
57 changes: 35 additions & 22 deletions site/gatsby-site/cypress/e2e/integration/citeEdit.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,9 @@ describe('Edit report', () => {
const expectedReport = {
authors: ['Test Author'],
cloudinary_id: 'reports/test.com/test.jpg',
date_downloaded: '2022-01-01',
date_downloaded: new Date('2022-01-01').toISOString(),
date_modified: format(now, 'yyyy-MM-dd'),
date_published: '2022-02-02',
epoch_date_downloaded: 1640995200,
date_published: new Date('2022-02-02').toISOString(),
epoch_date_modified: getUnixTime(now),
epoch_date_published: 1643760000,
flag: null,
Expand All @@ -220,8 +219,10 @@ describe('Edit report', () => {

cy.wait('@updateReport').then((xhr) => {
expect(xhr.request.body.variables.query.report_number).eq(expectedReport.report_number);

expect(xhr.request.body.variables.set).to.deep.eq(expectedReport);
expect({
...xhr.request.body.variables.set,
date_modified: format(new Date(xhr.request.body.variables.set.date_modified), 'yyyy-MM-dd'),
}).to.deep.eq(expectedReport);
});

cy.wait('@logReportHistory')
Expand All @@ -232,6 +233,7 @@ describe('Edit report', () => {
...expectedReport,
modifiedBy: user.userId,
user: report10.data.report.user.userId,
date_modified: input.date_modified,
};

expect(input).to.deep.eq(expectedResult);
Expand Down Expand Up @@ -401,10 +403,9 @@ describe('Edit report', () => {
const expectedReport = {
authors: ['Test Author'],
cloudinary_id: 'reports/test.com/test.jpg',
date_downloaded: '2022-01-01',
date_downloaded: new Date('2022-01-01').toISOString(),
date_modified: format(now, 'yyyy-MM-dd'),
date_published: '2022-02-02',
epoch_date_downloaded: 1640995200,
date_published: new Date('2022-02-02').toISOString(),
epoch_date_modified: getUnixTime(now),
epoch_date_published: 1643760000,
flag: null,
Expand All @@ -424,8 +425,10 @@ describe('Edit report', () => {

cy.wait('@updateReport').then((xhr) => {
expect(xhr.request.body.variables.query.report_number).eq(10);

expect(xhr.request.body.variables.set).deep.eq(expectedReport);
expect({
...xhr.request.body.variables.set,
date_modified: format(new Date(xhr.request.body.variables.set.date_modified), 'yyyy-MM-dd'),
}).to.deep.eq(expectedReport);
});

cy.wait('@logReportHistory')
Expand All @@ -436,6 +439,7 @@ describe('Edit report', () => {
...expectedReport,
modifiedBy: user.userId,
user: report10.data.report.user.userId,
date_modified: input.date_modified,
};

expect(input).to.deep.eq(expectedResult);
Expand Down Expand Up @@ -666,11 +670,10 @@ describe('Edit report', () => {
authors: ['Marco Acevedo'],
cloudinary_id:
'reports/assets.change.org/photos/0/yb/id/eYyBIdJOMHpqcty-1600x900-noPad.jpg?1523726975',
date_downloaded: '2019-04-13',
date_downloaded: new Date('2019-04-13').toISOString(),
date_modified: format(now, 'yyyy-MM-dd'),
date_published: '2015-07-11',
date_published: new Date('2015-07-11').toISOString(),
editor_notes: '',
epoch_date_downloaded: 1555113600,
epoch_date_modified: getUnixTime(now),
epoch_date_published: 1436572800,
flag: null,
Expand All @@ -692,7 +695,10 @@ describe('Edit report', () => {
.its('request.body.variables')
.then((variables) => {
expect(variables.query.report_number).to.equal(23);
expect(variables.set).deep.eq(expectedReport);
expect({
...variables.set,
date_modified: format(new Date(variables.set.date_modified), 'yyyy-MM-dd'),
}).deep.eq(expectedReport);
});

cy.wait('@logReportHistory')
Expand All @@ -703,6 +709,7 @@ describe('Edit report', () => {
...expectedReport,
modifiedBy: user.userId,
user: report10.data.report.user.userId,
date_modified: input.date_modified,
};

expect(input).to.deep.eq(expectedResult);
Expand Down Expand Up @@ -934,8 +941,8 @@ describe('Edit report', () => {
authors: ['Marco Acevedo'],
cloudinary_id:
'reports/assets.change.org/photos/0/yb/id/eYyBIdJOMHpqcty-1600x900-noPad.jpg?1523726975',
date_downloaded: '2019-04-13',
date_published: '2015-07-11',
date_downloaded: new Date('2019-04-13').toISOString(),
date_published: new Date('2015-07-11').toISOString(),
flag: null,
image_url:
'https://assets.change.org/photos/0/yb/id/eYyBIdJOMHpqcty-1600x900-noPad.jpg?1523726975',
Expand All @@ -950,7 +957,6 @@ describe('Edit report', () => {
editor_notes: '',
language: 'en',
source_domain: 'change.org',
epoch_date_downloaded: 1555113600,
epoch_date_published: 1436572800,
date_modified: format(now, 'yyyy-MM-dd'),
epoch_date_modified: getUnixTime(now),
Expand All @@ -960,7 +966,10 @@ describe('Edit report', () => {
.its('request.body.variables')
.then((variables) => {
expect(variables.query.report_number).to.equal(23);
expect(variables.set).deep.eq(expectedReport);
expect({
...variables.set,
date_modified: format(new Date(variables.set.date_modified), 'yyyy-MM-dd'),
}).deep.eq(expectedReport);
});

cy.wait('@logReportHistory')
Expand All @@ -971,6 +980,7 @@ describe('Edit report', () => {
...expectedReport,
modifiedBy: user.userId,
user: report10.data.report.user.userId,
date_modified: input.date_modified,
};

expect(input).to.deep.eq(expectedResult);
Expand Down Expand Up @@ -1128,8 +1138,8 @@ describe('Edit report', () => {
authors: ['Marco Acevedo'],
cloudinary_id:
'reports/assets.change.org/photos/0/yb/id/eYyBIdJOMHpqcty-1600x900-noPad.jpg?1523726975',
date_downloaded: '2019-04-13',
date_published: '2015-07-11',
date_downloaded: new Date('2019-04-13').toISOString(),
date_published: new Date('2015-07-11').toISOString(),
flag: null,
image_url:
'https://assets.change.org/photos/0/yb/id/eYyBIdJOMHpqcty-1600x900-noPad.jpg?1523726975',
Expand All @@ -1144,7 +1154,6 @@ describe('Edit report', () => {
editor_notes: '',
language: 'en',
source_domain: 'change.org',
epoch_date_downloaded: 1555113600,
epoch_date_published: 1436572800,
date_modified: format(now, 'yyyy-MM-dd'),
epoch_date_modified: getUnixTime(now),
Expand All @@ -1154,7 +1163,10 @@ describe('Edit report', () => {
.its('request.body.variables')
.then((variables) => {
expect(variables.query.report_number).to.equal(23);
expect(variables.set).deep.eq(expectedReport);
expect({
...variables.set,
date_modified: format(new Date(variables.set.date_modified), 'yyyy-MM-dd'),
}).deep.eq(expectedReport);
});

cy.wait('@logReportHistory')
Expand All @@ -1165,6 +1177,7 @@ describe('Edit report', () => {
...expectedReport,
modifiedBy: user.userId,
user: report10.data.report.user.userId,
date_modified: input.date_modified,
};

expect(input).to.deep.eq(expectedResult);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,10 @@ describe('Functions', () => {
report_number: 2,
is_incident_report: true,
title: 'Submisssion 1 title',
date_downloaded: '2020-10-30',
date_modified: '2021-07-27',
date_published: '2017-05-03',
date_submitted: '2020-10-30',
date_downloaded: new Date('2020-10-30'),
date_modified: new Date('2021-07-27'),
date_published: new Date('2017-05-03'),
date_submitted: new Date('2020-10-30'),
epoch_date_downloaded: 1604016000,
epoch_date_modified: 1686182943,
epoch_date_published: 1493769600,
Expand Down Expand Up @@ -384,10 +384,10 @@ describe('Functions', () => {
report_number: 2,
is_incident_report: true,
title: 'Submisssion 1 title',
date_downloaded: '2020-10-30',
date_modified: '2021-07-27',
date_published: '2017-05-03',
date_submitted: '2020-10-30',
date_downloaded: new Date('2020-10-30'),
date_modified: new Date('2021-07-27'),
date_published: new Date('2017-05-03'),
date_submitted: new Date('2020-10-30'),
epoch_date_downloaded: 1604016000,
epoch_date_modified: 1686182943,
epoch_date_published: 1493769600,
Expand Down Expand Up @@ -541,10 +541,10 @@ describe('Functions', () => {
report_number: 2,
is_incident_report: false,
title: 'Submisssion 1 title',
date_downloaded: '2020-10-30',
date_modified: '2021-07-27',
date_published: '2017-05-03',
date_submitted: '2020-10-30',
date_downloaded: new Date('2020-10-30'),
date_modified: new Date('2021-07-27'),
date_published: new Date('2017-05-03'),
date_submitted: new Date('2020-10-30'),
epoch_date_downloaded: 1604016000,
epoch_date_modified: 1686182943,
epoch_date_published: 1493769600,
Expand Down Expand Up @@ -843,10 +843,10 @@ describe('Functions', () => {
report_number: 2,
is_incident_report: true,
title: 'Submisssion 1 title',
date_downloaded: '2020-10-30',
date_modified: '2021-07-27',
date_published: '2017-05-03',
date_submitted: '2020-10-30',
date_downloaded: new Date('2020-10-30'),
date_modified: new Date('2021-07-27'),
date_published: new Date('2017-05-03'),
date_submitted: new Date('2020-10-30'),
epoch_date_downloaded: 1604016000,
epoch_date_modified: 1686182943,
epoch_date_published: 1493769600,
Expand Down
1 change: 1 addition & 0 deletions site/gatsby-site/i18n/locales/es/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@
"csetChartDeveloped": "CSET ha desarrollado definiciones específicas para las frases subrayadas que pueden diferir de las definiciones de otras organizaciones. Como resultado, otras organizaciones pueden hacer diferentes evaluaciones sobre si un incidente de IA en particular es (o no) un daño de IA. Los detalles sobre las definiciones de CSET para el daño de la IA se pueden encontrar <1>aquí</1>.",
"csetChartMail": "Cada incidente es clasificado de forma independiente por dos anotadores CSET. Las anotaciones se revisan por pares y finalmente se seleccionan al azar para el control de calidad antes de la publicación. A pesar de este riguroso proceso, ocurren errores y se invita a los lectores a <1>informar</1> de cualquier error que puedan descubrir mientras navegan.",
"[Untitled Report]": "[Informe sin título]",
"YYYY-MM-DD": "AAAA-MM-DD",
"Incidents": "Incidentes",
"Incident and Issue Reports": "Incidentes e Informes de Problemas",
"Issue Reports": "Informes de Problemas",
Expand Down
1 change: 1 addition & 0 deletions site/gatsby-site/i18n/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@
"csetChartDeveloped": "Le CSET a développé des définitions spécifiques pour les phrases soulignées qui peuvent différer des définitions d'autres organisations. Par conséquent, d'autres organisations peuvent procéder à des évaluations différentes pour déterminer si un incident d'IA particulier est (ou n'est pas) un préjudice lié à l'IA. Des détails sur les définitions du CSET pour les dommages causés par l'IA peuvent être trouvés <1>ici</1>.",
"csetChartMail": "Chaque incident est classé indépendamment par deux annotateurs CSET. Les annotations sont examinées par des pairs et finalement sélectionnées au hasard pour un contrôle qualité avant publication. Malgré ce processus rigoureux, des erreurs se produisent et les lecteurs sont invités à <1>signaler</1> toute erreur qu'ils pourraient découvrir en naviguant.",
"[Untitled Report]": "[Rapport sans titre]",
"YYYY-MM-DD": "AAAA-MM-JJ",
"Incidents": "Incidents",
"Incident and Issue Reports": "Incidents et rapports de problèmes",
"Issue Reports": "Rapports de problèmes",
Expand Down
Loading

0 comments on commit c6063da

Please sign in to comment.