IRC logs for #farmOS, 2020-10-05 (GMT)

2020-10-04
2020-10-06
TimeNickMessage
[04:46:25]* farmBOT has quit (Ping timeout: 240 seconds)
[04:46:50]* farmBOT has joined #farmos
[16:02:32]<skalakm[m]>I'm reading the message you left. I think you're giving me too much credit for knowing what's going on. As I understand it, my first step should be running a php script (eg with drush php-script) that calls that function with the appropriate inputs. I'm not sure what step 2 is. Does that function itself do the grouping? What do I do with the log that's returned? I've used the feeds module to import some logs, but I
[16:02:32]<skalakm[m]>don't see an importer for this type of log.
[16:05:48]<mstenta[m]>Hi skalakm - haha looking back I may have misread your question too.
[16:06:02]<mstenta[m]>What exactly are you trying to do? I'll see if I can suggest something more specific...
[16:07:53]<skalakm[m]>For example, I have 3 asset types (apples, cantaloupes, and honey dew melons) that I have imported. I would like to assign them all them all to the group "fruit".
[16:08:49]<mstenta[m]>Ok!
[16:09:32]<mstenta[m]>So first, create the group named "Fruit"
[16:10:19]<skalakm[m]>Ok, that's done.
[16:10:39]<mstenta[m]>Then, if you have all the asset IDs...
[16:11:03]<mstenta[m]>(assuming the first three are IDs: 1, 2, 3 - and the "Fruit" group is 4)...
[16:12:02]<mstenta[m]>ACTION sent a long message: < https://matrix.org/_matrix/media/r0/download/matrix.org/blVfXBPJORMcuMDe... >
[16:12:08]<mstenta[m]>oops - hit enter too soon :-)
[16:14:26]<mstenta[m]>ACTION sent a long message: < https://matrix.org/_matrix/media/r0/download/matrix.org/EJgjFEdpYrqyALVX... >
[16:15:04]<mstenta[m]>That PHP code will create a log - that assigns the plantings to the group
[16:15:54]<mstenta[m]>Are you hoping to perform this assignment DURING Feeds import?
[16:16:08]<mstenta[m]>It might make sense to do it afterwards
[16:16:15]<mstenta[m]>So all the assets are in the system
[16:17:50]<mstenta[m]>(Worth noting, this is a very similar problem to assigning "Location" during Feeds import - which I believe @megandalster made his own solution for here: https://github.com/farmOS/farmOS/issues/199#issuecomment-659446449)
[16:21:22]<skalakm[m]>Afterwards is fine. What do I do with the log? (I'm still looking at Allen's code to figure it out.)
[16:22:53]<mstenta[m]>You don't need to do anything with the log - it's basically just a record in the system that says "These assets are in this group now"
[16:23:03]<mstenta[m]>That's how farmOS determines what groups an asset is in - by looking for those logs
[16:23:04]<mstenta[m]>Same for location
[16:23:21]<mstenta[m]>So that: over time you can have a history of an assets movements (and group membership changes) over time
[16:24:02]<mstenta[m]>That probably isn't needed for your use-case (Grouping plantings), but is needed for things like animals moving from one herd to another
[16:25:53]* nickredmark[m] has quit (Ping timeout: 244 seconds)
[16:28:25]* jgaehring[m]1 has quit (Ping timeout: 244 seconds)
[16:28:25]* blm5303[m] has quit (Ping timeout: 244 seconds)
[16:28:25]<skalakm[m]>You never know when something will stop being a fruit... I'll need to try out what you said, but while I've got you here, is there a similar way to assign harvest logs to users?
[16:28:25]* jgaehring[m]1 has joined #farmos
[16:28:29]<skalakm[m]>(and this might be a stupid question, is that snippet you gave me the entire file? do I need import statements or something? My php is a work in progress)
[16:29:07]* blm5303[m] has joined #farmos
[16:29:40]* nickredmark[m] has joined #farmos
[16:29:50]<mstenta[m]>> You never know when something will stop being a fruit...
[16:29:50]<mstenta[m]>Haha WHAT IS a fruit, really? ;-)
[16:31:06]<mstenta[m]>> is there a similar way to assign harvest logs to users?
[16:31:06]<mstenta[m]>We don't have a general purpose "helper function" for assigning a log to a user, but all the logic can be found here:
[16:31:06]<mstenta[m]>https://github.com/farmOS/farmOS/blob/92f854b9be271e06f2e005f14d64653eb4...
[16:31:25]<mstenta[m]>that is the code that runs when you click a checkbox next to a Log in farmOS, and click the "Assign" button
[16:31:56]<mstenta[m]>> is that snippet you gave me the entire file? do I need import statements or something?
[16:31:56]<mstenta[m]>that was just a snippet - where you put it depends on where you need it :-)
[16:32:16]<mstenta[m]>but for example... that could be put in a simple `test.php` file in the webroot, and run via `drush php-script test.php`
[16:32:41]<mstenta[m]>that's a quick and dirty way to run code
[16:33:34]<mstenta[m]>or... it could make sense to write something more general in a module... just depends on what you need
[16:33:50]<mstenta[m]>are you working with custom modules at all yet?
[16:35:07]<skalakm[m]>No, I'm still at quick and dirty. I'll give it a try that way and see what happens. Thank again for all your help.
[16:35:21]<mstenta[m]>Thumbs up!