faustinoaq changed the topic of #amber to: Welcome to Amber Framework community! | https://amberframework.org | Developer happiness, productivity and bare metal performance | GH: https://github.com/amberframework | Docs: https://docs.amberframework.org | Gitter: https://gitter.im/amberframework/amber | IRC Logger: https://irclog.whitequark.org/amber | Amber::Server.start
vivus has joined #amber
<FromGitter> <pynixwang> why crystal so slow in this benchmark.
<FromGitter> <Blacksmoke16> i mean its not that slow
<FromGitter> <Blacksmoke16> 28ms avg is still really good
<FromGitter> <pynixwang> should be 28us
<FromGitter> <Blacksmoke16> ok
vivus has quit [Remote host closed the connection]
<FromGitter> <nsuchy> @pynixwang Are you working on the nuclear grid? I doubt 28ms response is harming anything
<FromGitter> <nsuchy> that's faster than what most enterprise applications give you
<pracabor> it's also approaching the network latency of just connecting to most websites
<FromGitter> <Blacksmoke16> there is a big difference between a framework built for just speed and one that is actually useful
<FromGitter> <Blacksmoke16> if you can sacrifice some speed for ease of development, its something id rather do
<FromGitter> <Blacksmoke16> the avg person using your app isnt going to notice the difference between 50 and 100 ms, benchmarks will sure, but thats hardly real world
<FromGitter> <nsuchy> Any theories on why this might be happening?
<FromGitter> <nsuchy> ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5cdaf6de252dbb751557a647]
<FromGitter> <nsuchy> worth adding here
<FromGitter> <nsuchy> Even works fine on localhost
<FromGitter> <nsuchy> only happens on production
<FromGitter> <Blacksmoke16> slave lag?
<FromGitter> <nsuchy> no
<FromGitter> <nsuchy> there is no slave
<FromGitter> <nsuchy> just a single postgres server
<FromGitter> <nsuchy> even runs in development mode
<FromGitter> <nsuchy> on production
<FromGitter> <nsuchy> its the exact same as my laptop
<FromGitter> <nsuchy> other than linux
<FromGitter> <nsuchy> instead of mac
<FromGitter> <Blacksmoke16> hm
<FromGitter> <nsuchy> How does `ModelName.create` determine which ID to use?
<FromGitter> <nsuchy> for the primary key
<FromGitter> <nsuchy> my create function doesn't set an id manually so it has to default to something
<FromGitter> <Blacksmoke16> sec
<FromGitter> <nsuchy> postgres itself has `not null default nextval('versions_id_seq'::regclass)` set as default value for id
<pracabor> the create lets the database pick
<FromGitter> <nsuchy> pracabor: So then the thing I just sent above should be correct
<FromGitter> <nsuchy> inwhich case granite shouldn't have duplicate key errors
<FromGitter> <nsuchy> :|
<pracabor> granite isn't the one throwing the error, or enforcing it
<pracabor> postgres is
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5cdafa01f52a2375162fd6b2]
<FromGitter> <Blacksmoke16> its possible you're passing it an `id` field in the args
<FromGitter> <Blacksmoke16> which would set the pk to that, which would fail when trying to insert since it already exists
<FromGitter> <nsuchy> where would args be set at
<FromGitter> <nsuchy> ```code paste, see link```
<FromGitter> <nsuchy> This is the exact method I'm calling
<pracabor> I don't see any obvious way that what you're doing is wrong
<FromGitter> <nsuchy> And more recently I replaced `params[:id]` with ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ with the `hack_id` thing I created [https://gitter.im/amberframework/amber?at=5cdafaa379d70050996ea84d]
<FromGitter> <nsuchy> to make sure it can't get confused with params[:id]
<FromGitter> <nsuchy> so im lost
<pracabor> I mean that line is way too long for sanity but that's irrelevant
<FromGitter> <nsuchy> haha
<FromGitter> <nsuchy> yes
<FromGitter> <nsuchy> there's a lot of data
<FromGitter> <nsuchy> :P
<FromGitter> <nsuchy> Full source: https://gitlab.lunorian.is/nsuchy/sm64hacksdb/
<FromGitter> <nsuchy> if you want to check for things I haven't directly mentioned
<pracabor> @nsuchy perhaps something is wrong with your postgresql sequence -- is there data in the table that predates the sequence?
<FromGitter> <nsuchy> Possibly
<FromGitter> <nsuchy> I imported the old database from ruby with import code on my laptop
<pracabor> do a select max(id) on the column
<FromGitter> <nsuchy> and copied over into the database on production
<pracabor> and then update nextval for the sequence
<pracabor> oh your psql dump might not have included the sequence
<FromGitter> <nsuchy> maybe
<pracabor> I've run into that for sure
<FromGitter> <nsuchy> How do I rewrite that query
<FromGitter> <nsuchy> for both the hacks table and versions table
<FromGitter> <nsuchy> i don't understand sql aside from the basic select update delete stuff :P
<pracabor> select max(id) from <table>;
<FromGitter> <nsuchy> ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5cdafbe779d70050996eb4cc]
<pracabor> then you can ask for the nextval from the sequence and see if it'll overlap: `select nextval(<sequence name>)`
<pracabor> if it's wrong, you can do `alter sequence <sequence name> lastvalue <whatever>`
<FromGitter> <nsuchy> ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5cdafc5e0824230a7734b723]
<FromGitter> <nsuchy> looks like that was the issue
<FromGitter> <nsuchy> 😂
<pracabor> \o/
<FromGitter> <nsuchy> having trouble updating the sequence though
<FromGitter> <nsuchy> ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5cdafd1bf52a2375162ff1d9]
<pracabor> I just pulled that from my head, do a search on stackoverflow for some better syntax
<FromGitter> <nsuchy> nvm
<FromGitter> <nsuchy> got it working
<FromGitter> <nsuchy> from postgres docs
<FromGitter> <nsuchy> thanks for your help
<FromGitter> <nsuchy> :)
<FromGitter> <nsuchy> everything is working
<FromGitter> <nsuchy> my friend's mario database can add hacks again
<FromGitter> <nsuchy> :D
<pracabor> \o/
<FromGitter> <nsuchy> pretty sure that I can safely say we're the only mario database in the world written in Crystal/Amber
<FromGitter> <nsuchy> before that it was ruby on rails but I heard about crystal and how the compiler reduced the amount of runtime errors and I gave it a shot
<FromGitter> <nsuchy> this is awesome but postgres is confusing
<FromGitter> <nsuchy> :P
<FromGitter> <nsuchy> @Blacksmoke16 This might be up your ally https://github.com/amberframework/granite/issues/333
<FromGitter> <Blacksmoke16> but its not really related to granite
<FromGitter> <Blacksmoke16> you would have to query the underlying database using the queries you did every time a record is saved
<FromGitter> <nsuchy> How about only do that query in the event it fails to save
<FromGitter> <damianham> @nsuchy these are the kind of things you have to take care of when migrating databases
<FromGitter> <Blacksmoke16> its not really granite's responsibility to make sure the underlying database was setup properly
<FromGitter> <damianham> it would be completely wrong for a web framework to take care of database migration issues
<FromGitter> <Blacksmoke16> ^
<FromGitter> <Blacksmoke16> it would be different if granite *did* the migration
<FromGitter> <Blacksmoke16> then this would be a bug of not copying the sequence over, but since that happened outside of it, its not something i think we should worry about
<FromGitter> <damianham> nope
<FromGitter> <nsuchy> Hmm okay
<FromGitter> <nsuchy> Well it’s fixed now so it’s unlikely to be an issue again
<FromGitter> <Blacksmoke16> exactly
<FromGitter> <nsuchy> By chance is there a Markdown to HTML parser in Crystal?
<FromGitter> <nsuchy> Or would I need to write my own?
<FromGitter> <nsuchy> Adding discussion-board-like functionality to my app and if something already exists it'd save me some time
<FromGitter> <Blacksmoke16> https://github.com/icyleaf/markd
<FromGitter> <nsuchy> thanks
<FromGitter> <nsuchy> `Markd 305.36 ( 3.27ms) (± 5.52%) 10.73× slower` ⏎ ⏎ Lol 3ms is far from slow
<FromGitter> <nsuchy> :joy'