repo_name stringlengths 6 97 | path stringlengths 3 341 | text stringlengths 8 1.02M |
|---|---|---|
mitixx/abilitysheet | app/decorators/sheet_decorator.rb | # frozen_string_literal: true
class SheetDecorator < Draper::Decorator
delegate_all
def normal
Static::POWER[object.n_ability].first
end
def hard
Static::POWER[object.h_ability].first
end
def exh
Static::EXH_POWER[object.exh_ability].first
end
def updated_at
return '' unless object.... |
mitixx/abilitysheet | db/migrate/20191103084533_create_socials.rb | <filename>db/migrate/20191103084533_create_socials.rb
class CreateSocials < ActiveRecord::Migration[6.0]
def change
create_table :socials do |t|
t.string :provider
t.json :raw
t.string :secret
t.string :token
t.string :uid
t.bigint :user_id
t.timestamps
t.index %i... |
mitixx/abilitysheet | app/jobs/ist_sync_job.rb | <gh_stars>10-100
# frozen_string_literal: true
class IstSyncJob < ApplicationJob
queue_as :ist
def perform(user)
puts %(#{Time.zone.now} #{user.djname}[#{user.iidxid}] => ist sync start)
user.update_ist
puts %(#{Time.zone.now} #{user.djname}[#{user.iidxid}] => ist sync done)
end
end
|
mitixx/abilitysheet | app/decorators/score_decorator.rb | # frozen_string_literal: true
class ScoreDecorator < Draper::Decorator
delegate_all
def updated_at
return '' unless object.updated_at
object.updated_at.to_date.strftime
end
end
|
mitixx/abilitysheet | spec/models/user_follow_methods_spec.rb | <gh_stars>10-100
# frozen_string_literal: true
# == Schema Information
#
# Table name: follows
#
# id :integer not null, primary key
# user_id :integer
# target_user_id :integer
# created_at :datetime not null
# updated_at :datetime not null
#
describe User::Fo... |
mitixx/abilitysheet | app/models/concerns/user/list.rb | <reponame>mitixx/abilitysheet<gh_stars>10-100
# frozen_string_literal: true
module User::List
extend ActiveSupport::Concern
included do
class << self
def users_list(type, options = {})
__send__(type, options)
end
def recent200
query = <<~QUERY
SELECT
user... |
mitixx/abilitysheet | app/models/message.rb | <filename>app/models/message.rb
# frozen_string_literal: true
# == Schema Information
#
# Table name: messages
#
# id :bigint(8) not null, primary key
# body :string
# email :string
# ip :inet not null
# user_id :bigint(8)
# state :boolean default(FA... |
mitixx/abilitysheet | app/models/score.rb | <reponame>mitixx/abilitysheet<filename>app/models/score.rb<gh_stars>10-100
# frozen_string_literal: true
# == Schema Information
#
# Table name: scores
#
# id :bigint(8) not null, primary key
# state :integer default(7), not null
# score :integer
# bp :integer
# sheet_id ... |
mitixx/abilitysheet | spec/support/sheets_helper.rb | <gh_stars>10-100
# frozen_string_literal: true
module SheetsHelper
def sync_sheet
redis = Redis.new
ret = JSON.parse(redis.get('sheets'))
Sheet.insert_all!(ret['sheets'])
end
end
|
mitixx/abilitysheet | spec/systems/admin/users_spec.rb | <reponame>mitixx/abilitysheet
# frozen_string_literal: true
feature '管理用メッセージページ', type: :system do
background do
user = create(:user, id: 1, role: role)
login(User.find(user.id))
visit admin_users_path
end
describe '#index' do
context '管理者でない' do
let(:role) { User::Role::ADMIN - 1 }
... |
mitixx/abilitysheet | app/controllers/helps_controller.rb | <filename>app/controllers/helps_controller.rb<gh_stars>10-100
# frozen_string_literal: true
class HelpsController < ApplicationController
def ist; end
def support; end
def oauth; end
end
|
mitixx/abilitysheet | app/models/concerns/user/role.rb | <reponame>mitixx/abilitysheet
# frozen_string_literal: true
module User::Role
extend ActiveSupport::Concern
OWNER = 100
ADMIN = 75
MEMBER = 50
SPECIAL = 25
GENERAL = 0
included do
def owner?
OWNER <= role
end
def admin?
ADMIN <= role
end
def member?
MEMBER <= rol... |
mitixx/abilitysheet | app/controllers/admin/dashboards_controller.rb | # frozen_string_literal: true
class Admin::DashboardsController < ApplicationController
before_action :authenticate_user!
before_action :owner_user!
def index
@email = User.where.not(email: '').count
@message = Message.where(state: false).count
@user = User.where(current_sign_in_at: Date.today..Date... |
mitixx/abilitysheet | app/models/sheet.rb | # frozen_string_literal: true
# == Schema Information
#
# Table name: sheets
#
# id :bigint(8) not null, primary key
# title :string
# n_ability :integer
# h_ability :integer
# version :integer
# active :boolean default(TRUE), not null
# textage :string
# created... |
mitixx/abilitysheet | lib/slack/user_dispatcher.rb | <gh_stars>10-100
# frozen_string_literal: true
module Slack
class UserDispatcher
def self.new_register_notify(id)
user = User.find(id)
body = {
username: 'User Dispatcher',
attachments: [
{
color: :good,
title: '新規登録通知',
pretext: '_new reg... |
mitixx/abilitysheet | lib/tasks/sidekiq.rake | # frozen_string_literal: true
namespace :sidekiq do
desc 'Start sidekiq'
task start: :environment do
system "bundle exec sidekiq -C #{Rails.root.join('config', 'sidekiq.yml')}"
end
task :sidekiqctl, %i[name deadline_timeout] => :environment do |_t, args|
system "bundle exec sidekiqctl #{args[:name]} #... |
mitixx/abilitysheet | spec/systems/navbar/display_navbar_spec.rb | # frozen_string_literal: true
feature 'Navbarの閲覧可能コンテンツ', type: :system, js: true do
context 'ログインしていない場合' do
background do
visit root_path
end
scenario '管理項目が表示されていない' do
expect(page).to have_no_css('.admin-parent')
end
scenario 'ライバル欄が存在しない' do
expect(page).to have_no_content(... |
mitixx/abilitysheet | spec/factories/logs.rb | # frozen_string_literal: true
# == Schema Information
#
# Table name: logs
#
# id :bigint(8) not null, primary key
# user_id :bigint(8)
# sheet_id :bigint(8)
# pre_state :integer
# new_state :integer
# pre_score :integer
# new_score :integer
# pre_bp :integer
# new_... |
mitixx/abilitysheet | spec/systems/users/recent_spec.rb | <filename>spec/systems/users/recent_spec.rb<gh_stars>10-100
# frozen_string_literal: true
feature '最近更新したユーザ200人一覧', type: :system, js: true do
let(:iidxid) { '0000-0000' }
background do
create(:user, id: 1, iidxid: iidxid)
create(:sheet, id: 1)
create(:score, user_id: 1, sheet_id: 1, state: 5)
vis... |
mitixx/abilitysheet | config/schedule.rb | require 'dotenv'
Dotenv.overload
env :PATH, ENV['PATH']
set :output, ENV['CRON_LOG_FILE']
set :enviroment, ENV['RAILS_ENV'] || :production
set :job_template, "/bin/zsh -l -c ':job'"
# 毎日5時にDBのバックアップを取る
every 1.day, at: '5:00 am' do
rake 'db:data:s3_backup'
end
|
mitixx/abilitysheet | app/models/concerns/user/api.rb | <filename>app/models/concerns/user/api.rb
# frozen_string_literal: true
module User::Api
extend ActiveSupport::Concern
included do
def graph(start_month, end_month)
categories = logs.create_between(start_month, end_month).map { |b| b[0].to_s.slice(0, 7) }
column = logs.column(start_month, end_mont... |
mitixx/abilitysheet | app/controllers/admin/sheets_controller.rb | # frozen_string_literal: true
class Admin::SheetsController < ApplicationController
before_action :authenticate_user!
before_action :member_user!
before_action :load_sheet, except: %i[index new create]
def index
@q = Sheet.search(params[:q])
@q.sorts = ['id desc'] if @q.sorts.empty?
@sheets = @q.r... |
mitixx/abilitysheet | app/controllers/api/api_controller.rb | <reponame>mitixx/abilitysheet<filename>app/controllers/api/api_controller.rb
# frozen_string_literal: true
class UnauthorizedError < RuntimeError; end
class Forbidden < RuntimeError; end
class BadRequest < RuntimeError; end
class ServiceUnavailable < RuntimeError; end
class Api::ApiController < ActionController::A... |
mitixx/abilitysheet | db/migrate/20141115070915_create_logs.rb | <reponame>mitixx/abilitysheet<filename>db/migrate/20141115070915_create_logs.rb
class CreateLogs < ActiveRecord::Migration[5.1]
def change
create_table :logs do |t|
t.integer :user_id
t.integer :sheet_id
t.integer :pre_state
t.integer :new_state
t.integer :pre_score
t.integer :... |
mitixx/abilitysheet | spec/decorators/user_decorator_spec.rb | # frozen_string_literal: true
describe UserDecorator do
let(:instance) { described_class.new(user) }
let(:user) { create(:user, created_at: Time.new(2017, 3, 3)) }
describe '#pref' do
it 'returns pref of its pref' do
expect(instance.pref).to eq('海外')
end
end
describe '#grade' do
it 'retu... |
mitixx/abilitysheet | app/helpers/select_helper.rb | <reponame>mitixx/abilitysheet<gh_stars>10-100
# frozen_string_literal: true
module SelectHelper
def check_boxes_prefs
User::Static::PREF.map do |pref|
User.new(pref: User::Static::PREF.index(pref))
end
end
def check_boxes_n_abilities
Static::POWER.map do |_, index|
Sheet.new(n_ability: i... |
mitixx/abilitysheet | spec/support/session_helper.rb | <reponame>mitixx/abilitysheet
# frozen_string_literal: true
module SessionHelpers
def login(user, run_callbacks: false)
login_as(user, scope: :user, run_callbacks: run_callbacks)
end
end
|
mitixx/abilitysheet | app/controllers/admin/socials_controller.rb | # frozen_string_literal: true
class Admin::SocialsController < ApplicationController
before_action :authenticate_user!
before_action :admin_user!
def index
@q = Social.ransack(params[:q])
@q.sorts = ['id desc'] if @q.sorts.empty?
@socials = @q.result.page(params[:page])
end
def show
@social... |
mitixx/abilitysheet | spec/requests/sheets_spec.rb | # frozen_string_literal: true
describe Api::V1::SheetsController, type: :request do
include_context 'api'
describe 'GET /api/v1/sheets' do
before { create(:sheet, id: 1, active: true) }
let(:url) { '/api/v1/sheets' }
let(:method) { 'get' }
let(:result) do
{
sheets: [{
id: 1... |
mitixx/abilitysheet | lib/twitter_dispatcher.rb | # frozen_string_literal: true
class TwitterDispatcher
def initialize
tokens = ENV['TWITTER_TOKENS'].split(',')
@client = Twitter::REST::Client.new do |config|
config.consumer_key = tokens[0]
config.consumer_secret = tokens[1]
config.access_token = tokens[2]
config.ac... |
mitixx/abilitysheet | lib/irt/sync.rb | <filename>lib/irt/sync.rb
# frozen_string_literal: true
require 'twitter_dispatcher'
module Irt
class Sync
def self.run
hash = fetch
Ability.sync(hash)
twitter = TwitterDispatcher.new
twitter.tweet('地力値表を更新しました')
end
def self.fetch
# token = ENV['IRT_TOKEN']
uri ... |
mitixx/abilitysheet | lib/tasks/auto_generate_diagram.rake | # frozen_string_literal: true
if Rails.env.development?
RailsERD.load_tasks
namespace :erd do
task :load_models do
say 'Loading application environment...'
Rake::Task[:environment].invoke
say 'Loading code in search of Active Record models...'
Zeitwerk::Loader.eager_load_all
end
... |
mitixx/abilitysheet | app/mailers/notice_mail.rb | # frozen_string_literal: true
class NoticeMail < ActionMailer::Base
default from: '<EMAIL>'
def new_register(user_id)
@user = User.find_by(id: user_id)
@count = User.select(:id).count
mail to: '<EMAIL>'
mail subject: '新規登録者'
end
def form_deal(email, subject, body)
@body = "#{body}\r\n"
... |
mitixx/abilitysheet | app/controllers/google_controller.rb | <gh_stars>10-100
# frozen_string_literal: true
class GoogleController < ApplicationController
before_action :authenticate_user!
def destroy
current_user.socials.find_by(provider: 'google_oauth2').destroy!
redirect_to edit_user_registration_path
end
end
|
mitixx/abilitysheet | app/controllers/users/registrations_controller.rb | <reponame>mitixx/abilitysheet<filename>app/controllers/users/registrations_controller.rb
# frozen_string_literal: true
require 'slack/user_dispatcher'
require 'ist_client'
class Users::RegistrationsController < Devise::RegistrationsController
def create
pre_user = User.select(:id).count
super
after_user... |
mitixx/abilitysheet | spec/systems/rivals/rival_spec.rb | <reponame>mitixx/abilitysheet
# frozen_string_literal: true
feature 'ライバル情報', type: :system do
given(:user) { create(:user, id: 1) }
background do
user2 = create(:user, id: 2, djname: 'RIVAL', iidxid: '1111-1111', username: 'rival')
user.follow(user2.iidxid)
login(user)
end
scenario 'プロフィールページへのリン... |
mitixx/abilitysheet | lib/slack/message_dispatcher.rb | <filename>lib/slack/message_dispatcher.rb<gh_stars>10-100
# frozen_string_literal: true
module Slack
class MessageDispatcher
def self.send(id)
message = Message.find(id)
user = message.user
user_information = nil
user_information = "#{user.djname}[#{user.iidxid}]" if user
admin_mess... |
mitixx/abilitysheet | lib/slack/gcs_dispatcher.rb | # frozen_string_literal: true
module Slack
class GcsDispatcher
def self.success(env)
body = {
icon_emoji: ':gcp_gcs:',
username: 'GCS Dispatcher',
attachments: [
{
color: :good,
title: 'backup success',
pretext: '_GCP GCS_',
... |
mitixx/abilitysheet | spec/factories/sheets.rb | <gh_stars>10-100
# frozen_string_literal: true
# == Schema Information
#
# Table name: sheets
#
# id :bigint(8) not null, primary key
# title :string
# n_ability :integer
# h_ability :integer
# version :integer
# active :boolean default(TRUE), not null
# textage :... |
mitixx/abilitysheet | app/controllers/api/v1/logs_controller.rb | # frozen_string_literal: true
class Api::V1::LogsController < Api::V1::BaseController
before_action :load_user!
def full_calendar
start_date = "#{params[:year]}-#{params[:month]}-01".to_date
end_date = start_date + 1.month
logs = @user.logs.where(created_date: start_date..end_date)
render json: { ... |
mitixx/abilitysheet | spec/factories/messages.rb | # frozen_string_literal: true
# == Schema Information
#
# Table name: messages
#
# id :bigint(8) not null, primary key
# body :string
# email :string
# ip :inet not null
# user_id :bigint(8)
# state :boolean default(FALSE)
# created_at :datetime ... |
mitixx/abilitysheet | spec/systems/admin/dashboards_spec.rb | # frozen_string_literal: true
feature 'ダッシュボードの閲覧', type: :system do
background do
create(:user, id: 1, role: 100)
login(User.find(1))
visit admin_dashboards_path
end
it 'email登録人数が見れる' do
expect(page).to have_content('email登録人数')
end
it '未読メッセージが見れる' do
expect(page).to have_content('未読メ... |
mitixx/abilitysheet | db/migrate/20150105172226_create_abilities.rb | <filename>db/migrate/20150105172226_create_abilities.rb
class CreateAbilities < ActiveRecord::Migration[5.1]
def change
create_table :abilities do |t|
t.integer :sheet_id
t.float :fc
t.float :exh
t.float :h
t.float :c
t.float :e
t.float :aaa
t.timestamps null: fals... |
mitixx/abilitysheet | app/decorators/message_decorator.rb | # frozen_string_literal: true
class MessageDecorator < Draper::Decorator
delegate_all
def user_name
return '匿名' unless object.user_id
user = User.find_by(id: object.user_id)
"#{user.djname}[#{user.iidxid}]"
end
def created_at
object.created_at.strftime('%Y/%m/%d %H:%M')
end
def status
... |
mitixx/abilitysheet | app/decorators/mail_decorator.rb | # frozen_string_literal: true
class MailDecorator < Draper::Decorator
delegate_all
end
|
mitixx/abilitysheet | app/models/concerns/user/follow_methods.rb | # frozen_string_literal: true
module User::FollowMethods
extend ActiveSupport::Concern
included do
def change_follow(target_user)
following?(target_user.id) ? unfollow(target_user.iidxid) : follow(target_user.iidxid)
end
def following?(user_id)
follow_users.pluck(:id).include?(user_id)
... |
mitixx/abilitysheet | spec/factories/scores.rb | <reponame>mitixx/abilitysheet
# frozen_string_literal: true
# == Schema Information
#
# Table name: scores
#
# id :bigint(8) not null, primary key
# state :integer default(7), not null
# score :integer
# bp :integer
# sheet_id :bigint(8) not null
# user_id :b... |
mitixx/abilitysheet | spec/support/redis_helper.rb | # frozen_string_literal: true
module RedisHelper
def self.load_sheets_data
redis = Redis.new
uri = URI.parse('https://sp12.iidx.app/api/v1/sheets/list')
sheets = JSON.parse(Net::HTTP.get(uri))
redis.set('sheets', sheets.to_json)
rescue Errno::ECONNREFUSED
puts '本番サーバが稼働していません'
redis.set('sh... |
mitixx/abilitysheet | spec/systems/logs/show_logs_spec.rb | # frozen_string_literal: true
feature 'ログの詳細画面', type: :system, js: true do
background do
@user = create(:user, id: 1, iidxid: '1234-5678', role: User::Role::GENERAL)
create(:sheet, id: 1, title: 'log spec1')
create(:sheet, id: 2, title: 'log spec2')
create(:score, sheet_id: 1, state: 6, user_id: 1)
... |
mitixx/abilitysheet | app/models/follow.rb | <filename>app/models/follow.rb
# frozen_string_literal: true
# == Schema Information
#
# Table name: follows
#
# id :bigint(8) not null, primary key
# user_id :bigint(8)
# target_user_id :bigint(8)
# created_at :datetime not null
# updated_at :datetime not null
#
... |
mitixx/abilitysheet | app/controllers/users_controller.rb | <filename>app/controllers/users_controller.rb
# frozen_string_literal: true
class UsersController < ApplicationController
def index
@title = '最近更新した200人'
if params[:query]&.present?
@users = User.where(iidxid: params[:query])
@scores_map = User.users_list(:rivals, @users)
else
@users = ... |
mitixx/abilitysheet | app/models/concerns/sheet/api.rb | # frozen_string_literal: true
module Sheet::Api
extend ActiveSupport::Concern
included do
def schema
{
id: id,
title: title,
n_clear: n_ability,
hard: h_ability,
exh: exh_ability,
n_clear_string: Static::POWER[n_ability][0],
hard_string: Static::PO... |
mitixx/abilitysheet | spec/systems/sheets/clear_sheet_spec.rb | <reponame>mitixx/abilitysheet<filename>spec/systems/sheets/clear_sheet_spec.rb
# frozen_string_literal: true
feature 'ノマゲ地力表', type: :system, js: true do
given(:user) { create(:user, id: 1) }
background do
visit sheet_path(iidxid: user.iidxid, type: 'clear')
end
scenario '存在しないユーザへのアクセス' do
visit shee... |
mitixx/abilitysheet | db/migrate/20180226135142_add_exh_tosheet.rb | <filename>db/migrate/20180226135142_add_exh_tosheet.rb
class AddExhTosheet < ActiveRecord::Migration[5.1]
def change
add_column :sheets, :exh_ability, :integer
end
end
|
mitixx/abilitysheet | spec/systems/admin/messages_spec.rb | # frozen_string_literal: true
feature '管理用メッセージページ', type: :system do
background do
create(:user, id: 1, role: role)
login(User.find(1))
visit admin_messages_path
end
describe '#index' do
context '管理者でない' do
let(:role) { User::Role::ADMIN - 1 }
scenario 'トップページにリダイレクトされる' do
... |
mitixx/abilitysheet | app/models/ability.rb | # frozen_string_literal: true
# == Schema Information
#
# Table name: abilities
#
# id :bigint(8) not null, primary key
# sheet_id :bigint(8)
# fc :float
# exh :float
# h :float
# c :float
# e :float
# aaa :float
# created_at :datetime ... |
mitixx/abilitysheet | spec/systems/messages_spec.rb | <filename>spec/systems/messages_spec.rb
# frozen_string_literal: true
feature '連絡フォーム', type: :system do
given(:user) { create(:user, id: 1) }
background do
create(:score, user_id: 1, sheet_id: 1)
visit new_message_path
end
describe 'new' do
context 'ログイン時' do
background do
login(use... |
mitixx/abilitysheet | config/initializers/rack.rb | <reponame>mitixx/abilitysheet
Rack::Utils.multipart_part_limit = 0
|
mitixx/abilitysheet | app/controllers/api/v1/messages_controller.rb | <gh_stars>10-100
# frozen_string_literal: true
class Api::V1::MessagesController < Api::V1::BaseController
def index
authenticate_member!
render json: { num: Message.where(state: false).count }
end
end
|
mitixx/abilitysheet | spec/models/user_spec.rb | <reponame>mitixx/abilitysheet
# frozen_string_literal: true
# == Schema Information
#
# Table name: users
#
# id :bigint(8) not null, primary key
# email :string default(""), not null
# username :string default(""), not null
# encrypted_... |
mitixx/abilitysheet | db/migrate/20141111002700_create_scores.rb | <filename>db/migrate/20141111002700_create_scores.rb<gh_stars>10-100
class CreateScores < ActiveRecord::Migration[5.1]
def change
create_table :scores do |t|
t.integer :state, null: false, default: 7
t.integer :score
t.integer :bp
t.integer :sheet_id, null: false
t.integer :user_id, ... |
mitixx/abilitysheet | spec/systems/session/sign_up_spec.rb | # frozen_string_literal: true
feature 'sign up', type: :system do
background do
visit new_user_registration_path
sync_sheet
allow(Slack::UserDispatcher).to receive(:new_register_notify).and_return(true)
end
def input_sign_up_form(iidxid)
fill_in 'user_email', with: '<EMAIL>'
fill_in 'user_use... |
mitixx/abilitysheet | spec/systems/session/login_spec.rb | # frozen_string_literal: true
feature 'ログイン処理', type: :system do
background do
create(:user, id: 1)
visit new_user_session_path
end
given(:user) { User.find_by(id: 1) }
context 'iidxidでログイン' do
scenario 'response ok' do
fill_in 'user_login', with: user.iidxid
fill_in 'user_password', wi... |
mitixx/abilitysheet | spec/systems/sheets/hard_sheet_spec.rb | <filename>spec/systems/sheets/hard_sheet_spec.rb
# frozen_string_literal: true
feature 'ハード地力表', type: :system, js: true do
given(:user) { create(:user, id: 1) }
background do
visit sheet_path(iidxid: user.iidxid, type: 'hard')
end
scenario '存在しないユーザへのアクセス' do
visit sheet_path(iidxid: '1111-1111', typ... |
mitixx/abilitysheet | app/controllers/api/v1/abilities_controller.rb | # frozen_string_literal: true
class Api::V1::AbilitiesController < Api::V1::BaseController
def index
power = params[:type] == 'exh' ? Static::EXH_POWER : Static::POWER
render json: {
abilities: power.map do |elem|
{ key: elem[1], value: elem[0] }
end
}
end
def create
unless p... |
mitixx/abilitysheet | app/controllers/users/passwords_controller.rb | # frozen_string_literal: true
class Users::PasswordsController < Devise::PasswordsController
def create
self.resource = resource_class.send_reset_password_instructions(resource_params)
yield resource if block_given?
if successfully_sent?(resource)
flash[:notice] = '再発行メールを送信しました、数分ほどかかります'
f... |
mitixx/abilitysheet | app/models/concerns/static.rb | <reponame>mitixx/abilitysheet<gh_stars>10-100
# frozen_string_literal: true
module Static
LAMP = %w[FC EXH H C E A F N].freeze
LAMP_HASH = LAMP.map.with_index(0) { |e, i| [e, i] }.to_h
LAMP_OFFICIAL = [
'FULLCOMBO CLEAR',
'EX HARD CLEAR',
'HARD CLEAR',
'CLEAR',
'EASY CLEAR',
'ASSIST CLEAR... |
mitixx/abilitysheet | app/controllers/welcomes_controller.rb | # frozen_string_literal: true
class WelcomesController < ApplicationController
def index
@title = 'TOP'
end
end
|
mitixx/abilitysheet | spec/spec_helper.rb | # frozen_string_literal: true
require 'simplecov'
SimpleCov.start
require 'capybara/rspec'
require 'sidekiq/testing'
require 'rspec/retry'
RSpec.configure do |config|
config.expect_with :rspec do |expectations|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
end
config.mock_with :rs... |
mitixx/abilitysheet | spec/models/sheet_spec.rb | <reponame>mitixx/abilitysheet<gh_stars>10-100
# frozen_string_literal: true
# == Schema Information
#
# Table name: sheets
#
# id :bigint(8) not null, primary key
# title :string
# n_ability :integer
# h_ability :integer
# version :integer
# active :boolean default(TRU... |
mitixx/abilitysheet | app/controllers/api/v1/maintenance_controller.rb | # frozen_string_literal: true
class Api::V1::MaintenanceController < Api::V1::BaseController
before_action :authenticate_slack!
def change
mode = params[:text].split('メンテナンス ')[1]
mode == '開始' ? system('touch /var/tmp/abilitysheet_maintenance.txt') : system('rm /var/tmp/abilitysheet_maintenance.txt')
... |
mitixx/abilitysheet | config/application.rb | <reponame>mitixx/abilitysheet
require_relative "boot"
require_relative '../lib/rails_log_silencer'
require "rails/all"
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module Abilitysheet
class Application < Rails::Appl... |
mitixx/abilitysheet | spec/systems/recommends/recommends_spec.rb | # frozen_string_literal: true
feature '地力値表', type: :system, js: true do
given(:user) { create(:user, id: 1) }
background do
create(:score, user_id: 1, sheet_id: 1)
visit recommends_path
end
context 'ログイン時' do
background do
login(user)
visit recommends_path
end
scenario '地力値表が表... |
mitixx/abilitysheet | app/models/concerns/graph.rb | <filename>app/models/concerns/graph.rb<gh_stars>10-100
# frozen_string_literal: true
module Graph
extend ActiveSupport::Concern
included do
def self.column(start_month, end_month)
between = create_between(start_month, end_month)
category = []
fc_count = []
exh_count = []
h_count ... |
mitixx/abilitysheet | db/migrate/20141116172112_create_messages.rb | class CreateMessages < ActiveRecord::Migration[5.1]
def change
create_table :messages do |t|
t.string :body
t.string :email
t.inet :ip, null: false
t.integer :user_id
t.boolean :state, default: false
t.timestamps null: false
end
add_index :messages, :user_id
end
end
|
mitixx/abilitysheet | app/models/concerns/user/static.rb | # frozen_string_literal: true
module User::Static
PREF = %w[
海外
北海道 青森県 岩手県 宮城県
秋田県 山形県 福島県 茨城県
栃木県 群馬県 埼玉県 千葉県
東京都 神奈川県 新潟県 富山県
石川県 福井県 山梨県 長野県
岐阜県 静岡県 愛知県 三重県
滋賀県 京都府 大阪府 兵庫県
奈良県 和歌山県 鳥取県 島根県
岡山県 広島県 山口県 徳島県
香川県 愛媛県 高知県 福岡県
佐賀県 長崎県 熊本県 大分県
宮崎県 鹿児島県 沖縄県
香港 韓国 ... |
mitixx/abilitysheet | lib/tasks/auto_annotate_and_erd.rake | # frozen_string_literal: true
namespace :db do
task migrate: :environment do
Rake::Task['db:migrate'].invoke
`rails erd annotate_models` if Rails.env.development?
end
end
|
mitixx/abilitysheet | spec/support/api_helper.rb | <reponame>mitixx/abilitysheet<gh_stars>10-100
# frozen_string_literal: true
require 'json_expressions/rspec'
module ApiHelper
include Rack::Test::Methods
def domain
''
end
def default_rack_env
{ 'HTTP_HOST' => domain }
end
shared_context 'api' do
subject do
case method
when 'get... |
mitixx/abilitysheet | spec/systems/sheets/power_sheet_spec.rb | <reponame>mitixx/abilitysheet<gh_stars>10-100
# frozen_string_literal: true
feature '地力値表', type: :system do
given(:user) { create(:user, id: 1) }
background do
visit sheet_path(iidxid: user.iidxid, type: 'power')
end
scenario '存在しないユーザへのアクセス' do
visit sheet_path(iidxid: '1111-1111', type: 'power')
... |
mitixx/abilitysheet | db/migrate/20150112192519_create_sheets.rb | <filename>db/migrate/20150112192519_create_sheets.rb<gh_stars>10-100
class CreateSheets < ActiveRecord::Migration[5.1]
def change
create_table :sheets do |t|
t.string :title
t.integer :n_ability
t.integer :h_ability
t.integer :version
t.boolean :active, null: false, default: true
... |
mitixx/abilitysheet | app/controllers/logs_controller.rb | <gh_stars>10-100
# frozen_string_literal: true
require 'ist_client'
class LogsController < ApplicationController
before_action :load_user, only: %i[sheet list show]
before_action :authenticate_user!, only: %i[edit update ist destroy]
def edit
@log = current_user.logs.find(params[:id])
render :show_moda... |
mitixx/abilitysheet | config/initializers/session_store.rb | <reponame>mitixx/abilitysheet<gh_stars>10-100
# frozen_string_literal: true
# Be sure to restart your server when you modify this file.
Rails.application.config.session_store :cookie_store, key: '_abilitysheet_session', secure: Rails.env.production? || Rails.env.staging?
|
mitixx/abilitysheet | app/controllers/users/omniauth_callbacks_controller.rb | # frozen_string_literal: true
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
before_action :authenticate_user!
def google_oauth2
callback_from :google_oauth2
end
private
def auth
request.env['omniauth.auth']
end
def callback_from(provider)
@provider = provi... |
mitixx/abilitysheet | db/migrate/20191010113324_add_score_index.rb | class AddScoreIndex < ActiveRecord::Migration[6.0]
def change
add_index :scores, %i[user_id version updated_at]
end
end
|
mitixx/abilitysheet | app/controllers/api/v1/scores_controller.rb | <gh_stars>10-100
# frozen_string_literal: true
class Api::V1::ScoresController < Api::V1::BaseController
before_action :load_user
before_action :authenticate!, only: :update
def show
render json: { scores: @user.scores.is_active.is_current_version.preload(:sheet).map(&:schema) }
end
def detail
shee... |
mitixx/abilitysheet | app/controllers/application_controller.rb | # frozen_string_literal: true
class ApplicationController < ActionController::Base
before_action :set_raven_context
# protect_from_forgery with: :exception
# refs: https://github.com/rails/rails/issues/24257
# refs: https://github.com/plataformatec/devise/pull/4033/files
protect_from_forgery prepend: true
... |
mitixx/abilitysheet | spec/requests/users_spec.rb | # frozen_string_literal: true
describe Api::V1::UsersController, type: :request do
include_context 'api'
describe 'GET /api/v1/users/me' do
before { create(:user) }
describe 'ユーザのログイン状態を返す' do
let(:url) { '/api/v1/users/me' }
let(:method) { 'get' }
context 'ログインしていない場合' do
let(:r... |
mitixx/abilitysheet | app/controllers/admin/mails_controller.rb | # frozen_string_literal: true
class Admin::MailsController < ApplicationController
before_action :authenticate_user!
before_action :admin_user!
def new; end
def create
NoticeMail.form_deal(params[:email_address], params[:subject], params[:body]).deliver
flash[:notice] = %(メールを送信しました)
redirect_to ... |
mitixx/abilitysheet | spec/factories/users.rb | <gh_stars>10-100
# frozen_string_literal: true
# == Schema Information
#
# Table name: users
#
# id :bigint(8) not null, primary key
# email :string default(""), not null
# username :string default(""), not null
# encrypted_password ... |
mitixx/abilitysheet | config/initializers/sidekiq.rb | redis_params = { url: ENV['REDIS_URL'] }
Sidekiq.configure_server do |config|
config.redis = redis_params
end
Sidekiq.configure_client do |config|
config.redis = redis_params
end
Sidekiq.default_worker_options = { retry: 0 }
schedule_file = 'config/schedule.yml'
if File.exist?(schedule_file) && Sidekiq.server?
... |
mitixx/abilitysheet | app/services/clearing_transition_table_service.rb | <reponame>mitixx/abilitysheet
# frozen_string_literal: true
class ClearingTransitionTableService < ApplicationService
def initialize(user)
super()
@user_id = user.id
end
def execute
hash = {}
sheets = Sheet.active.joins(:logs).select('sheets.title, logs.new_state, logs.created_date').where('logs... |
mitixx/abilitysheet | spec/models/user_ist_spec.rb | # frozen_string_literal: true
# == Schema Information
#
# Table name: follows
#
# id :integer not null, primary key
# user_id :integer
# target_user_id :integer
# created_at :datetime not null
# updated_at :datetime not null
#
require 'ist_client'
describe Use... |
mitixx/abilitysheet | app/controllers/api/v1/statics_controller.rb | <reponame>mitixx/abilitysheet
# frozen_string_literal: true
class Api::V1::StaticsController < Api::V1::BaseController
def index
render json: {
grade: User::Static::GRADE.zip(User::Static::GRADE_COLOR).map { |grade, grade_color| { grade => grade_color } },
pref: User::Static::PREF
}
end
end
|
mitixx/abilitysheet | lib/ist_client.rb | # frozen_string_literal: true
class IstClient
class NotFoundUser < StandardError; end
def initialize(url = 'https://score.iidx.app')
@url = url
end
def get_scores(iidxid, params)
endpoint = @url + "/api/v1/scores/#{iidxid}?" + params.to_query
body = Net::HTTP.get(URI.parse(endpoint))
JSON.par... |
mitixx/abilitysheet | app/controllers/api/v1/health_check_controller.rb | <reponame>mitixx/abilitysheet<filename>app/controllers/api/v1/health_check_controller.rb<gh_stars>10-100
# frozen_string_literal: true
class Api::V1::HealthCheckController < Api::V1::BaseController
def index
ActiveRecord::Base.connection.execute('select 1')
client = Redis.new(url: ENV['REDIS_URL'])
clien... |
mitixx/abilitysheet | db/migrate/20151219233629_create_follows.rb | class CreateFollows < ActiveRecord::Migration[5.1]
def change
create_table :follows do |t|
t.integer :user_id
t.integer :target_user_id
t.timestamps null: false
end
add_index :follows, [:user_id, :target_user_id], unique: true
end
end
|
mitixx/abilitysheet | config/initializers/sentry.rb | # frozen_string_literal: true
logger = ::Logger.new('log/raven.log')
logger.level = ::Logger::DEBUG
Raven.configure do |config|
config.logger = logger
config.dsn = ENV['SENTRY_DSN']
config.environments = %w(staging production)
config.current_environment = Rails.env
config.release = ENV.fetch('RELEASE', 'vx.... |
mitixx/abilitysheet | spec/requests/logs_spec.rb | # frozen_string_literal: true
describe Api::V1::LogsController, type: :request do
include_context 'api'
describe 'GET /api/v1/logs/graph/1111-1111/2016/2' do
before do
create(:user, iidxid: '1111-1111', id: 1)
end
let(:url) { '/api/v1/logs/graph/1111-1111/2016/2' }
let(:method) { 'get' }
... |
mitixx/abilitysheet | spec/models/social_spec.rb | <gh_stars>10-100
# frozen_string_literal: true
# == Schema Information
#
# Table name: socials
#
# id :bigint(8) not null, primary key
# provider :string
# raw :json
# secret :string
# token :string
# uid :string
# user_id :bigint(8)
# created_at :datetime not... |
mitixx/abilitysheet | spec/systems/users/show_spec.rb | # frozen_string_literal: true
feature 'プロフィールページ', type: :system, js: true do
given(:user) { create(:user, id: 1, djname: 'PROF', iidxid: '1111-1111', pref: 0, grade: 4, created_at: '2016-03-06') }
context '非ログイン時' do
background do
create(:score, user_id: 1, sheet_id: 1)
visit user_path(user.iidxid... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.