-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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 database entries for new gists, update REPL URLs #2680
Conversation
@@ -6,7 +6,7 @@ exports.up = DB => { | |||
name character varying(255), | |||
username character varying(255) not null, | |||
avatar text, | |||
github_token character varying(255) not null, | |||
github_token character varying(255), |
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 should be the only change to the production DB required
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.
Will do
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.
Done
Alright, this is ready if anyone wants to take a look at it. The only other thing I thought about adding is a |
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 haven't run this locally, but have you tested logging in for the first time, despite a users
row already existing for you via the Gist->Owner call?
I'm 90% sure the on conflict
still works for us in that case, but it did pop into my mind while reading.
I did, yeah — it seems to work correctly |
let k, cols=[], vals=[]; | ||
for (k in obj) { | ||
cols.push(k); | ||
vals.push(k === 'files' ? JSON.stringify(obj[k]) : obj[k]); |
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.
Did I write this? Can't tell if this file was moved or is new.
Looking at it, the JSON.stringify
shouldn't be necessary... I 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.
I added the JSON.stringify
, it was erroring without it. I think it'll accept objects but not arrays (I changed the structure to files: [...]
instead of files: {...}
since we're no longer bound to the gist format, to reduce faffing
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.
Ah, then okay. Arrays need explicit casting. We could also do { files }
so that the input/output is automatic. Just have to remember to row.files.files
, which may be too annoying.
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.
yeah, i wondered about that. i reckon explicit casting is ok, since we probably won't need to add it in more places, and since we'll get a loud error if we do
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 happy either way
This builds on #2572:
/repl?gist=xyz123
URLs with/repl/xyz123
/repl?example=hello-world
URLs with/repl/hello-world
/repl
to/repl/hello-world
/gist/create
to/repl/create.json
and/gist/xyz123
to/repl/xyz123.json
gists
table of the databaseTurns the fork icon into a link tochanged my mind about this. Instead, it inserts a history entry, so that the back button takes you to the parent/repl/xyz123/fork
(which would update the database and redirect the user to/repl/abc234
)relaxed
logic