Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Joe Gaudet
    @joegaudet
    The only patch to the instance we observe doesn’t include the to_many relationship
    What is the key argument in this instance
    Larry Gebhardt
    @lgebhardt
    I think it's the related resource ids, but I haven't confirmed yet. I'll do some testing now
    Joe Gaudet
    @joegaudet
    Gotcha, so it’d look something like
    Order.order_items.delete(1,2,3)
    Let me test that.
    Larry Gebhardt
    @lgebhardt
    I think it will just be one at a time (seems we could optimize that)
    Joe Gaudet
    @joegaudet
    Calling it in that manner still triggers acts_as_paranoid and paper_trail.
    [44] pry(main)> Order.last.order_items.delete(1)
      Order Load (1.1ms)  SELECT  "orders".* FROM "orders" ORDER BY "orders"."id" DESC LIMIT 1
      OrderItem Load (0.7ms)  SELECT  "order_items".* FROM "order_items" WHERE "order_items"."deleted_at" IS NULL AND "order_items"."order_id" = 197 AND "order_items"."id" = 1 LIMIT 1
       (0.5ms)  BEGIN
      MenuItem Load (0.7ms)  SELECT  "menu_items".* FROM "menu_items" WHERE "menu_items"."id" = 163 LIMIT 1
      Query Trace > app/models/order_item.rb:249:in `client_price_cents'
      MenuOptionItem Load (0.9ms)  SELECT "menu_option_items".* FROM "menu_option_items" INNER JOIN "order_item_menu_option_items" ON "menu_option_items"."id" = "order_item_menu_option_items"."menu_option_item_id" WHERE "order_item_menu_option_items"."order_item_id" = 1 ORDER BY "menu_option_items"."id" ASC
      Query Trace > app/models/order_item.rb:354:in `record_misc_for_paper_trail'
       (0.3ms)  BEGIN
      SQL (0.9ms)  INSERT INTO "foodee_versions" ("item_type", "item_id", "event", "object", "created_at", "misc", "order_id") VALUES ('OrderItem', 1, 'destroy', '{"id":1,"menu_item_id":163,"order_id":197,"item_options":[],"menu_item_version":null,"created_at":"2019-12-11T22:23:23.835Z","updated_at":"2019-12-11T22:25:24.987Z","quantity":1,"notes":null,"client_price_cents":400,"restaurant_price_cents":289,"taxable":null,"legacy_id":null,"legacy_data":null,"group_order_member_id":null,"deleted_at":null,"override_prices":false,"capacity_units":1.0}', '2019-12-11 22:25:34.629523', '{"menu_item":"Wakame Salad","menu_option_items":[],"group_order_member":null}', 197) RETURNING "id"
       (1.0ms)  COMMIT
    Enqueued HistorianVersionPusherJob (Job ID: e6e999c1-f059-4533-93c8-7457bb0da99a) to Sidekiq(default) with arguments: 3086
      ClientInvoiceItem Load (0.6ms)  SELECT  "invoicing_line_items".* FROM "invoicing_line_items" WHERE "invoicing_line_items"."type" IN ('ClientInvoiceItem') AND "invoicing_line_items"."billable_id" = 1 AND "invoicing_line_items"."billable_type" = 'OrderItem' LIMIT 1
      RestaurantInvoiceItem Load (0.5ms)  SELECT  "invoicing_line_items".* FROM "invoicing_line_items" WHERE "invoicing_line_items"."type" IN ('RestaurantInvoiceItem') AND "invoicing_line_items"."billable_id" = 1 AND "invoicing_line_items"."billable_type" = 'OrderItem' LIMIT 1
      SQL (0.6ms)  UPDATE "order_items" SET "deleted_at" = '2019-12-11 22:25:34.653016', "updated_at" = '2019-12-11 22:25:34.653167' WHERE "order_items"."id" = 1
      SQL (2.0ms)  UPDATE "orders" SET "updated_at" = '2019-12-11 22:25:34.657432' WHERE "orders"."id" = 197
       (0.6ms)  COMMIT
    Enqueued Searchkick::ReindexV2Job (Job ID: 3e77cf50-848e-43a4-8cc5-5f0de86275e1) to Sidekiq(searchkick) with arguments: "Order", "197", nil, {:routing=>nil}
    => [#<OrderItem:0x00007fd8289028f8
      id: 1,
      menu_item_id: 163,
      order_id: 197,
      item_options: [],
      menu_item_version: nil,
      created_at: Wed, 11 Dec 2019 22:23:23 UTC +00:00,
      updated_at: Wed, 11 Dec 2019 22:25:34 UTC +00:00,
      quantity: 1,
      notes: nil,
      client_price_cents: nil,
      restaurant_price_cents: nil,
      taxable: nil,
      legacy_id: nil,
      legacy_data: nil,
      group_order_member_id: nil,
      deleted_at: Wed, 11 Dec 2019 22:25:34 UTC +00:00,
      override_prices: false,
      capacity_units: 1.0>]
    [45] pry(main)>
    Larry Gebhardt
    @lgebhardt
    That's good to know. And I mis-traced the code. That won't get called from update (too many similar names)
    Joe Gaudet
    @joegaudet
    I’m crazy stumped
    Larry Gebhardt
    @lgebhardt
    How are you sure it's happening on the particular patch call?
    Joe Gaudet
    @joegaudet
    We definitely aren’t sure.
    But there’s only one place with a explict call to destroy those records.
    And we don’t see that inthe logs
    So just thought that might be one way in.
    Larry Gebhardt
    @lgebhardt
    In your resources posted above which one is getting deleted?
    Joe Gaudet
    @joegaudet
    Reservations.
    While working with instances.
    Larry Gebhardt
    @lgebhardt
    I just don't see how that would be happening
    Joe Gaudet
    @joegaudet
    Yeah, we’re quite puzzled as well.
    Larry Gebhardt
    @lgebhardt
    No other code hitting the db?
    Joe Gaudet
    @joegaudet
    I certainly hope not.
    Larry Gebhardt
    @lgebhardt
    :)
    Joe Gaudet
    @joegaudet
    I made it happen once locally, but still cannot reliably reproduce.
    Dmitriy "Dima" Likhten
    @dlikhten
    @lgebhardt to your earlier question... Unfortunately resources go through operations and processors so it is way more accurate for me to test the controller than the resource. I know it is not that helpful :( but we do tend to treat those controller tests as unit tests for resources testing all branching that way.
    Larry Gebhardt
    @lgebhardt
    @dlikhten Thanks, that actually is helpful in it confirms I'm not missing an obvious easier way of doing something. It's always felt a bit wrong and I've been hesitant to document it that way in the guides, but it is a subject I want to cover.
    Scott González
    @scottgonzalez
    We have real unit tests for our ApplicationResource class, but all of our tests for the individual resources are controller tests.
    We have a bunch of helper methods we use in those tests, but the tests make a full request.
    Dmitriy "Dima" Likhten
    @dlikhten
    @lgebhardt i do like how the delegation works, but also it is a bit of a drag to try to isolate the behavior for testing, sort of a code-smell to me. I can test the resource, and there's a bunch of stuff there, but most interesting things like queries and filters, that all only works via the processors.
    Artem Panfilenko
    @enkos

    Anyone got worked ancestry + jsonapi-resources?

    I read wiki https://github.com/cerebris/jsonapi-resources/wiki/Use-with-Ancestry but get and error

    Can't join 'Tag' to association named 'parent'; perhaps you misspelled it?

    When make request like http://localhost:3000/tags/2?include=parent

    Joe Gaudet
    @joegaudet
    Unrelated to JR, can anyone tell my why this gist is doing what it’s doing in tst.rb
    Joe Gaudet
    @joegaudet
    I feel legit like I’m taking crazy pills here
    Larry Gebhardt
    @lgebhardt
    It looks like the 1=0 parts would be where the polymorphic foreign key part of the where clause would be. Maybe it can't figure that out because of the namespacing. Can you try specifying the foreign_key on the belongs_to?
    Joe Gaudet
    @joegaudet
    Tried that, no effect.
    If I go from Accounting::Invoice.last.invoiceable it works
    It’s odd that there are two
    1=0s
    Larry Gebhardt
    @lgebhardt
    That is very weird. I'd probably start stepping into the rails code and see what's going on.
    Have you tried removing the concern and placing the invoicable relationship directly into GroupOrderMember?
    Joe Gaudet
    @joegaudet
    Yeah no luck either
    Larry Gebhardt
    @lgebhardt
    Maybe remove the namespaces too, just to simplify it as much as possible
    Joe Gaudet
    @joegaudet
    Yeah that would be a next go to, there is also the STI in play as Invoice is a subclass of LedgerItem
    Polymorphism is so fucked in rails.
    Larry Gebhardt
    @lgebhardt
    Polymorphism is not my favorite rails feature. I think half the time on JR was spent fighting with it.
    Joe Gaudet
    @joegaudet
    It doesn’t really suport some critical fatures, like multiple inheritance
    It’s quite annoying
    Anywho thanks for taking a look, I’m going to let it simmer for a bit.
    Larry Gebhardt
    @lgebhardt
    Good luck with it