#RubyOnRails - 07 August 2019
« Back 1 day Forward 1 day »
[08:11:30] Intelo: cannot use rvm. can we just use rails internal server to run redmine instead of ngnix or apache
[09:18:16] algun: sylario: create a temporary table to import a spreadsheet into. This temporary table must be unique to the import... occasion. Hence variable name
[09:21:45] algun: I want data in a uniquely-named temporary table for multiple reasons. It's faster to work with (in memory by default, can diff with the [permanent] target table using a performant query), memory management done by the DB, in case of an error the table will be dropped.
[09:31:26] algun: The devs I'm supporting aren't SQL savvy I'm afraid. They've managed to create a temporary table through Rails already. What they're stumped with is how to parameterize a model to use the temporary tale they've created.
[09:39:52] Sylario: they can create a non-AR model and create a basic sets of fuction to implement the interactions between the DB and the model
[10:14:44] Sylario: I do not understand, you can create a table with any name you want with a direct SQL query
[10:16:28] algun: The question is precisely how to parameterize an ActiveRecord so that its table name is set at runtime
[10:19:29] algun: I explained this as well. In particular, an attribute that differentiate between imports does nothing to remove data in case of failure.
[10:20:53] algun: note that in your case, the table can't be temporary because it's used by multiple imports
[10:22:46] algun: "Temporary tables are automatically dropped at the end of a session, or optionally at the end of the current transaction (see ON COMMIT below)."
[10:23:59] Sylario: I would just create a cron task that delete rows from a job older than one hours or something like that
[10:24:54] algun: I find it strange that Rails' models don't seem to support dynamically-named tables
[10:30:30] algun: Is it feasible to just set table_name = 'useredit_'+SecureRandom.uuid and use that name to create a temporary table? Would that be a new name for each request? Or is there a shared pool of ARs across requests, meaning names would not be unique (the UUID would only be calculated once)?
[10:31:11] algun: (user is the "target" table, useredit_*-s are supposed to be the temporary "import" tables)
[13:09:22] dionysus69: I am thinking about a functionality that would automatically handle restful routes if they are not present in routes.rb
[13:11:35] dionysus69: I am doing this because I am just experimenting around, may not be that useful by the end of the day, but would be great if just declaring controller/action would deduce the route in case of restful actions at least*
[17:15:57] dviola: I'm trying to get rid of this each loop: https://github.com/diegoviola/fromthepage/blob/1175-remove-show-to-method/app/controllers/dashboard_controller.rb#L55-L59
[17:16:26] dviola: the problem is it calls all these model methods: like_owner? and collaborator? -- it expects a loop of some sort
[17:24:14] havenwood: dviola: it seems line 56 could simply be done in the query, which would presumably reduce the collection size before iteration
[17:25:12] havenwood: dviola: i usually recommend chaining off of #find_each, if you really want to iterate over large collections so it'll be in proper batches
[17:26:17] havenwood: dviola: though I guess you're using a #filter_map, which Ruby doesn't add until version 2.7 this Christmas
[17:27:20] havenwood: dviola: It's hard to say how to optimize #like_owner? and #collaborator? without knowing what those do.
[17:28:27] dviola: havenwood: https://github.com/diegoviola/fromthepage/blob/master/app/models/user.rb#L102-L121 -- btw, I don't expect you to tell me how to rewrite this one
[17:29:25] dviola: collaborator? is here: https://github.com/diegoviola/fromthepage/blob/master/app/models/user.rb#L102-L121
[17:30:21] dviola: https://github.com/diegoviola/fromthepage/blob/master/app/models/user.rb#L98-L100
[17:31:25] havenwood: dviola: ^ that's a bit more efficient (presuming, haven't benchmarked) way to check: Collection == obj.class
[18:14:29] xco: hi is there a better way to get current time and date nicely formatted like “August 07, 2019 20:11” without using strftime?