lib/tsks/cli.rb in tsks-0.0.14 vs lib/tsks/cli.rb in tsks-0.0.15

- old
+ new

@@ -82,11 +82,11 @@ end if tsks.count > 0 for tsk in tsks tsk_status = Tsks::Actions.get_tsk_status tsk[:status] - puts "#{tsk[:id]} #{tsk_status} | #{tsk[:tsk]} @#{tsk[:context]}" + puts "#{tsk[:id]} | #{tsk_status} #{tsk[:tsk]} @#{tsk[:context]}" end else puts "no tsks found." end end @@ -157,12 +157,12 @@ user_id = File.read File.join CLI.setup_folder, "user_id" token = File.read File.join CLI.setup_folder, "token" Tsks::Actions.update_tsks_with_user_id user_id Tsks::Actions.update_server_for_removed_tsks token - Tsks::Storage.delete_removed_uuids - local_tsks = Tsks::Storage.select_all local_id=false + Tsks::Storage.delete_removed_tsk_ids + local_tsks = Tsks::Storage.select_all begin get_res = Tsks::Request.get "/tsks", token remote_tsks = get_res[:tsks] @@ -174,20 +174,16 @@ for tsk in local_tsks_to_post post_res = Tsks::Request.post "/tsks", token, {tsk: tsk} posted_tsk = post_res[:tsk] if posted_tsk - # TODO: write tests for Storage.select_local_id - tsk_local_id = Tsks::Storage.select_local_id({tsk: posted_tsk[:tsk], - created_at: posted_tsk[:created_at], - updated_at: posted_tsk[:updated_at]}) - - Tsks::Storage.update tsk_local_id, {id: posted_tsk[:id]} + Tsks::Storage.update_by({rowid: tsk[:rowid]}, {id: posted_tsk[:id]}) end end end - updated_local_tsks = Tsks::Storage.select_all local_id=false + # TODO: review this process + updated_local_tsks = Tsks::Storage.select_all remote_tsks_to_storage = remote_tsks - updated_local_tsks if remote_tsks_to_storage.count > 0 Tsks::Storage.insert_many remote_tsks_to_storage end