Entry tags:
It's thursday and the code mostly works
Code works manually but not in the script. Anyone receiving multiple new account emails can rest assured that this is a good sign ;)
ref:https://dev.atlbbs.com/svn/atlbbs/trunk/moocash/doc/logic_three.rb
Reread Dune Messiah in the last couple days. That was really quite good and much better than I remember. It makes watching the SciFi miniseries ever so much more painful, though.
Moving is proceeding at a trickle, but there's food in the kitchen and other signs of a potential home. Plenty of work ahead on that front, not including dragging more crap across town, and eventually paying someone to move the furniture over.
That wasn't much better that the last try, but oh well. How are all of you doing? Surviving the $holiday onslaught?
#!/usr/bin/env ../script/runner ## third try on the order processing logic, started in pseudocode ## preliminaries: ## cache existing moodle users moodle_users = User.all.collect do |u| u.username end ## Run through lineitems, creating MoocashOrderProcessing ## where not found so we have is_processed? fields OrderProduct.all.each do |op| ## make a mop if there is not already a MoocashOrderProcessing line for this lineitem MoocashOrderProcessing.new(op).save unless MoocashOrderProcessing.find_by_orders_products_id(op.orders_products_id) end ## Main order processing loop ## For every line item not marked as processed MoocashOrderProcessing.find_all_by_processed(0).each do |mop| ##get the lineitem from the MOP view lineitem = mop.orderproduct ## if lineitem's product type is 'training' if lineitem.product.master_categories_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='mjolnir' ## 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 mco = MoocashOrder.new lineitem.order ## ask the MoocashOrder to enroll mco.enroll quantum_class_id ## if writing to DB does not fail spectacularly ... mco.save ## mark it done mop.processed = 1 mop.save end end end
ref:https://dev.atlbbs.com/svn/atlbbs/trunk/moocash/doc/logic_three.rb
Reread Dune Messiah in the last couple days. That was really quite good and much better than I remember. It makes watching the SciFi miniseries ever so much more painful, though.
Moving is proceeding at a trickle, but there's food in the kitchen and other signs of a potential home. Plenty of work ahead on that front, not including dragging more crap across town, and eventually paying someone to move the furniture over.
That wasn't much better that the last try, but oh well. How are all of you doing? Surviving the $holiday onslaught?