Giter Site home page Giter Site logo

crm's Introduction

CRM Mobile

Running on local

Console

  • dc run app rails console development

Run rake task in console

  • require 'rake'
  • Rails.application.load_tasks
  • Rake::Task['fake:clients'].invoke
  • Rake::Task['fake:activities'].invoke

v1.1 todo

  • Get production data
  • Get ruby version from the other computer

Install Procedures

  • rake load_data:clients # Load all the clients
  • rake load_data:industries # Load all the industry data
  • rake load_data:models # Load all the model data

After deploy, have to do this on the server (for now) - capistrano can be challenging.

  • cd /home/sgadeploy/crm/current
  • bundle install --without development test
  • bundle exec rake assets:precompile RAILS_ENV=production
  • whenever -w
  • ps -aux | grep unicorn
  • kill
  • /etc/init.d/unicorn_crm start

After rails upgrade, go to /home/sgadeploy/crm/current and run

  • bundle install --without development test

Migrations

  • bundle exec rake db:migrate RAILS_ENV=production

Replace SSL cert

From local, put rossmixing.crt certificate on the server somewhere:

Mac dev for tests

Postgres on server

  • psql (PostgreSQL) 9.3.17

Ruby on server

  • ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]

Docker

  • docker-compose run app bundle exec rake db:create
  • docker-compose run app bundle exec rake db:migrate
  • docker-compose run app psql -h db -U postgres crm_development < crm_production.dump

Docker production

  • dcprod = docker-compose -f docker-compose.prod.yml
  • dcprod run app bundle exec rake db:create
  • dcprod run app bundle exec rake db:migrate
  • dcprod run app bundle exec rake db:migrate:up VERSION=20200417190235
  • bundle exec rake assets:precompile
  • dcprod run app psql -h db -U postgres crm_production < crm_production.dump

Set up the ec2 instance

  • sudo yum install docker
  • sudo yum install git
  • sudo systemctl start docker
  • sudo systemctl enable docker ** Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.

docker-compose

Login

ssh -i "crmrossmixingcom.pem" [email protected]

Auto restart on boot

@reboot (sleep 30s ; cd /home/ec2-user/crm ; /usr/local/bin/docker-compose -f docker-compose.prod.yml up -d )&

Rails console in production

  • dcprod run app rails console production

Postgres console in production

  • dcprod run app psql -h db -U postgres crm_production

Testing bug with pagination

  • Need to comment out the pagination in the erb in audit log and clients to pass tests

Backup and restore

  • pg_dump -h localhost -U postgres crm_production | gzip -c > /home/sgadeploy/backups/crm.2018-12-08.dump.gz
  • dcprod run app dropdb -U postgres -h db crm_production
  • dcprod run app createdb -U postgres -h db -T template0 crm_production
  • dcprod run app bash
  • cat ./crm.2018-12-08.dump.gz | gunzip | psql -h db -U postgres crm_production
  • /var/lib/docker/volumes/crm_backups/_data

Old IP

  • 72.28.113.176

Test outbound email to jim

UserMailer.test_email_to_jim().deliver_now()

View the docker volumes

  • There is one for the postgres data and one for the uploads data

[ec2-user@ip-10-0-0-245 public]$ docker volume ls DRIVER VOLUME NAME local crm_postgres_data local crm_uploads_data

[ec2-user@ip-10-0-0-245 public]$ docker volume inspect crm_uploads_data [ { "CreatedAt": "2018-12-21T01:59:02Z", "Driver": "local", "Labels": { "com.docker.compose.project": "crm", "com.docker.compose.version": "1.23.1", "com.docker.compose.volume": "uploads_data" }, "Mountpoint": "/var/lib/docker/volumes/crm_uploads_data/_data", "Name": "crm_uploads_data", "Options": null, "Scope": "local" } ]

Need sudo to get access to it [ec2-user@ip-10-0-0-245 public]$ sudo ls /var/lib/docker/volumes/crm_uploads_data/_data -lsa total 0 0 drwxrwxr-x 4 root root 44 Dec 21 01:59 . 0 drwxr-xr-x 3 root root 19 Dec 21 01:59 .. 0 drwxr-xr-x 3 root root 24 Dec 21 01:59 activity_attachment 0 drwxr-xr-x 2 root root 6 Dec 21 18:35 tmp

Here's where the files are right now [ec2-user@ip-10-0-0-245 public]$ sudo ls /var/lib/docker/volumes/crm_uploads_data/_data/activity_attachment/attachment 4198 4199 4200 4202 4203 4204 4205 4206 4207 4208 4209

Copy from my other location

sudo cp -r ~/crm_uploads_from_before_aws/activity_attachment/attachment /var/lib/docker/volumes/crm_uploads_data/_data/activity_attachment/

Get the missing clients

  • https://richonrails.com/articles/exporting-to-csv-using-ruby-on-rails-3-and-ruby-1-9 require 'csv' def self.as_csv CSV.generate do |csv| x = column_names + ["contacts_email", "users_email"] csv << x all.each do |item| y = item.attributes.values_at(*column_names) + [item.contacts.pluck("email").join(",")] + [item.users.pluck("email").join(",")] csv << y end end end this_month = Date.new(2018,12,1) @clients = Client.where("created_at >= ?", this_month).order(:created_at) File.open("clients.csv", "w+") do |f| f << @clients.as_csv end

Get the missing contacts

this_month = Date.new(2018,12,1) @contacts = Contact.where("created_at >= ?", this_month).order(:created_at) File.open("contacts.csv", "w+") do |f| f << @contacts.as_csv end

Get the missing activities

def self.create_from_import(activity_params) match_params = {activity_date: activity_params[:activity_date].in_time_zone("Eastern Time (US & Canada)"), client_id: activity_params[:client_id]} existing_activity = Activity.find_by(match_params) if existing_activity.nil? Activity.create(activity_params) else existing_activity end end

def self.as_csv CSV.generate do |csv| x = column_names + ["contact_email", "users_email", "clients_name", "clients_eid", "models_name", "activity_attachments"] csv << x all.each do |item| y = item.attributes.values_at(*column_names) + [item.contact.nil? ? "" : item.contact.email] + [item.user.nil? ? "" : item.user.email] + [item.client.nil? ? "" : item.client.name] + [item.client.nil? ? "" : item.client.eid] + [item.models.pluck("name").join(",")] + [item.activity_attachments.pluck("attachment").join(",")] csv << y end end end

this_month = Date.new(2018,12,1) @activities = Activity.where("created_at >= ?", this_month).order(:created_at) File.open("activities.csv", "w+") do |f| f << @activities.as_csv end

How to install Postgress 11 on Debian

Find missing activity attachments

Activity.all.each do |activity| if activity.activity_attachments.present? activity.activity_attachments.each do |aa| file_path = aa.attachment.file.file if !File.exist?(file_path) puts "=================================" puts "#{file_path} missing!" puts "ID = #{activity.id}" puts "User id = #{activity.user_id} which is #{activity.user.email}" puts "Activity date = #{activity.activity_date}" puts "Client = #{activity.client.name}" end end end end

Setup cron at the server level

[ec2-user@ip-10-0-0-245 crm]$ crontab -l @reboot (sleep 30s ; cd /home/ec2-user/crm ; /usr/local/bin/docker-compose -f docker-compose.prod.yml up -d )&

Import prospects hourly

0 * * * * /usr/local/bin/docker-compose -f /home/ec2-user/crm/docker-compose.prod.yml run --rm app bundle exec rake load_data:prospects

Make a database backup daily

30 23 * * * /usr/local/bin/docker-compose -f /home/ec2-user/crm/docker-compose.prod.yml run --rm app bundle exec rake db:backup

Read production logs

sudo tail -f /var/lib/docker/volumes/crm_log/_data/production.log

crm's People

Contributors

jimknight avatar

Watchers

 avatar  avatar  avatar

crm's Issues

Tweak the leads email

The leads we receive are formatted as listed in the email below. Since we often forward the email to respond to the question, it requires us to change the subject and some of the content.

Would it be possible to reword the subject line to read:
Inquiry at Mixers.com from "customer name " instead of New Lead: "customer name"

Also, can we reword:
Contact Information instead of Prospect Information

Finally, can we reword:
Assigned by "Ross contact name" instead of "Ross contact name" assigned you a prospect for "customer name".

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.