Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:Unipisa/dm-manager into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
paolini committed Oct 15, 2024
2 parents 6a56e80 + 4e73365 commit 840a457
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
34 changes: 32 additions & 2 deletions server/controllers/processes/sanityCheck.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ router.get('/', async (req, res) => {
count: { $gt: 1 }
}
}
])
])

// find duplicated emails and alternativeEmails
const duplicatedEmails = await Person.aggregate([
Expand Down Expand Up @@ -98,6 +98,34 @@ router.get('/', async (req, res) => {
}
])

// find persons with trailing spaces
const personsWithTrailingSpaces = await Person.aggregate([
{
$match: {
$or: [
{ firstName: { $regex: /\s+$/, $options: "s" } },
{ lastName: { $regex: /\s+$/, $options: "s" } },
{ email: { $regex: /\s+$/, $options: "s" } },
{ alternativeEmails: { $regex: /\s+$/, $options: "s" } }
]
}
}
]);

// find institutions with trailing spaces
const institutionsWithTrailingSpaces = await Institution.aggregate([
{
$match: {
$or: [
{ name: { $regex: /\s+$/, $options: "s" } },
{ country: { $regex: /\s+$/, $options: "s" } },
{ city: { $regex: /\s+$/, $options: "s" } },
{ code: { $regex: /\s+$/, $options: "s" } }
]
}
}
]);

// find duplicated institutions
const duplicatedInstitutions = await Institution.aggregate([
{ $project: {
Expand All @@ -120,6 +148,7 @@ router.get('/', async (req, res) => {
}
]);

// find duplicated seminars
const duplicatedSeminars = await Seminar.aggregate([
{
$facet: {
Expand Down Expand Up @@ -192,6 +221,7 @@ router.get('/', async (req, res) => {
}
])

// find duplicated events
const duplicatedEvents = await Event.aggregate([
{
$facet: {
Expand Down Expand Up @@ -269,7 +299,7 @@ router.get('/', async (req, res) => {
}
])

return res.json({duplicatedNames, duplicatedEmails, missingMatricola, missingSSD, missingInstitutionCountry, duplicatedInstitutions, duplicatedSeminars, duplicatedEvents})
return res.json({duplicatedNames, personsWithTrailingSpaces, institutionsWithTrailingSpaces, duplicatedEmails, missingMatricola, missingSSD, missingInstitutionCountry, duplicatedInstitutions, duplicatedSeminars, duplicatedEvents})
})

module.exports = router
10 changes: 10 additions & 0 deletions src/processes/SanityCheck.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@ export default function SanityCheck() {
</td>
)}
/>
<CheckCard
title="Person with trailing spaces"
data={data.personsWithTrailingSpaces}
renderRow={(item, i) => RenderCheckSingleItem(item, i, '/person')}
/>
<CheckCard
title="Institution with trailing spaces"
data={data.institutionsWithTrailingSpaces}
renderRow={(item, i) => RenderCheckSingleItem(item, i, '/institution')}
/>
</>
);
}

0 comments on commit 840a457

Please sign in to comment.