-
-
Notifications
You must be signed in to change notification settings - Fork 229
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
🎉 Tag Graph #3695
🎉 Tag Graph #3695
Conversation
Quick links (staging server):
Login:
SVG tester:Number of differences (default views): 4530 (e117a3) ❌ Edited: 2024-06-17 19:57:36 UTC |
db/db.ts
Outdated
} | ||
|
||
await knex("tag_graph").delete() | ||
await knex("tag_graph").insert(tagGraphRows) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an easy way to do the update but then the updatedAt timestamp will not be useful information. I think being able to know which tags have been updated might be worth the slight complication to do a select all and then do the add/update/delete operations accordingly. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tag graph doesn't have updatedAt
- do you think it should?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it can be really useful - e.g. when something goes wrong and you want to undo some change from yesterday or so it's really nice if that query can identify the three rows that actually changed instead of having to fetch all from a backup.
That said I'm not sure about whether it's worth changing this PR for it.
CREATE TABLE tag_graph ( | ||
parentId INT NOT NULL, | ||
childId INT NOT NULL, | ||
weight INT NOT NULL DEFAULT 1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we maybe init this to 100 and sort it so that "heavier" items "sink down"? This makes it easier to modify individual elements up or down without quickly running into negative numbers which seem a bit weird. Totally minor thing of course and feel free to ignore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hemmed and hawed on what the metaphor for "weight" should be - density, or weight-as-in-importance.
Ultimately I went with importance because pressing the up arrow should move the object up, and things at the top should be the most important.
I'll increase the default if for no reason other than reducing the risk of shenanigans with the number 0 😁
|
||
// create root tag | ||
await queryRunner.query(`-- sql | ||
INSERT INTO tags (name) VALUES ("tag-graph-root")`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This leads to tag-graph-root being a valid tag in various selection dropdowns. Probably not a big deal since our users are not out to sabotage our system but maybe nice to eventually filter it out
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice work! I had a few comments/questions but nothing major.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks for the tweaks! I'm a bit on the fence about the updatedAt field - I'll leave it to you to decide if you want to change it :)
Changes
tag_graph
table in the DBtags
table@dnd-kit/core
library to our admin/tag-graph
to quickly and conveniently structure the tag graph/tags
admin UI to be a flat list of all tags and a simple form to add a new tagThis PR doesn't introduce any breaking changes or migrations to existing interactions with our tags table. Only once we've merged this and the data and research team has created a tag graph they're happy with, we can migrate functionality over to use the graph.
Demo
tag.graph.demo.mov