Hi abhishekpanwar ! I was about to write on the PR. I didn't understand your question on IRC
2020-03-02 06226, 2020
abhishekpanwar
Okay, so the question is, that you said to get the particular entity type and then get the model by using the util function getEntityModelByType right?
2020-03-02 06251, 2020
abhishekpanwar
For creating a revisionmodel and headermodel
2020-03-02 06226, 2020
abhishekpanwar
I basic question is how is that referring working here?
2020-03-02 06253, 2020
abhishekpanwar
how is RevisionModel is referring to a particular type like WorkRevision etc
2020-03-02 06225, 2020
abhishekpanwar
I open bookbrainz-data-js but couldn't find anything that would help.
2020-03-02 06229, 2020
abhishekpanwar
*opened
2020-03-02 06232, 2020
c1e0 has quit
2020-03-02 06243, 2020
Mr_Monkey
You can get the entity type from the EntityHeader or from an $entityRevision (AuthorRevision, WorkRevision,…) if you already have access to it, and that allows you to then use `getEntityModelByType` to get the correct model
2020-03-02 06226, 2020
Mr_Monkey
That's for example how it is used in `getEntityByBBID` as you mentionned (fetching the EntityHeader and getting the type from that)
2020-03-02 06247, 2020
somenath1435 joined the channel
2020-03-02 06217, 2020
abhishekpanwar
Yes So that shouldnt be the problem in the code I pushed? Yet the error occurs that you are also facing.
2020-03-02 06224, 2020
Mr_Monkey
In your case, when you do `await Promise.all(_.map(updatedEntities, (entityModel) =>` you should be able to get the correct entity type using `entityModel.get('type')`
2020-03-02 06228, 2020
abhishekpanwar
updatedEntities is an array of objects from getEntityByBBID function
2020-03-02 06205, 2020
abhishekpanwar
So I shouldn't have to do the manual work of getting type and then fetching the model. right?
2020-03-02 06240, 2020
abhishekpanwar
Since getEntityByBBID does the same work?
2020-03-02 06241, 2020
Mr_Monkey plunges back in the code
2020-03-02 06246, 2020
ruaok
zas: hetzener provisioned the server. incorrectly. even after talking to customer service twice. sigh.
2020-03-02 06259, 2020
alastairp
hi Mr_Monkey
2020-03-02 06251, 2020
D4RK-PH0ENiX has quit
2020-03-02 06253, 2020
Mr_Monkey
Hi alastairp
2020-03-02 06245, 2020
prabal has quit
2020-03-02 06248, 2020
prabal joined the channel
2020-03-02 06217, 2020
abhishekpanwar
Am I a bit clear Mr_Monkey?
2020-03-02 06210, 2020
CatQuest
reosarevok around?
2020-03-02 06213, 2020
Mr_Monkey
abhishekpanwar: Have a look at https://github.com/bookbrainz/bookbrainz-site/blo… , which does a similar thing to what you are trying to achieve. You should be able to reuse the existing functions and not have to deal with all those entity model complications :)
2020-03-02 06213, 2020
Mr_Monkey
What should happen in you code is:
2020-03-02 06213, 2020
Mr_Monkey
1. Get all entities related to the entity being deleted (you already do that)
2020-03-02 06213, 2020
Mr_Monkey
2. Modify the relationshipSets as you need (you do that already), and track that new relationshipset along with the associated entity ({entityBBID: newRelationshipSetId} object (as done by `getNextRelationshipSets` for example)). let's call this the newRelationshipSetMap
Mr_Monkey: :C if it's both your and mine prefrence. i'd like us to put in a n option before it's default pell-mell changed to a differnt behaviour, honestly.
2020-03-02 06247, 2020
Mr_Monkey
CatQuest: I also see the point of view that it differs from default browser behavior and we've both got an easy option to open in a new tab, but no easy option for the other way around.
2020-03-02 06246, 2020
Mr_Monkey
If it's the two of us vs. web standards, I think we don't weigh much.
2020-03-02 06235, 2020
Mr_Monkey
abhishekpanwar: Let me know If that's not clear, I can comment on the PR directly to be clearer
2020-03-02 06252, 2020
abhishekpanwar
Mr_Monkey: Yeah I will do it for sure. But could you please explain that referring of different types of entities by RevisionModel or could you please share some docs on it? That way in future If I work on this, I'd have a better grasp on it.
2020-03-02 06232, 2020
CatQuest
hmm that's a point. but I hope that option will be on the table soon
2020-03-02 06236, 2020
CatQuest
:)
2020-03-02 06248, 2020
CatQuest
dang were is reotab when you need him
2020-03-02 06204, 2020
CatQuest
he's camping up some montain photographing birbs or what
You'll see here that the entity table can give you the entity type for a given BBID. You need that if you want to directly affect the $entityRevision or $entityHeader, as there is a separate table for each entity type
Mr_Monkey: I didn't know about that google doc :P are other things also documented like this?
2020-03-02 06244, 2020
D4RK-PH0ENiX joined the channel
2020-03-02 06245, 2020
Mr_Monkey
No, just this work in progress
2020-03-02 06205, 2020
prabal
okayy
2020-03-02 06251, 2020
prabal
about that submit icon, I don't think 'check-double' and 'save' are ideal for submit
2020-03-02 06202, 2020
prabal
They can work
2020-03-02 06210, 2020
D4RK-PH0ENiX has quit
2020-03-02 06214, 2020
prabal
but
2020-03-02 06229, 2020
D4RK-PH0ENiX joined the channel
2020-03-02 06200, 2020
prabal
What do you say Mr_Monkey
2020-03-02 06244, 2020
Mr_Monkey
abhishekpanwar: I'm not sure if that answers your question or makes things clearer. With regards to your code, if for example I was deleting an Author with a relatuionship to a Work, the code was trying to create a new AuthorRevision for the Author, but also for the Work (instead of a WorkRevision), as RevisionModel and HeaderModel refer to the entity you're deleting (so AuthorRevision and AuthorHeader).
2020-03-02 06234, 2020
Mr_Monkey
prabal: I agree, I'm not 100% convinced. Do you want to see if you can find one more suitable? If not, let's not put any icon we're not convinced with.
2020-03-02 06249, 2020
abhishekpanwar
Okay Yes that is my question. If that is the case then how to I create a work_revision instead of author revision? If the answer is getting the model by type then isn't this the same as doing gettingEntityByBBID?
2020-03-02 06204, 2020
abhishekpanwar
In my code the I think the problem is only what you mentioned that I am creating the same revisionModel for all the different types of entities. I just need to know how can I create respective RevisionModels for each of the different type of Entity
2020-03-02 06251, 2020
prabal
abhishekpanwar what you're doing will solve this issue also right?
So the existing `saveEntitiesAndFinishRevision` method should be all you need.
2020-03-02 06256, 2020
abhishekpanwar
Okay
2020-03-02 06202, 2020
abhishekpanwar
Got it
2020-03-02 06215, 2020
Mr_Monkey
Sorry, forgot about that trigger for a second :)
2020-03-02 06248, 2020
Mr_Monkey
So what we're doing is doing an SQL UPDATE on all the modified entities, and the trigger does the rest for you.
2020-03-02 06233, 2020
abhishekpanwar
it handles creation of header and revision_models automatically right?
2020-03-02 06242, 2020
Mr_Monkey
Yes
2020-03-02 06207, 2020
abhishekpanwar
I just need to modify an entity and call the function `saveEntitiesAndFinishRevision`
2020-03-02 06212, 2020
abhishekpanwar
Alright
2020-03-02 06200, 2020
Mr_Monkey
In your case, it will do an update for the "deleted" entity (not deleting it fully, just setting dataId to null [no data = "deleted" entity) and updating the relationshipSetId for the related entities.
2020-03-02 06215, 2020
Mr_Monkey
All part of the same Revision
2020-03-02 06246, 2020
abhishekpanwar
Actually What I was trying to do in my solution was:
2020-03-02 06247, 2020
abhishekpanwar
1. Find all the affected entities (including the entity to be deleted).
2020-03-02 06247, 2020
abhishekpanwar
2. Now create a new Revision.
2020-03-02 06247, 2020
abhishekpanwar
3. Find all the affected entities.
2020-03-02 06247, 2020
abhishekpanwar
4. Set revisionParents
2020-03-02 06247, 2020
abhishekpanwar
5. Create the work_revision, author_revision etc for each of the affected entities.
2020-03-02 06249, 2020
abhishekpanwar
6. Create the work_header, author_header etc for each of the affected entities with masterRevision equal to the new revision.
2020-03-02 06254, 2020
abhishekpanwar
7. Deleted the entity.
2020-03-02 06234, 2020
abhishekpanwar
The process was right but 5 and 6 points were not working as I expected them to. As I didnt know about the triggers.
2020-03-02 06247, 2020
abhishekpanwar
I will implement the new solution now.
2020-03-02 06256, 2020
abhishekpanwar has quit
2020-03-02 06258, 2020
ZaphodBeeblebrox joined the channel
2020-03-02 06258, 2020
ZaphodBeeblebrox has quit
2020-03-02 06258, 2020
ZaphodBeeblebrox joined the channel
2020-03-02 06202, 2020
CatQuest has quit
2020-03-02 06213, 2020
ZaphodBeeblebrox
dumme CatQuest
2020-03-02 06247, 2020
c1e0 joined the channel
2020-03-02 06233, 2020
somenath1435 has quit
2020-03-02 06233, 2020
Pac23
ruaok shall i write it in a fork of it on a different branch or in a new repo ?
2020-03-02 06255, 2020
ruaok
branch in a clone of the main repo
2020-03-02 06222, 2020
anant joined the channel
2020-03-02 06225, 2020
Pac23
oh okay, you mean clone clone right not fork clone ?
(wanted to test how merging makes the rev-page look/work)
2020-03-02 06218, 2020
KrachbummNT joined the channel
2020-03-02 06240, 2020
ZaphodBeeblebrox
oic, it was tst not beta/prod
2020-03-02 06244, 2020
ZaphodBeeblebrox
test*
2020-03-02 06251, 2020
ZaphodBeeblebrox
feelsbadman
2020-03-02 06215, 2020
ZaphodBeeblebrox
anyway you should put it up on test first maybe. so that I dunno. can test :D
2020-03-02 06209, 2020
alastairp
ruaok: btw, I'm just deploying some stacks on docker swarm using portainer (web-based interface to swarm commands), and it's super magic and scary, but for the most part just works
2020-03-02 06211, 2020
alastairp
pretty neat
2020-03-02 06222, 2020
alastairp
not sure how you're managing the spark swarm?
2020-03-02 06255, 2020
ruaok
on the command line, with two scripts.
2020-03-02 06207, 2020
alastairp
(why do so many tech apps start with S? skype, slack, steam, spotify, safari, swarm, spark, siri)