fix for fp importer seems to complain if plot already exists #47 #48
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix for issue #47. The problem is triggered in the row_importer class by this line of code object.can_overwrite(@batch_id, @overwrite_batch_id) when we call attempt_to_overwrite!(object) method, Instead of using object.batch_id, it is using batch_id which results in an attempt to create a new plot in the database using the records of a plot that already exists. That in turn causes the reported error: No permission to override Plot a different batch
The way the code is currently designed, it will always create a new batch in the database each time an upload is submitted irrespective of whether it is a new upload or simply an update which was the case with Allie. I didn't want to change that, so I added a new boolean column named duplicate to the batches table. This will allow us to easily delete duplicate batch record that was created during update but are redundant. In order to fix the reported issue, I had to reuse existing batch whenever an import is an update as Allie was doing, So the boolean duplicate column allows us to set any new batch record* created during an up date to true and later we can just delete all batch record where the duplicate value is equal to true.