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

Migration to remove void resources #1200

Merged
merged 1 commit into from Oct 6, 2017

Conversation

abulte
Copy link
Contributor

@abulte abulte commented Oct 5, 2017

Remove resources without title or url from the DB. On data.gouv.fr, this matches:

ObjectId("53698e19a3a729239d203399") Fonds stratégique pour le développement de la presse (FSDP) - Aides attribuées
ObjectId("583e801488ee387693c65bb3") SYME05 - Bornes de recharge pour véhicule électrique

@abulte abulte requested a review from a team October 5, 2017 15:16
Copy link
Contributor

@noirbizarre noirbizarre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it can be optimized with a single pass on a reduced queryset.

var nbRemoved = 0;

const removedNoTitle = db.dataset.update(
{resources: {$gt: []}},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can reduce the number of documents to lookup with {resources.title: null}.
If you want to perform it in a single pass:

{$or: [{'resources.title': null}, {'resources.url': null}]},
{$pull: {resources: {$or: [{title: null}, {url: null}]}}},

@abulte abulte merged commit 9034872 into opendatateam:master Oct 6, 2017
@abulte abulte deleted the purge-void-resources branch October 6, 2017 09:36
@abulte abulte removed the in progress label Oct 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants