Skip to content
This repository has been archived by the owner on Jun 16, 2021. It is now read-only.

Commit

Permalink
Merge pull request #105 from omu/develop
Browse files Browse the repository at this point in the history
Merge develop into master
  • Loading branch information
msdundar authored Jul 13, 2018
2 parents 91fe8d9 + 60a487d commit c06405c
Show file tree
Hide file tree
Showing 44 changed files with 885 additions and 76 deletions.
12 changes: 6 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ GEM
thread_safe (~> 0.3, >= 0.3.1)
bcrypt (3.1.12)
bindex (0.5.0)
bootsnap (1.3.0)
bootsnap (1.3.1)
msgpack (~> 1.0)
brakeman (4.3.1)
builder (3.2.3)
Expand Down Expand Up @@ -171,7 +171,7 @@ GEM
orm_adapter (0.5.0)
pagy (0.12.0)
parallel (1.12.1)
parser (2.5.1.0)
parser (2.5.1.2)
ast (~> 2.4.0)
pg (1.0.0)
pg_search (2.1.2)
Expand Down Expand Up @@ -221,20 +221,20 @@ GEM
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
redis (4.0.1)
reek (5.0.1)
reek (5.0.2)
codeclimate-engine-rb (~> 0.4.0)
kwalify (~> 0.7.0)
parser (>= 2.5.0.0, < 2.6)
parser (>= 2.5.0.0, < 2.6, != 2.5.1.1)
rainbow (>= 2.0, < 4.0)
responders (2.4.0)
actionpack (>= 4.2.0, < 5.3)
railties (>= 4.2.0, < 5.3)
rollbar (2.16.2)
multi_json
rubocop (0.58.0)
rubocop (0.58.1)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
parser (>= 2.5)
parser (>= 2.5, != 2.5.1.1)
powerpack (~> 0.1)
rainbow (>= 2.2.2, < 4.0)
ruby-progressbar (~> 1.7)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Nokul

[![Product](https://assets.omu.sh/badge/product.svg)](https://omu.sh "BAUM Product") [![Maintainability](https://api.codeclimate.com/v1/badges/32e076b5cbd4ee545f48/maintainability)](https://codeclimate.com/github/omu/nokul/maintainability) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/2c7333e690454bbd99811c8860f08d2b)](https://www.codacy.com/app/msdundar/nokul?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=omu/nokul&amp;utm_campaign=Badge_Grade) [![CircleCI](https://circleci.com/gh/omu/nokul/tree/master.svg?style=svg&circle-token=a25e63abc0e1e6c074750d9b2ce5396e3e279d82)](https://circleci.com/gh/omu/nokul/tree/master) [![Codacy Badge](https://api.codacy.com/project/badge/Coverage/2c7333e690454bbd99811c8860f08d2b)](https://www.codacy.com/app/msdundar/nokul?utm_source=github.com&utm_medium=referral&utm_content=omu/nokul&utm_campaign=Badge_Coverage) [![Known Vulnerabilities](https://snyk.io/test/github/omu/nokul/badge.svg)](https://snyk.io/test/github/omu/nokul)
[![Beta](https://omu.sh/assets/badge/beta.svg)](https://omu.sh "BAUM Beta") [![Maintainability](https://api.codeclimate.com/v1/badges/32e076b5cbd4ee545f48/maintainability)](https://codeclimate.com/github/omu/nokul/maintainability) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/2c7333e690454bbd99811c8860f08d2b)](https://www.codacy.com/app/msdundar/nokul?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=omu/nokul&amp;utm_campaign=Badge_Grade) [![CircleCI](https://circleci.com/gh/omu/nokul/tree/master.svg?style=svg&circle-token=a25e63abc0e1e6c074750d9b2ce5396e3e279d82)](https://circleci.com/gh/omu/nokul/tree/master) [![Codacy Badge](https://api.codacy.com/project/badge/Coverage/2c7333e690454bbd99811c8860f08d2b)](https://www.codacy.com/app/msdundar/nokul?utm_source=github.com&utm_medium=referral&utm_content=omu/nokul&utm_campaign=Badge_Coverage) [![Known Vulnerabilities](https://snyk.io/test/github/omu/nokul/badge.svg)](https://snyk.io/test/github/omu/nokul)

## Prerequisites

Expand Down
1 change: 1 addition & 0 deletions app/assets/images/baum-beta.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion app/controllers/locations/countries_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def set_country
end

def country_params
params.require(:country).permit(:name, :alpha_2_code, :alpha_3_code, :numeric_code, :mernis_code)
params.require(:country).permit(:name, :alpha_2_code, :alpha_3_code, :numeric_code, :mernis_code, :yoksis_code)
end
end
end
59 changes: 59 additions & 0 deletions app/jobs/yoksis/articles_create_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# frozen_string_literal: true

module Yoksis
class ArticlesCreateJob < ApplicationJob
queue_as :high

# slow operation
def perform(user)
@response = Services::Yoksis::V1::Ozgecmis.new(user.id_number.to_i).articles
end

# callbacks

# rubocop:disable Metrics/BlockLength
after_perform do |job|
user = job.arguments.first
if @response[:sonuc][:durum_kodu].eql?('1') && @response[:makale_liste].present?
response = [@response[:makale_liste]].flatten

response.each do |study|
user.articles.create(
yoksis_id: study[:yayin_id],
scope: study[:kapsam_id].try(:to_i),
review: study[:hakem_tur].try(:to_i),
index: study[:endeks_id].try(:to_i),
title: study[:makale_adi],
authors: study[:yazar_adi],
number_of_authors: study[:yazar_sayisi],
country: study[:ulke],
city: study[:sehir],
journal: study[:dergi_adi],
language_of_publication: study[:yayin_dili_adi],
month: study[:ay],
year: study[:yil],
volume: study[:cilt],
issue: study[:sayi],
first_page: study[:ilk_sayfa],
last_page: study[:son_sayfa],
doi: study[:doi],
issn: study[:issn],
access_type: study[:erisim_turu].try(:to_i),
access_link: study[:erisim_linki],
discipline: study[:alan_bilgisi],
keyword: study[:anahtar_kelime],
special_issue: study[:ozel_sayi],
special_issue_name: study[:ozel_sayi_ad],
sponsored_by: study[:sponsor],
author_id: study[:yazar_id],
last_update: study[:guncelleme_tarihi],
status: study[:aktif_pasif].try(:to_i),
type: study[:makale_turu_id].try(:to_i),
incentive_point: study[:tesv_puan]
)
end
end
end
# rubocop:enable Metrics/BlockLength
end
end
40 changes: 40 additions & 0 deletions app/jobs/yoksis/certifications_create_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# frozen_string_literal: true

module Yoksis
class CertificationsCreateJob < ApplicationJob
queue_as :high

# slow operation
def perform(user)
@response = Services::Yoksis::V1::Ozgecmis.new(user.id_number.to_i).certifications
end

# callbacks
after_perform do |job|
user = job.arguments.first
if @response[:sonuc][:durum_kodu].eql?('1') && @response[:arastirma_liste].present?
response = [@response[:arastirma_liste]].flatten

response.each do |study|
user.certifications.create(
yoksis_id: study[:s_id].try(:to_i),
type: study[:tur_id].try(:to_i),
name: study[:adi],
content: study[:icerik],
location: study[:yer],
scope: study[:kapsam].try(:to_i),
duration: study[:sure],
start_date: study[:bastar],
end_date: study[:bittar],
title: study[:unvan_ad].try(:capitalize_all),
number_of_authors: study[:kisi_sayisi],
city_and_country: study[:ulke_sehir],
last_update: study[:guncelleme_tarihi],
incentive_point: study[:tesv_puan],
status: study[:aktif_pasif].try(:to_i)
)
end
end
end
end
end
41 changes: 41 additions & 0 deletions app/jobs/yoksis/projects_create_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# frozen_string_literal: true

module Yoksis
class ProjectsCreateJob < ApplicationJob
queue_as :high

# slow operation
def perform(user)
@response = Services::Yoksis::V1::Ozgecmis.new(user.id_number.to_i).projects
end

# callbacks
after_perform do |job|
user = job.arguments.first
if @response[:sonuc][:durum_kodu].eql?('1') && @response[:proje_listesi].present?
response = [@response[:proje_listesi]].flatten

response.each do |study|
user.projects.create(
yoksis_id: study[:proje_id].try(:to_i),
name: study[:proje_ad],
subject: study[:proje_konusu],
status: study[:proje_durumu_id].try(:to_i),
bastar: study[:bas_tar],
bittar: study[:bit_tar],
budget: study[:butce],
duty: study[:proje_konumu_ad],
type: study[:proje_turu_ad],
currency: study[:para_birimi_ad],
last_update: study[:guncelleme_tarihi],
activity: study[:aktif_pasif].try(:to_i),
scope: study[:kapsam].try(:to_i),
title: study[:unvan_ad],
unit_id: study[:kurum_id].try(:to_i),
incentive_point: study[:tesv_puan]
)
end
end
end
end
end
38 changes: 0 additions & 38 deletions app/jobs/yoksis_publications_create_job.rb

This file was deleted.

55 changes: 55 additions & 0 deletions app/models/academic_studies/article.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# frozen_string_literal: true

class Article < ApplicationRecord
self.inheritance_column = nil

# relations
belongs_to :user

# validations
validates :yoksis_id, presence: true
validates :title, presence: true

# enums
enum scope: { national: 0, international: 1 }
enum review: { reviewed: 0, not_reviewed: 1 }
enum access_type: { printed: 1, electronic: 2, printed_and_electronic: 3 }
enum status: { deleted: 0, active: 1 }

enum index: {
ssci: 5,
sci_expanded: 6,
ahci: 7,
field_indexes: 8,
well_established_indexes: 9,
sci: 40,
not_indexed: 42,
ebsco: 46,
index_islamicus: 47,
index_medicus: 48,
dental_index: 49,
engineering_index: 50,
compumath_index: 51,
education_index: 52,
australian_education_index: 53,
british_education_index: 54,
eric: 55,
esci: 56,
index_chemicus: 59,
turkish_index: 45
}

enum type: {
original_article: 1,
technical_note: 2,
commentary: 3,
case_report: 4,
letter_to_the_editor: 5,
abstract: 6,
book_review: 7,
research_note: 8,
export_report: 9,
review_article: 10,
short_article: 11
}
end
11 changes: 4 additions & 7 deletions app/models/academic_studies/certification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@ class Certification < ApplicationRecord
self.inheritance_column = nil

# relations
# TODO: belongs_to user or employee?
belongs_to :user

# # validations
# validates :article_title, presence: true
# validates :scope, presence: true
# validates :review, presence: true
# validates :index, presence: true
# validates :number_of_authors, presence: true
# validations
validates :yoksis_id, presence: true
validates :type, presence: true
validates :title, presence: true

# enums
enum type: {
Expand Down
22 changes: 22 additions & 0 deletions app/models/academic_studies/project.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# frozen_string_literal: true

class Project < ApplicationRecord
self.inheritance_column = nil

# relations
belongs_to :user

# validations
validates :yoksis_id, presence: true

# enums
enum status: {
completed: 1,
continuing: 2,
deferred: 3,
pending: 4
}

enum activity: { passive: 0, active: 1 }
enum scope: { national: 0, international: 1 }
end
2 changes: 2 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class User < ApplicationRecord

# academic studies
has_many :certifications, dependent: :destroy
has_many :articles, dependent: :destroy
has_many :projects, dependent: :destroy

# validations
validates :email, presence: true, uniqueness: true
Expand Down
Loading

0 comments on commit c06405c

Please sign in to comment.