Skip to content

Commit

Permalink
Merge branch 'production' of github.com:interflux-electronics/interfl…
Browse files Browse the repository at this point in the history
…ux-api-rails-backend into feature/visits
  • Loading branch information
janwerkhoven committed Feb 9, 2024
2 parents 142baaf + 4ba5771 commit 411ee69
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 3 deletions.
1 change: 1 addition & 0 deletions app/controllers/v1/admin/companies_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def creatable_attributes
rank_on_group_website
show_markets
head_count
shown_on_icsf_website
]
end

Expand Down
2 changes: 2 additions & 0 deletions app/controllers/v1/public/companies_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ def permitted_includes
def permitted_filters
%i[
business_name
shown_on_main_website
shown_on_group_website
shown_on_icsf_website
]
end
end
Expand Down
3 changes: 2 additions & 1 deletion app/serializers/v1/admin/company_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ class CompanySerializer < ApplicationSerializer
:history,
:rank_on_group_website,
:show_markets,
:head_count
:head_count,
:shown_on_icsf_website

belongs_to :country

Expand Down
3 changes: 2 additions & 1 deletion app/serializers/v1/public/company_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ class CompanySerializer < ApplicationSerializer
:history,
:rank_on_group_website,
:show_markets,
:head_count
:head_count,
:shown_on_icsf_website

belongs_to :country

Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20240127091511_add_tag_for_icsf_suppliers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddTagForIcsfSuppliers < ActiveRecord::Migration[6.1]
def change
add_column :companies, :shown_on_icsf_website, :boolean, default: false
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2024_01_21_003248) do
ActiveRecord::Schema.define(version: 2024_01_27_091511) do

# These are extensions that must be enabled in order to support this database
enable_extension "pgcrypto"
Expand Down Expand Up @@ -90,6 +90,7 @@
t.boolean "show_markets", default: true
t.integer "head_count", default: 1
t.boolean "shown_on_main_website", default: false
t.boolean "shown_on_icsf_website", default: false
t.index ["business_name"], name: "index_companies_on_business_name", unique: true
t.index ["country_id"], name: "index_companies_on_country_id"
t.index ["slug"], name: "index_companies_on_slug", unique: true
Expand Down
70 changes: 70 additions & 0 deletions lib/tasks/companies.rake
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,74 @@ namespace :companies do
company.update!(shown_on_main_website: true)
end
end

task create_icsf_suppliers: :environment do
log.info '⛵️'

# 1. Create the 8 missing companies.

to_create = [
['AI Electronics & Technology', 'AI Electronics & Technology Co., Ltd.', '114/192 M.1 T.Samet A. Mueang, Chonburi 20000', 'Thailand', '[email protected]', 'https://www.aiet.co.th/', '+66955861119'],
['Elas', 'Elas Kft.', 'Diófa u. 130, Budapest, 1162', 'Hungary', '[email protected]', 'https://elas.hu', '+36 (1) 220-9401'],
['Link Ways Tech', 'Link Ways Tech Co., Ltd.', '16F, Block B, Jin Shi Wang Hu Building, No. 18, Jia Rui alley, SIP, China', 'China', '[email protected]', 'https://www.mylinkways.com/', '+86 177 5172 9710'],
['PT Tamura Trade Indonsia', nil, 'Taman Surya II Blok D2/3, Cengkareng, Jakarta Barat 11830', 'Indonesia', '[email protected]', nil, '+62811878355'],
['SIP Technology', 'SIP Technology (M) SDN BHD', '36 Lorong IKS Bukit Tengah, Taman IKS Bukit Tengah, Penang 14000', 'Malaysia', '[email protected]', 'https://sip-technology.com/en/', '+604 508 8318'],
['Smartsol Technologies Mexico', nil, 'Prol. Pino Suárez 1039-int 23,El Vigía,Zapopan, Jalisco 45140', 'Mexico', '[email protected]', 'https://smartsol.mx/', '+52 3332713784'],
['Smartsol Technologies USA', nil, '12301 Rojas Dr Ste A14, El Paso, TX 79928', 'United States of America', '[email protected]', 'https://smartsol.mx/', '+16199007517'],
['VLK Techno Trade', 'V.L.K. TECHNO TRADE CO.,LTD.', '13, 36/7 Thanon Lam Luk Ka, Bueng Kham Phroi, Lam Luk Ka District, Pathum Thani 12150', 'Thailand', '[email protected]', 'https://www.vlktechno.com/', '+66215024751']
]

to_create.each do |data|
record = Company.find_by(business_name: data[0])

next if record.present?

Company.create!(
business_name: data[0],
legal_name: data[1],
address: data[2],
country: Country.find_by(name_english: data[3]),
email_orders: data[4],
website: data[5],
phone: data[6]
)
end

# 2. Flag 13 companies as approved ISCF distributors.

to_approve = [
'ABAN Electronics',
'AI Electronics & Technology',
'Autronix Systems',
'Elas',
'Interflux Singapore',
'JRPV Semicon Supplies',
'Link Ways Tech',
'Oritech',
'PT Tamura Trade Indonsia',
'SIP Technology',
'Smartsol Technologies Mexico',
'Smartsol Technologies USA',
'VLK Techno Trade'
]

to_approve.each do |name|
company = Company.find_by(business_name: name)

raise '🔥' if company.nil?

company.update(
public: true,
shown_on_icsf_website: true
)
end

log.info '✅'
end

private

def log
Rails.logger
end
end

0 comments on commit 411ee69

Please sign in to comment.