LogRec.create(uid: task[:tid], lrtype: 'tsk', rc_time: rc_time, start: task[:start] )
LogRec.create(uid: task[:tid], lrtype: 'task', rc_time: rc_time, start: task[:start] )
module ProtocolElementTypeName TASK = 'task' NOTE = 'note' EVENT = 'event' end
log = Array.new log_recs.each do |log_rec| case log_rec.lrtype when 'qc' log.push({uid: log_rec.uid, type: log_rec.lrtype, parid: log_rec.parid, start: log_rec.start.gsub(" ", "T"), ts: log_rec.ts.gsub(" ", "T"), rc_time: log_rec.rc_time.gsub(" ", "T"), state: log_rec.state, rcpt: log_rec.recipient}) when 'tstate', 'etsks' log.push({type: log_rec.lrtype, parid: log_rec.parid, start: log_rec.start.gsub(" ", "T"), end: log_rec.end, ts: log_rec.ts.gsub(" ", "T"), rc_time: log_rec.rc_time.gsub(" ", "T"), state: log_rec.state, rcpt: log_rec.recipient}) when 'pcb', 'grps' log.push({type: log_rec.lrtype, ts: log_rec.ts.gsub(" ", "T"), rc_time: log_rec.rc_time.gsub(" ", "T"), rcpt: log_rec.recipient}) when 'egrp', 'tgrp' log.push({type: log_rec.lrtype, parid: log_rec.parid, ts: log_rec.ts.gsub(" ", "T"), rc_time: log_rec.rc_time.gsub(" ", "T"), state: log_rec.state, rcpt: log_rec.recipient}) when 'rprefs' log.push({type: log_rec.lrtype, parid: log_rec.parid, ts: log_rec.ts.gsub(" ", "T"), rc_time: log_rec.rc_time.gsub(" ", "T"), rcpt: log_rec.recipient}) else log.push({uid: log_rec.uid, type: log_rec.lrtype, parid: log_rec.parid, start: log_rec.start.gsub(" ", "T"), end: log_rec.end, ts: log_rec.ts.gsub(" ", "T"), rc_time: log_rec.rc_time.gsub(" ", "T"), state: log_rec.state, rcpt: log_rec.recipient}) end
module LogRecObjType # obj_type LogRec EVENT = 'event' QC = 'qv' TASK = 'task' end
@@types_objects = { ObjectJournal::QC => :complect_qc, ObjectJournal::EVENT => :complect_event, ObjectJournal::TASK => :complect_task }
def complect_qc obj = { :uid => self.id, :type => self.lrtype, :parid => self.parid, :start => self.start, :ts => self.ts, :rc_time => self.rc_time, :state => self.state, :rcpt=> self.recipient } return obj end # ...
def complect_object_journal if @@types_objects.has_key?(self.lrtype) return send(@@types_objects[self.lrtype]) else return complect_another end end
log = log_recs.map { |x| x.complect_object_journal }
class Operation def return_operation operation = { :goal => {:id => goal.gid, :title => goal.title, :ts => goal.ts}, :task => {:is_problem => task.is_problem, :state => task.state,:author => task.author_id} } return operation end end class Event < Operation def return_operation operation = { :goal => {:id => goal.gid, :title => goal.title, :ts => goal.ts, :author => goal..author_id, :holder => complect_goal_content_header}, :task => {:is_problem => task.is_problem, :state => task.state,:author => task.author_id} } return operation end end class Task < Operation def return_operation operation = { :goal => {:id => goal.gid, :title => goal.title, :ts => goal.ts}, :task => {:id => task.gid, :title => task.title, ts => task.ts, :author => task..author_id, :holder => complect_holder} } } return operation end end
class Operation def return_operation operation = { :goal => complect_goal, :task => complect_task } return operation end def complect_goal goal_obj = { :id => goal.gid, :title => goal.title, :ts => goal.ts, } return goal_obj end def complect_task #task = self.task task_obj = { :is_problem =>task.is_problem, :state => task.state, :author => task.author_id } return task_obj end end class Event < Operation def complect_goal goal_obj = { :id => goal.gid, :title => goal.title, :ts => goal.ts, :author => goal.author_id, :holder => complect_goal_content_header } return goal_obj end end class Task < Operation def complect_task task_obj = { :id => task.gid, :title => task.title, :ts => task.ts, :author => task.author_id, :holder => complect_holder } return task_obj end end
Source: https://habr.com/ru/post/261439/
All Articles