Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 11:17
    theHellDog commented #422
  • Nov 24 02:30

    drujensen on dj-upgrade-micrate

    (compare)

  • Nov 24 02:29

    drujensen on master

    Upgrade to latest micrate (#124… (compare)

  • Nov 24 02:29
    drujensen closed #1241
  • Nov 22 22:22
  • Nov 22 11:24
  • Nov 22 04:02
    drujensen synchronize #1241
  • Nov 22 04:02

    drujensen on dj-upgrade-micrate

    upgrade node (compare)

  • Nov 22 03:48
    drujensen synchronize #1241
  • Nov 22 03:48

    drujensen on dj-upgrade-micrate

    upgrade docker version (compare)

  • Nov 21 17:28
    drujensen opened #1241
  • Nov 21 17:27

    drujensen on dj-upgrade-micrate

    Upgrade to latest micrate This… (compare)

  • Nov 17 15:42

    drujensen on master

    Unify AbstractStore#update API … (compare)

  • Nov 17 15:42
    drujensen closed #1240
  • Nov 17 15:42
    drujensen closed #1239
  • Nov 17 14:46
    bcardiff opened #1240
  • Nov 16 00:54
  • Nov 14 22:48
    drujensen commented #1239
  • Nov 13 20:02
    bcardiff opened #1239
  • Nov 13 15:48
    bcardiff opened #434
George Dietrich
@Blacksmoke16
if you could share your model/code that would be helpful as well
Oleksii Morozov
@jaysneg
require "uuid"

class Ip < Granite::Base
  connection pg
  table ips

  column id : Int64, primary: true
  column value : String, converter: PgInet
  column uuid : String? = UUID.random.to_s

  column first_seen : Time
  column last_seen : Time

  timestamps
end
George Dietrich
@Blacksmoke16
and how are you selecting the records?
Oleksii Morozov
@jaysneg
  Ip.find_each("WHERE uuid IS NULL") do |ip|
      ip.uuid = UUID.random.to_s
      ip.save
  end
Oleksii Morozov
@jaysneg

@jaysneg make your model a view - when I am querying the database with joins I always create view models for that purpose. e.g.

thanks

George Dietrich
@Blacksmoke16
yea i dunno, i somehow doubt its a bug tho
Jonas Ohlsson Aden
@pocketjoso

Hello everyone!
I'm seeing timeouts for requests to our crystal server, using the Amber framework, after around 120s.

Is there any configuration for this in Amber, or even crystal itself, that can be increased? I know, it's not the most common use case... but I have this need currently.

Thanks!

What actually seems to happen, for some reason, is that the relevant Controller (extended from Amber::Controller::Base) seems to restart, processing the same request again, but never actually responding.. For certain long running request handlers I've also seen some ERR_EMPTY_RESPONSE errors returned.
George Dietrich
@Blacksmoke16
what's the controller action doing that it takes this long? prob not a great practice regardless
Jonas Ohlsson Aden
@pocketjoso
yeah I know... it's crunching some numbers, outside of crystal even.
I don't have the option of changing that currently, unfortunately.
George Dietrich
@Blacksmoke16
fair enough
Jonas Ohlsson Aden
@pocketjoso

my plan is to change this setup in the mid-term to avoid these very long requests.

I was just hoping for a quicker fix for the timeout issues. :) Is there any timeout handling for the Controllers (or underlying crystal code) currently, that you know of?

Or should I give up on that idea? I totally agree it's an edge case, but the behavior I am seeing still seems like a bug (that the Controller "restarts" after 120s).

George Dietrich
@Blacksmoke16
:shrug: will have to wait for someone more familiar with the implementation. \cc @drujensen
Jonas Ohlsson Aden
@pocketjoso
hehe okay thanks anyway
Oleksii Morozov
@jaysneg

yea i dunno, i somehow doubt its a bug tho

the same issue appears with created_at and updated_at
I'm thy add convertor but model not even call it

George Dietrich
@Blacksmoke16
If you can reproduce it, create an issue with the code and I can check it out
Damian Hamill
@damianham
@andrewc910 @eliasjpr I think support to differentiate routes by domain name within Amber might be a useful enhancement to the framework. How about having a host section in routes.cr that encapsulates piplines, e.g.
Amber::Server.configure do
  host "myhost.mydomain.com" do
    pipeline :sub1 do
      # normal pipeline plugs.....
    end
    routes :sub1 do
      get "/", SubdomainController, :index # matches "myhost.mydomain.com" only
    end
  end
  pipeline :web do
    # normal pipeline plugs
  end
  routes :web do
    get "/", HomeController, :index  # matches any host
  end
end
Oleksii Morozov
@jaysneg_gitlab

If you can reproduce it, create an issue with the code and I can check it out

this issue appears when i add column column uuid : String? = UUID.random.to_s

I think the issue in default value UUID.random.to_s

To reproduce
create new Amber project and any table ips
with timestamps and uuid String

and add to model column uuid : String? = UUID.random.to_s

create record and read it

George Dietrich
@Blacksmoke16
@jaysneg_gitlab works fine for me
require "uuid"

class Test < Granite::Base
  connection my_blog
  table "test"

  column id : Int64, primary: true
  column uuid : String? = UUID.random.to_s
  timestamps
end

Test.new.save

pp Test.first # =>
# #<Test:0x7f4576fedf80
#  @_current_callback=nil,
#  @created_at=2020-11-05 00:17:21.0 UTC,
#  @destroyed=false,
#  @errors=[],
#  @id=1,
#  @new_record=false,
#  @updated_at=2020-11-05 00:17:21.0 UTC,
#  @uuid="a84ae3c4-41f7-4dc5-848f-d463897db817">
CREATE table "test"
(
    id         BIGSERIAL PRIMARY KEY,
    uuid       TEXT NOT NULL,
    created_at timestamptz,
    updated_at timestamptz
)
Ibraheem Ahmed
@ibraheemdev

I was looking at the amber macro for routes and saw this line:

controller = {{controller.id}}.new(context)

What is the controller.id? Is this reflection?

Why can't you just do {{controller}}.new(context)?
Dru Jensen
@drujensen
I use id so you can pass in a string or symbol into the macro and it handles the conversion.
Ibraheem Ahmed
@ibraheemdev
Oh, ok, that makes sense
JonMallozzi
@JonMallozzi
Hello, I am brand new to the Amber framework, and I am struggling to find the answer in the docs, but is there a way to change a form input to be date. I have a date of birth field for my User table that I would like to submit to make a user. I have tried == text_field(type: Time, name: "date_of_birth", value: user.date_of_birth, placeholder: "Date_of_birth", class: "form-control" to try making the input a date but that did not work and is giving me the error self[k] = v Error: no overload matches 'Hash...
Any suggestions on how to add this input type?
George Dietrich
@Blacksmoke16
whats the full error?
JonMallozzi
@JonMallozzi
image.png
here is the full error
if a picture is not a good format I can type it out
George Dietrich
@Blacksmoke16
got the trace too?
JonMallozzi
@JonMallozzi
on amber watch what is the flag for showing the stack trace. above the error, it says use --error-trace but amber watch --error-trace does not run
George Dietrich
@Blacksmoke16
:shrug:
JonMallozzi
@JonMallozzi
yeah I am not finding much information on getting a stack trace so I am not sure how to provided that
George Dietrich
@Blacksmoke16
np, we can defer to someone who is more familiar with it :p
Dru Jensen
@drujensen
The types don’t match. Your union with Time.class looks suspicious.
JonMallozzi
@JonMallozzi
I could not find the answer so I kinda just guessed but what exactly do I need to put as my type: for a html date input?
Dru Jensen
@drujensen
That is the html type. You can use “time” if you want. When it gets submitted, you may need to convert it from a string to a time so you can set it in the model.
Jared Smith
@jrods
I had this problem too with Time as a column type, from what i understood from the Model, the macros don't consider time at all. So i ended up including an overloading function just for time with convert_type
module Granite::Type
  extend self

  def convert_type(value : String, t : Time?.class) : Time?
    Time.parse_local value, "%F"
  end
end
Andrew
@andrewc910
@damianham I would love amber to support some type of subdomains/hosts.
I personally would prefer a subdomain macro as I imagine pipes would overlap but I'll take what I can get. I'm not too keen on opening a PR since that issue has been raised and the core devs supported a pipe approach over expanding the router.
I enjoy how rails does it but its the only major backend framework I have used so my perspective can be limited.
Damian Hamill
@damianham
@andrewc910 while I agree that a pipe based approach would allow you to set a request variable which you could then use to handle the request based on the subdomain - I imagine it would involve delegation from a primary controller to a delegate controller and that decision logic may have to be added to every method in the primary controller. I don't think that is the optimal way to handle subdomains. It might not be the favoured option of the core team but an extension to the router is the "correct" way to handle subdomains IMHO. Why not do a PR anyway and see if it gains favour.
Elias Perez
@eliasjpr
@andrewc910 @damianham I would like to see how subdomain works with Rails, and to better understand the use cases. I would not mind to reopen the subdomain issue and do a RFC write up to start a conversation we can compare the extension approach with the built in approach.
Sam Holst
@samholst
how do you pass local variables to a slang partial? I can't find documentation on how that would be implemented. If I have a partial that I would to include many times in a view but pass different information to it dynamically within the same view? In Rails it would be = render partial: '_some_partial', locals: { "some" => "data" }. I could then reuse this in the same view many times with different information.
1 reply
Elias Perez
@eliasjpr
👍🏻
Andrew
@andrewc910
@damianham I 100% agree with you.
@eliasjpr no promises but I'll take a look at rails in my free time. If I can get a nice idea of how it works, I'll open a rfc with an explanation. I'm pretty busy rn so it might be awhile.
Elias Perez
@eliasjpr
Thanks @andrewc910