Skip to content
Snippets Groups Projects
Commit 68472657 authored by Matheus Agio Nerone's avatar Matheus Agio Nerone
Browse files

merge with master

parents d2f4dd23 5391f890
No related branches found
No related tags found
No related merge requests found
Showing
with 185 additions and 72 deletions
before_script:
- bundle install
stages:
- test
- deploy
test:
script:
- bundle exec rake db:migrate RAILS_ENV=test
- bundle exec rake test RAILS_ENV=test
only:
- master
deploy:
only:
- master
script:
- bundle exec mina setup
- bundle exec mina deploy
......@@ -50,6 +50,10 @@ group :development, :test do
gem 'sqlite3'
end
group :test do
gem 'shoulda'
end
# authentication
gem 'devise'
......@@ -65,4 +69,6 @@ gem 'gruff'
gem 'chart-js-rails'
#depoyment
gem 'mina'
\ No newline at end of file
gem 'mina'
gem 'rubycritic', require: false
\ No newline at end of file
# Portal MEC
Breve descrição
[![build status](https://ci.gitlab.c3sl.ufpr.br/projects/19/status.png?ref=master)](https://ci.gitlab.c3sl.ufpr.br/projects/19?ref=master)
## Requirements
* ruby >=2.2
......
class Management::HighlightsController < ManagementController
def index
#rep = repository.for(:user)
db = OrientDb::HighlightRepository.new
@highlights = db.find_all
@highlights = highlight_repository.find_all
end
def show
end
def new
end
def delete
db = OrientDb::HighlightRepository.new
@highlights = db.find_all
@highlights = highlight_repository.find_all
end
def create
......@@ -29,9 +22,12 @@ class Management::HighlightsController < ManagementController
db = OrientDb::HighlightRepository.new
db.insert_data(@name,@url)
end
private
def highlight_repository
repository.for :highlight
end
end
class UniversitiesController < ApplicationController
def index
@universities = university_repository.find_all
@universities = university_repository.find_all || []
end
def show
......
module ActiveRecord
class CountryRepository
def find_all
end
def find_by_id(rid)
end
end
end
module ActiveRecord
class HighlightRepository
def find_all
end
def insert_data(name, url)
end
end
end
module ActiveRecord
class UniversityRepository
def find_all
end
def find_by_id(rid)
end
def has(rid)
end
end
end
class ActiveRecord::UserRepository
module ActiveRecord
class UserRepository
def all
User.all
end
def find_by_id(rid)
end
def create!(attributes={})
User.create! attributes
end
def author_of(rid)
end
def has(rid)
end
end
end
\ No newline at end of file
class OrientDb::Base
attr_reader :connection
def initialize(connection = nil)
@connection ||= Orientdb4r.client
@connection.connect :database => "teste", :user => "root", :password => "root"
def initialize(connection)
@connection = connection
rescue => e
puts "Error at connection"
puts e.message
puts e.backtrace
rescue => e
puts "Fail to connect OrientDb"
puts e.message
puts e.backtrace
end
end
......@@ -2,12 +2,12 @@ module OrientDb
class CountryRepository < Base
def find_all
return @connection.query "SELECT * FROM Country LIMIT 100 OFFSET 20"
return connection.query "SELECT * FROM Country LIMIT 100 OFFSET 20"
end
def find_by_id(rid)
res = @connection.query "SELECT title FROM Country WHERE @rid=##{rid}"
res[0]["has"] = @connection.query "SELECT expand(in) from (SELECT expand(out_has) FROM Country WHERE @rid=##{rid} LIMIT 30)"
res = connection.query "SELECT title FROM Country WHERE @rid=##{rid}"
res[0]["has"] = connection.query "SELECT expand(in) from (SELECT expand(out_has) FROM Country WHERE @rid=##{rid} LIMIT 30)"
res[0]
end
end
......
......@@ -6,11 +6,12 @@ module OrientDb
end
def find_all
return @connection.query "SELECT FROM Highlight"
rescue
return nil
return connection.query "SELECT FROM Highlight"
rescue
return nil
end
def insert_data (name,url)
return @connection.command "INSERT INTO Highlight (name,URL) VALUES ('#{name}','#{url}')"
rescue
......@@ -20,6 +21,7 @@ module OrientDb
def remove_data
#return @connection.command "DELETE FROM Highlight (name)"
end
end
......
......@@ -6,25 +6,25 @@ module OrientDb
end
def find_all
return @connection.query "SELECT FROM University LIMIT 100"
return connection.query "SELECT FROM University LIMIT 100"
end
def find_by_id(rid)
res = @connection.query "SELECT title FROM University WHERE @rid=##{rid}"
res = connection.query "SELECT title FROM University WHERE @rid=##{rid}"
localized = @connection.query "SELECT expand(out) from (SELECT expand(in_has) FROM University WHERE @rid=##{rid})"
localized = connection.query "SELECT expand(out) from (SELECT expand(in_has) FROM University WHERE @rid=##{rid})"
#aux = @connection.query "SELECT FROM University WHERE @rid=##{rid}"
comments = @connection.query "SELECT expand(in_commented) FROM University WHERE @rid=##{rid}"
#aux = connection.query "SELECT FROM University WHERE @rid=##{rid}"
comments = connection.query "SELECT expand(in_commented) FROM University WHERE @rid=##{rid}"
res[0]["comments"] = comments[0];
res[0]["localized_in"] = localized[0];
res[0]["comments"] = comments[0];
res[0]["localized_in"] = localized[0];
return res[0];
return res[0];
end
def has(rid)
@connection.query "SELECT expand(in) FROM (SELECT expand(out_has) FROM University WHERE @rid=#{rid})"
connection.query "SELECT expand(in) FROM (SELECT expand(out_has) FROM University WHERE @rid=#{rid})"
end
end
end
module OrientDb
class UserRepository < Base
def register(attributes={})
end
def find_by_id(rid)
return @connection.query "SELECT FROM User WHERE @rid=#{rid}"
return connection.query "SELECT FROM User WHERE @rid=#{rid}"
end
def author_of(rid)
return @connection.query "SELECT expand(in) FROM (SELECT expand(out_author_of) FROM User WHERE @rid=#{rid})"
return connection.query "SELECT expand(in) FROM (SELECT expand(out_author_of) FROM User WHERE @rid=#{rid})"
end
def has(rid)
return @connection.query "SELECT expand(in) FROM (SELECT expand(out_has) FROM User WHERE @rid=#{rid})"
return connection.query "SELECT expand(in) FROM (SELECT expand(out_has) FROM User WHERE @rid=#{rid})"
end
end
end
......@@ -17,4 +17,4 @@ production:
<<: *default
database: portalmec_production
username: portalmec
password: <%= ENV['PORTALMEC_DATABASE_PASSWORD'] %>
password: <%= ENV['PORTALMEC_DATABASE_PASSWORD'] %>
\ No newline at end of file
......@@ -4,22 +4,31 @@ require 'mina/git'
set :rails_env, 'production'
set :domain, 'portalmecdev.c3sl.ufpr.br'
set :deploy_to, "/home/portalmec/#{rails_env}"
set :app_path, "#{deploy_to}/#{current_path}"
set :domain, 'portalmecdev.c3sl.ufpr.br'
set :deploy_to, "/home/portalmec/#{rails_env}"
set :app_path, "#{deploy_to}/#{current_path}"
set :repository, 'git@gitlab.c3sl.ufpr.br:portalmec/portalmec.git'
set :branch, 'master'
set :user, 'portalmec'
set :branch, 'master'
set :user, 'portalmec'
task :environment do
#invoke :'rbenv:load'
end
task deploy: :environment do
deploy do
invoke :'git:clone'
execute 'bundle install --binstubs'
execute 'rake daily:stats'
queue %[echo "-----> Installing ruby gems"]
execute 'bundle install --deployment --without development test'
queue %[echo "-----> Migrating database"]
execute 'bundle exec rake db:migrate'
queue %[echo "-----> Populate database with db/seeds.rb"]
execute 'bundle exec rake db:seed'
queue %[echo "----------> Pre compiling assets"]
execute 'bundle exec rake assets:precompile'
end
end
require 'yaml'
orientdb_configs = YAML.load_file(Rails.root.join('config').to_s.concat('/orient_db.yml'))
env_config = orientdb_configs.fetch(Rails.env)
OrientDb::Config.host = env_config['host']
OrientDb::Config.database = env_config['database']
OrientDb::Config.user = env_config['username']
OrientDb::Config.password = env_config['password']
\ No newline at end of file
orientdb_instance = OrientDb::Client.instance
Repository::Environments.create :development do |repository|
repository.register :user, OrientDb::UserRepository.new
repository.register :university, OrientDb::UniversityRepository.new
repository.register :highlight, OrientDb::HighlightRepository.new
repository.register :country, OrientDb::CountryRepository.new
repository.register :user, OrientDb::UserRepository.new(orientdb_instance)
repository.register :university, OrientDb::UniversityRepository.new(orientdb_instance)
repository.register :highlight, OrientDb::HighlightRepository.new(orientdb_instance)
repository.register :country, OrientDb::CountryRepository.new(orientdb_instance)
end
Repository::Environments.create :test do |repository|
repository.register :user, OrientDb::UserRepository.new
repository.register :university, OrientDb::UniversityRepository.new
repository.register :highlight, OrientDb::HighlightRepository.new
repository.register :country, OrientDb::CountryRepository.new
repository.register :user, OrientDb::UserRepository.new(orientdb_instance)
repository.register :university, OrientDb::UniversityRepository.new(orientdb_instance)
repository.register :highlight, OrientDb::HighlightRepository.new(orientdb_instance)
repository.register :country, OrientDb::CountryRepository.new(orientdb_instance)
end
Repository::Environments.create :production do |repository|
repository.register :user, OrientDb::UserRepository.new
repository.register :university, OrientDb::UniversityRepository.new
repository.register :highlight, OrientDb::HighlightRepository.new
repository.register :country, OrientDb::CountryRepository.new
end
repository.register :user, OrientDb::UserRepository.new(orientdb_instance)
repository.register :university, OrientDb::UniversityRepository.new(orientdb_instance)
repository.register :highlight, OrientDb::HighlightRepository.new(orientdb_instance)
repository.register :country, OrientDb::CountryRepository.new(orientdb_instance)
end
\ No newline at end of file
development: &development
host: mecdb2.c3sl.ufpr.br
database: PortalMEC
username: admin
password: admin
test:
host: mecdb2.c3sl.ufpr.br
database: PortalMEC
username: admin
password: admin
production:
host: mecdb2.c3sl.ufpr.br
database: PortalMEC
username: admin
password: admin
\ No newline at end of file
class OrientDb::Client
@@client = nil
def self.instance
if !@@client.nil?
return @@client
end
begin
@@client = Orientdb4r.client :host => OrientDb::Config::host, :port => OrientDb::Config::port, :ssl => OrientDb::Config::ssl
@@client.connect(database: OrientDb::Config::database, user: OrientDb::Config::user, password: OrientDb::Config::password)
rescue Orientdb4r::UnauthorizedError => e
raise 'Wrong orient db credentials'
end
end
end
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment