GSoC 2022 CircuitVerse | Week 7 and 8 Report

gsoc-2022-circuitverse-|-week-7-and-8-report

Description

This week I worked on completing the Noticed Integration into CircuitVerse, this was one of the challenging and most productive week ever as I have learned:

  • Rails console effective usage.
  • ActiveRecords
  • Migration.
  • Controllers.
  • Views rails.

So on the last meeting, I showed the demo of the notification functionality to the mentors and they stated it that there is some more small changes in the UI and to migrate the old data of Activity Notification.

I completed the task for helper methods, UI and some cleanups. But the most challenging task for me was to migrate data from one table to another table with different configuration. Aboobacker shared a migration file that contains SQL query for the migration but that was comparatively simpler then what I need to do in this task!

So I comeup with many solution to render oldnotification:

  1. I thought we can just add a before_action filter with method load_old_notifications for user.So I create a new column in old_notification table called migrated with default false, so whenever the user signin, the load_old_notifications will run and will check in the old_notification if the migrated field is false, it will create a new data for notification table and mark migrated as true in old_notification table.

  2. But I find this as very complex as we are thinking of removing ActivityNotification gem and while migrating there is model method needed to get the path of the notification, so I drop this solution and jump into next and next, I failed and finally come up with the solution to use ActiveRecords in migration (it worked but not preferable) so here is my migration file look like:

class PopulateNotificationData < ActiveRecord::Migration[7.0]
  include ActivityNotification
  def change
    Notification.find_each do |data|
      newnotification = NoticedNotification.first_or_initialize(
        :recipient_type => data.target_type,
        :recipient_id => data.target_id,
        :type => "PreviousNotification",
        :params => {
          user_id: data.notifier_id,
          path: data.notifiable_path,
          message: data.notifiable.printable_notifiable_name(data.target),
          type: data.notifiable_type
        },
        :read_at => data.opened_at
      )
      newnotification.save!
    end
  end
end

I need to change it in SQL query.

So that took me around 4 days but it was worth it, I learned a lot from failures.

This 2 weeks I also :

  • Passed Mid-term Evaluation
  • Post my first blog on CircuitVerse/Blog regarding first phase of GSoC.
  • Attended my first offline hackathon and meet awesome peoples.

Next week plan:

  • Complete spec testcases
  • Complete migration
  • Start working on push notification in mobile app.
Total
1
Shares
Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Post
how-to-fix-‘uncaught-syntaxerror:-cannot-use-import-statement-outside-a-module’

How to fix ‘Uncaught SyntaxError: Cannot use import statement outside a module’

Next Post
building-in-aws-–-install-aws-cli-version-2

Building in AWS – Install AWS CLI version 2

Related Posts