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

trashed (orphaned) items batch processing #154

Open
mquantin opened this issue Jun 17, 2024 · 6 comments
Open

trashed (orphaned) items batch processing #154

mquantin opened this issue Jun 17, 2024 · 6 comments

Comments

@mquantin
Copy link
Contributor

mquantin commented Jun 17, 2024

using teams 4.0.1

I ran a script and generated 1000 orphaned items (in an item set)

Question 1
Is there a way to create an item in a team via the API ?

If not (my case),
I try to move these items to the team "manually" (through the admin GUI)
Issue 1
In the trash, the batch action for orphaned items doesn't run anything. Nothing append, no log. nothing. Just the page is reloaded. Even with only 1 item (or few) is selected to be processed.

Issue 2
The other option would be to move/link the content of the item-set (with my orphaned items) to the target team. But I get error 500.

Processing them one by one is working well,
but this is not an option.

Any idea?

@alexdryden
Copy link
Contributor

I've recently run into the same 500 error when adding 500+ items to a team via item-set option on one of our systems. I wasn't able to reproduce it in the development environment, so I don't have a fix yet. My plan is to replace that interface with some better mass add options.

In the meantime, I'll implement the create endpoint for the API. Should be available some time in the next day or so.

@mquantin
Copy link
Contributor Author

Thank you Alex for the quick reply.
I need a quick (and maybe dirty) fix.
For now the items are trapped into the trash. And people need them Friday morning...

As a very bad and last solution I was investigating the possibility to directly create a SQL request...

I'll try tomorrow to split my orphaned items into small item sets to process them. If you have any other idea/tips, please tell me 😉

@alexdryden
Copy link
Contributor

I can probably push out the create api today, but I won't finish the batch create till tomorrow. I need to look at how the batching should be done (I suspect this is why large item sets are failing, no memory management for that process).

For the create, you'll just need to send a post request to /api/team-resource with global admin credentials. Then, for the payload, it expects a JSON with "team" as one key and team id as its value, and "resource" as another key and the resource id as the value.

@alexdryden
Copy link
Contributor

alexdryden commented Jun 17, 2024

I've only tested this with a single example (and haven't tested all of the cases where if should produce permission denied), but if you are in a time crunch you should be able to temporarily checkout the api-create-team-reasource branch and set up a script to make api calls for each of the team resources you need to create. Otherwise, I might have the batch create api feature ready by the end of the day in your time zone tomorrow.

Also, if your script uses the REST api to create items, you can pass team information with the other item data to add it to a team at the time of creation (this is already possible on the main branch). Just pass the key "team" or "add_team" with an array of team ids for the value. So, an example would look like:

{
   "dcterms:title":[
      {
         "property_id":1,
         "type":"literal",
         "is_public":"1",
         "@annotation":null,
         "@language":"",
         "@value":"test tittle"
      }
   ],
   "dcterms:description":[
      {
         "property_id":4,
         "type":"literal",
         "is_public":"1",
         "@annotation":null,
         "@language":"",
         "@value":"test description"
      }
   ],
   "team":[
      3
   ]
}

@mquantin
Copy link
Contributor Author

good ! thank you for that branch !
After tying to use a PUT request to update the team info (not working)
I deleted all the orphaned items
and I ran the script again to create items inside a team (it's working!)

It's not the perfect solution as I had to bypass some checks (e.g. compliance toward a template) to have it working.
Anyway, it saved the workshop scheduled on friday! thank you!

@alexdryden
Copy link
Contributor

It needs to be a POST request, not PUT. It is POST because you are creating new "team resource" entities via the /team-resource endpoint, not editing a team. Glad the other route worked out for you!

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

No branches or pull requests

2 participants