readme-jokes icon indicating copy to clipboard operation
readme-jokes copied to clipboard

⚠ Adding jokes to the API should be easier

Open ABSphreak opened this issue 4 years ago • 13 comments

Adding jokes to the jokes.json API should be easier,

right now, if people are adding jokes to the same joke-index concurrently,

only one PR can be merged, the rest would show a merge conflict,

which is tedious.

ABSphreak avatar Oct 08 '20 05:10 ABSphreak

That's bound to happen as eventually everyone is adding the new joke at the end(i.e. same line) which produces a conflict. Well I would want to work on this. would request you to assign.

damn-dvlpr avatar Oct 08 '20 05:10 damn-dvlpr

@damn-dvlpr sure go ahead.

ABSphreak avatar Oct 08 '20 06:10 ABSphreak

I'll open a PR real soon, meanwhile I would want you to go through this discussion here: https://github.com/tinganho/l10ns/issues/133 to get a deeper dive so that we can discuss it further. Right now I am trying to implement git-json-merge: https://www.npmjs.com/package/git-json-merge Let's just hope it does the trick!

damn-dvlpr avatar Oct 08 '20 07:10 damn-dvlpr

@damn-dvlpr hey, I will look into this discussion asap. You can reach out to me on Discord if you want to discuss → ABSphreak#1420

ABSphreak avatar Oct 08 '20 07:10 ABSphreak

Having been trying to implement the npm module from the past 2 days, yet haven't been able to find a viable solution. Do you think this module won't suffice in our case? https://www.npmjs.com/package/git-json-merge

damn-dvlpr avatar Oct 10 '20 17:10 damn-dvlpr

It might work, but how do we configure that to auto-resolve the issues in our case? Our conflicts are happening because of Joke indexing being redundant on different PRs, how would this be helpful in our case?

Have you tried it on your Fork?

ABSphreak avatar Oct 10 '20 17:10 ABSphreak

I was trying it out on a test repo I created, i can't figure out with whom this script is interacting with, whether it resolved on the local clone, or alters the working of git merger driver. the documentation seems missing to me hence all the trouble.

damn-dvlpr avatar Oct 11 '20 06:10 damn-dvlpr

Exactly my point. Try to think of some other solution if you can.

ABSphreak avatar Oct 11 '20 08:10 ABSphreak

Why are you guys using ArrayLike Objects? just use plain arrays less merge conflicts and easier to use and add more jokes

Don't use ArrayLike Objects. ->

{
	"0": {
		"q": "Relationship status?",
		"a": "I'll leave the relations to the database.",
		"form": "qa"
	},
	"1": {
		"q": "How do you get the code for the bank vault?",
		"a": "You checkout their branch.",
		"form": "qa"
	},
}

Use Arrays ->

[
	{
		"q": "Relationship status?",
		"a": "I'll leave the relations to the database.",
		"form": "qa"
	},
	{
		"q": "How do you get the code for the bank vault?",
		"a": "You checkout their branch.",
		"form": "qa"
	},
]

anuraghazra avatar Nov 09 '20 12:11 anuraghazra

@anuraghazra at first I just randomly picked the joke from ArrayLike Objects, would change the whole thing to Arrays, then I'd have to change it from a JSON to JS file I think.

Thanks for the tip man!

ABSphreak avatar Nov 09 '20 12:11 ABSphreak

Yup you can just use array.from method to convert the whole thing automatically. and create the JS or JSON file which ever you prefer

image

anuraghazra avatar Nov 09 '20 13:11 anuraghazra

Cool! Updating soon.

ABSphreak avatar Nov 09 '20 13:11 ABSphreak

@ABSphreak Still no update?

ivan-developer-01 avatar Oct 07 '23 11:10 ivan-developer-01