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

Add bulk complete UI #2550

Merged
merged 10 commits into from
Feb 21, 2019
Merged

Conversation

christinach
Copy link
Member

@christinach christinach commented Feb 7, 2019

  • Bulk edit button displays on search results page when a collection facet
    is selected.
  • search params are passed around so we can retrieve the same results
    set
  • Bulk edit controller queues 1 update job per 50 resources

Closes #1860
Closes #2494
Closes #697
Other functionality moved to #2586

@christinach
Copy link
Member Author

closes #697

@christinach christinach added Review and removed Review labels Feb 7, 2019
@hackartisan hackartisan force-pushed the 697-bulk-edit-workflow-status-rights-statement branch 2 times, most recently from b26958a to 8930700 Compare February 12, 2019 18:23
@christinach christinach force-pushed the 697-bulk-edit-workflow-status-rights-statement branch from 8930700 to 0bed38d Compare February 12, 2019 19:34
@hackartisan hackartisan force-pushed the 697-bulk-edit-workflow-status-rights-statement branch from 0bed38d to 3d5637c Compare February 12, 2019 20:56
@hackartisan hackartisan changed the title [WIP] display collection bulk edit button when facet collection is selected Add bulk complete UI Feb 12, 2019
@hackartisan hackartisan force-pushed the 697-bulk-edit-workflow-status-rights-statement branch from 3d5637c to 0099255 Compare February 12, 2019 20:58
@hackartisan
Copy link
Member

screen shot 2019-02-12 at 3 55 01 pm

@hackartisan
Copy link
Member

screen shot 2019-02-12 at 4 00 17 pm

@hackartisan hackartisan force-pushed the 697-bulk-edit-workflow-status-rights-statement branch from 0099255 to 0a7ad72 Compare February 12, 2019 21:01
end

def resources_update
(_, document_list) = search_results(q: params["search_params"]["q"], f: params["search_params"]["f"])
Copy link
Member

Choose a reason for hiding this comment

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

Does this retrieve the whole set of results, or just the first page?

Copy link
Member

Choose a reason for hiding this comment

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

good question; we will look into this.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd recommend adding a FL key with "id" too if that works through BL.

Copy link
Member

Choose a reason for hiding this comment

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

can't seem to provide fl to the search builder.

logfile Outdated
@@ -0,0 +1,2 @@
2019-02-11 10:48:40.115 EST [76779] FATAL: lock file "postmaster.pid" already exists
2019-02-11 10:48:40.115 EST [76779] HINT: Is another postmaster (PID 501) running in data directory "/usr/local/var/postgres"?
Copy link
Member

Choose a reason for hiding this comment

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

Looks like a stray logfile got added by mistake.

Copy link
Member Author

Choose a reason for hiding this comment

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

probably that was mine

@hackartisan hackartisan force-pushed the 697-bulk-edit-workflow-status-rights-statement branch 2 times, most recently from 5adfe2b to 738469e Compare February 13, 2019 15:00
escowles
escowles previously approved these changes Feb 13, 2019
@christinach christinach force-pushed the 697-bulk-edit-workflow-status-rights-statement branch from c78c8c6 to 31299bf Compare February 13, 2019 18:13
@hackartisan hackartisan force-pushed the 697-bulk-edit-workflow-status-rights-statement branch 2 times, most recently from c22d211 to f352633 Compare February 13, 2019 19:41
@christinach
Copy link
Member Author

screen shot 2019-02-13 at 5 29 05 pm

christinach and others added 4 commits February 13, 2019 17:50
- Bulk edit button displays on search results page when a collection facet
is selected.
- search params are passed around so we can retrieve the same results
set
- Bulk edit controller queues 1 update job per 50 resources

refs #697
still to do to close that ticket:
- Add rights statement, rights note
- Add search summary box to top of edit form

Co-authored-by: christinach <actspatial@gmail.com>
Co-authored-by: Christina Chortaria <actspatial@gmail.com>
Co-authored-by: Anna Headley <anna.headley@gmail.com>
Wrap form in a panel

Co-authored-by: Christina Chortaria <actspatial@gmail.com>
@christinach christinach force-pushed the 697-bulk-edit-workflow-status-rights-statement branch from 668b682 to 9b3a5b6 Compare February 13, 2019 22:51
@escowles escowles mentioned this pull request Feb 15, 2019
3 tasks
@tpendragon tpendragon temporarily deployed to staging February 15, 2019 18:19 Inactive
@escowles
Copy link
Member

In manually testing this, I'm seeing some (but not all) of my objects get completed. For example, I bulk completed 76 objects in staging, and 22 were left pending. I created 150 pending objects in my local dev instance, and 65 were completed, and 85 were left pending.

I can try this again, but I think it might make sense to take a look at the search logic to see if objects being completed are changing the search results as we page through them.

@hackartisan
Copy link
Member

@escowles i would totally believe that is happening. because it queues the batch update job and then queries solr for the next page.

I think we can resolve this by creating all the jobs first, then queuing them. But I'm not sure how to write a regression test for a race condition like this.

@escowles
Copy link
Member

@HackMasterA Yes, I agree it would be very hard to test — I'd be fine with manually testing to make sure any updates behave as expected.

@hackartisan hackartisan force-pushed the 697-bulk-edit-workflow-status-rights-statement branch from 12f0e58 to 3c5d6aa Compare February 18, 2019 19:29
@hackartisan
Copy link
Member

@escowles I updated the way the jobs are queued. do you want to try it now?

@escowles
Copy link
Member

@HackMasterA Yep, I'll try it out now

@escowles
Copy link
Member

I'm still seeing only a portion of the records get updated. I've got my local environment setup to test this — do you want me to see if I can get it to complete them all?

@hackartisan
Copy link
Member

@escowles sure, thanks!

@hackartisan
Copy link
Member

@escowles are the resources more or less identical? or do they have different metadata, etc?

@escowles
Copy link
Member

I'm testing with identical resources (other than titles being "Resource #{n}". I think I've figured out why it's updating only the first page of resources (and have a fix).

@hackartisan
Copy link
Member

i will update the test / fix rubocop probably in the morning.

@escowles escowles force-pushed the 697-bulk-edit-workflow-status-rights-statement branch from ed16036 to 00d11ce Compare February 18, 2019 22:00
app/controllers/bulk_edit_controller.rb Show resolved Hide resolved
args = {}.tap do |hash|
hash[:mark_complete] = (params["mark_complete"] == "1")
end
batches = prepare_batches
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you just rename prepare_batches to batches and memoize?

Copy link
Member

Choose a reason for hiding this comment

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

👍

# frozen_string_literal: true
class BulkUpdateJob < ApplicationJob
def perform(ids:, args:)
return unless args[:mark_complete]
Copy link
Contributor

Choose a reason for hiding this comment

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

Why would this ever get queued without mark_complete? I mean, I guess it would right now, but wouldn't it be more efficient to just not queue a thing if it didn't need updated?

Copy link
Member

Choose a reason for hiding this comment

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

I think this was a sort of breadcrumb for the fact that we will add new options to the form as we go along. but it doesn't really make sense the way it is; I'll look at moving or removing it.

spec/features/bulk_edit_spec.rb Show resolved Hide resolved
@hackartisan
Copy link
Member

@tpendragon I answered some of these questions and made some changes. memoizing batches increased its ABC so I had to extract another method. take another look? let me know what you think.

attributes = {}.tap do |attrs|
attrs[:state] = "complete" if args[:mark_complete] && !resource.state.include?("complete")
end
change_set.validate(attributes)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we check the value of this so it doesn't update it if there's a validation error? Maybe even have it throw an exception so this batch dies?

Copy link
Member

Choose a reason for hiding this comment

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

yes!

Copy link
Member

Choose a reason for hiding this comment

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

@tpendragon I just added this please take a look. Thanks!

attrs[:state] = "complete" if args[:mark_complete] && !resource.state.include?("complete")
end
change_set.validate(attributes)
if change_set.changed?
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this is going to do what you want. Should be if change_set.validate(attributes) or if change_set.valid?.

change_set.changed? will just tell you if a property is different, which it really should be if it's being bulk updated.

I'm actually a little concerned the tests below pass in light of this.

Copy link
Contributor

Choose a reason for hiding this comment

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

OH, I see what's going on. Ignore me.

@tpendragon tpendragon merged commit 2b8c4a8 into master Feb 21, 2019
@tpendragon tpendragon deleted the 697-bulk-edit-workflow-status-rights-statement branch February 21, 2019 18:47
@tpendragon tpendragon removed the Review label Feb 21, 2019
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

4 participants