Skip to content
This repository has been archived by the owner on Oct 26, 2023. It is now read-only.

Commit

Permalink
Merge pull request #101 from scalableinternetservices/main
Browse files Browse the repository at this point in the history
Update load testing 1
  • Loading branch information
YEthYuan authored Nov 18, 2022
2 parents f4d2fd6 + 989c6f2 commit 5ef2656
Show file tree
Hide file tree
Showing 29 changed files with 231 additions and 5,002 deletions.
3 changes: 0 additions & 3 deletions .idea/Hydra.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
FROM ruby:3.0

RUN curl -fsSL https://deb.nodesource.com/setup_16.x | bash -
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add \
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list \
&& apt-get update && apt-get install -y nodejs yarn --no-install-recommends \
Expand Down
41 changes: 15 additions & 26 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby "3.0.4"

gem 'bcrypt', '~> 3.1.11'
# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem "rails", "~> 7.0.4"

Expand All @@ -26,6 +26,20 @@ gem "turbo-rails"
# Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev]
gem "stimulus-rails"

#packages needed for going to the app server and run db:seed
gem "debug", platforms: %i[ mri mingw x64_mingw ]

gem "web-console"

gem "nokogiri"

gem "irb"

gem "reline"

gem "bindex"

gem "io-console"
# Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis]
# gem "kredis"

Expand All @@ -44,28 +58,3 @@ gem "bootsnap", require: false
# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
# gem "image_processing", "~> 1.2"

group :development, :test do
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
gem "debug", platforms: %i[ mri mingw x64_mingw ]
end

group :development do
# Use console on exceptions pages [https://github.com/rails/web-console]
gem "web-console"

# Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler]
# gem "rack-mini-profiler"

# Speed up commands on slow machines / big apps [https://github.com/rails/spring]
# gem "spring"


# appendix
gem "nokogiri"

gem 'bcrypt', '~> 3.1.11'

end


gem "shakapacker", "= 6.5"
22 changes: 7 additions & 15 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -110,22 +110,18 @@ GEM
net-protocol
net-protocol (0.1.3)
timeout
net-smtp (0.3.2)
net-smtp (0.3.3)
net-protocol
nio4r (2.5.8)
nokogiri (1.13.9-aarch64-linux)
racc (~> 1.4)
nokogiri (1.13.9-arm64-darwin)
racc (~> 1.4)
nokogiri (1.13.9-x86_64-linux)
racc (~> 1.4)
pg (1.1.4)
puma (5.6.5)
nio4r (~> 2.0)
racc (1.6.0)
rack (2.2.4)
rack-proxy (0.7.4)
rack
rack-test (2.0.2)
rack (>= 1.3)
rails (7.0.4)
Expand Down Expand Up @@ -159,20 +155,14 @@ GEM
io-console (~> 0.5)
sassc (2.4.0)
ffi (~> 1.9)
semantic_range (3.0.0)
shakapacker (6.5.0)
activesupport (>= 5.2)
rack-proxy (>= 0.6.1)
railties (>= 5.2)
semantic_range (>= 2.3.0)
sprockets (4.1.1)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.4.2)
actionpack (>= 5.2)
activesupport (>= 5.2)
sprockets (>= 3.0.0)
stimulus-rails (1.1.0)
stimulus-rails (1.1.1)
railties (>= 6.0.0)
thor (1.2.1)
timeout (0.3.0)
Expand All @@ -190,24 +180,26 @@ GEM
websocket-driver (0.7.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
zeitwerk (2.6.1)
zeitwerk (2.6.6)

PLATFORMS
aarch64-linux
arm64-darwin-21
x86_64-linux

DEPENDENCIES
bcrypt (~> 3.1.11)
bindex
bootsnap
bootstrap-sass (~> 3.4.1)
debug
importmap-rails
io-console
irb
nokogiri
pg (~> 1.1.0)
puma (~> 5.0)
rails (~> 7.0.4)
shakapacker (= 6.5)
reline
sprockets-rails
stimulus-rails
turbo-rails
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,11 @@ Hydra is a twitter-like social network.

### UI Mockups

## Steps to seed in app server
- Add `gem "web-console"` to your Gemfile and run `docker-compose run web bundle install` and `docker-compose run web yarn install` for the updated Gemfile.lock and yarn.lock.
- In config/environments/production.rb, add `config.web_console.development_only = false` to enable running web console on the app server.
- On AWS, find the IP address of the app server instance (go to EC2, then go inside your instance. Click "connect", go to "ssh client" tab, and find a line looking like `ssh -i "Hydra.pem" [email protected]`. Change the "root" to "ec2-user", then run it.
- Once on the app server, run `cd /var/app/current`, then `RAILS_ENV=production bundle exec rake db:seed`

## Steps to get your tsung log to local machine
- Assuming your tsung instance IP address is 34.222.195.237, from your local machine, run `rsync -auvL -e "ssh -i Hydra.pem" [email protected]:tsung_logs .` to get the logs.
6 changes: 3 additions & 3 deletions app/controllers/comments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ def create
@comment.comment = comment_params[:comment]
@comment.save
#@comment = @post.comments.create(comment: comment_params[])
redirect_to post_path(@post)
redirect_to post_path(@post), status: :ok
end

def destroy
@post = Post.find(params[:post_id])
@comment = @post.comments.find(params[:id])
@comment.destroy
redirect_to post_path(@post)
redirect_to post_path(@post), status: :see_other
end

def show
@post = Post.find(params[:post_id])
@comment = @post.comments.find(params[:id])
@comment.destroy
redirect_to post_path(@post)
redirect_to post_path(@post), status: :ok
end

private
Expand Down
25 changes: 23 additions & 2 deletions app/controllers/dashboard_controller.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,31 @@
class DashboardController < ApplicationController
include AccessControlConcern

@@post_limit = 5
@@rec_user_limit = 5
@@rec_group_limit =3

def index
@users = User.all
@groups = Group.all
@posts = Post.where(groupid: 0)
@limited_posts = Post.where(groupid: 0).limit(@@post_limit)
@rec_users = @users.limit(@@rec_user_limit)
@rec_groups = @groups.limit(@@rec_group_limit)
@post =Post.new
end
end

def show_more_posts
@@post_limit += 5
redirect_to "/dashboard"
end

def show_more_rec_users
@@rec_user_limit += 5
redirect_to "/dashboard"
end

def show_more_rec_groups
@@rec_group_limit += 3
redirect_to "/dashboard"
end
end
10 changes: 5 additions & 5 deletions app/controllers/group_users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ def join
flash[:notice] = "Oops, couldn't join at this point. Please try again later."
end

redirect_to "/groups/#{params[:gid]}"
redirect_to "/groups/#{params[:gid]}", status: :ok

end

def leave
GroupUser.where(user_id: current_user.id, group_id: params[:gid]).destroy_all

redirect_to "/groups/#{params[:gid]}"
redirect_to "/groups/#{params[:gid]}", status: :ok
end

def edit
Expand All @@ -37,7 +37,7 @@ def transferownership
@group_user2 = GroupUser.where(user_id: touid, group_id: params[:gid]) rescue not_found

if @group_user1.update(user_id: fromuid, group_id: params[:gid],permission:false) and @group_user2.update(user_id: touid, group_id: params[:gid],permission:true)
redirect_to @group
redirect_to @group, status: :ok
else
render :edit, status: :unprocessable_entity
end
Expand All @@ -59,7 +59,7 @@ def create
else
flash[:notice] = "Oops, cannot finish the operation. Please try again later."
end
redirect_to groupusers_path(:gid => gid)
redirect_to groupusers_path(:gid => gid), status: :ok
end

def destroy
Expand All @@ -68,7 +68,7 @@ def destroy

GroupUser.where(user_id: uid, group_id: gid).destroy_all

redirect_to groupusers_path(:gid => gid)
redirect_to groupusers_path(:gid => gid), status: :see_other
end

end
6 changes: 3 additions & 3 deletions app/controllers/groups_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ def create
user = current_user
rescue
flash.alert = "User information unknown. Did you login?"
redirect_to new_group_path and return
redirect_to new_group_path, status: :ok and return
end

@group = Group.new(groupname:group_params[:groupname],pic_url:group_params[:pic_url])
if @group.save
@group_user = GroupUser.new(group_id:@group.id,user_id:user.id,permission:true)
if @group_user.save
redirect_to group_path(@group)
redirect_to group_path(@group), status: :ok
else
render :new, status: :unprocessable_entity
end
Expand All @@ -46,7 +46,7 @@ def update
@group = Group.find(params[:id]) rescue not_found

if @group.update(groupname:group_params[:groupname],pic_url:group_params[:pic_url])
redirect_to @group
redirect_to @group, status: :ok
else
render :edit, status: :unprocessable_entity
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/messages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def new
def create
@message = Message.new message_params
if @message.save
redirect_to "/messages/#{@message.to_user_id}"
redirect_to "/messages/#{@message.to_user_id}", status: :ok
else
flash.alert = "couldnt save"
render :new, status: :unprocessable_entity
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/posts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class PostsController < ApplicationController

def index
# display posts which are public (has group_id:nil), or are part of a group the user belongs to
group_user = GroupUser.where(user_id:current_user.id)
group_user = logged_in? ? GroupUser.where(user_id:current_user.id) : []
arr = [nil]
for g_u in group_user do
arr.push(g_u.group_id)
Expand Down Expand Up @@ -47,7 +47,7 @@ def create

if @post.save
puts " ++DEBUG++ post_save?"
redirect_to post_path(@post)
redirect_to post_path(@post), status: :ok
else
puts " ++DEBUG++ new post fail"
render :new, status: :unprocessable_entity
Expand All @@ -62,7 +62,7 @@ def update
@post = Post.find(params[:id])

if @post.update(post_params)
redirect_to @post
redirect_to @post, status: :ok
else
render :edit, status: :unprocessable_entity
end
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ def create
flash[:notice] = "Login successfully."
logger.info "++DEBUG++ Login successfully."
logger.info " UID: #{session[:user_id]}, UName: #{session[:user_name]}"
redirect_to user
redirect_to user, status: :ok
else
# Create an error message
# puts " ++DEBUG++ login_fail?"
# puts "++DEBUG++ notice?"
redirect_to root_url, notice: 'Invalid username/password combination.'
redirect_to root_url, notice: 'Invalid username/password combination.', status: :unauthorized
# flash[:notice] = "Invalid username/password combination."
end
end

def destroy
log_out
redirect_to root_url, notice: 'Logged Out'
redirect_to root_url, notice: 'Logged Out', status: :see_other
end
end
Loading

0 comments on commit 5ef2656

Please sign in to comment.