Entry tags:
In lieu of an update
Some more Rails code. This is the third try at describing the logic flow for order processing
for this project, and then trying to make it work.
I'd really like to burble about all of the sleep disturbances and work drama but this is all you get today. I'm so behind from last week that the work day is already over, and I'm to dinner.
*waves*
for this project, and then trying to make it work.
#!/usr/bin/env ../script/runner
## third try on the order processing logic, started in pseudocode
## cache existing moodle users
moodle_users = User.all
## Run through Orders,lineitems, creating MoocashOrderProcessing
## where not found so we have is_processed? fields
Order.all do |o|
o.ordersproducts.all do |op|
## if there is not already a MoocashOrderProcessing line for this lineitem
if not MoocashOrderProcessing.find_by_orders_products_id(op.orders_products_id)
## make one
MoocashOrderProcessing.new(op).save
end
end
end
## For every line item not marked as processed
MoocashOrderProcessing.find_by_processed(0) do |mop|
## if lineitem's product type is 'training'
if lineitem.product.master_category_id == '1'
## FAKE: get class_id from lineitem.products_id => class_id
quantum_class_id = '1'
## FAKE: get username from Order.orderstatushistory.comments REGEX ~= USERNAME:$username
aetheric_username='jsmith'
## if we're given an existing Moodle user, set it up for enroll in new class_id
if moodle_users.include? aetheric_username
## FAKE: enroll(aetheric_username, quantum_class_id)
## lineitem.processed = 1
p 'Moocash : order processing : debug : username given: #{aetheric_username}'
## More likely create a new entry in the view so Moodle will add a new
## => user and enroll it.
else
## New MoocashOrder, pass the Order by id
moop = MoocashOrder.new lineitem.order
## ask the MoocashOrder to enroll
moop.enroll quantum_class_id
## if writing to DB does not fail spectacularly ...
moop.save
## mark it done
lineitem.processed = 1
end
end
end
I'd really like to burble about all of the sleep disturbances and work drama but this is all you get today. I'm so behind from last week that the work day is already over, and I'm to dinner.
*waves*

no subject
Okay, honey