-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
208 additions
and
22 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
class GetGroupSteamInfoJob < ApplicationJob | ||
def perform(options = {}) | ||
puts options.to_s | ||
puts self.queue_name | ||
# Do something later | ||
options[:format] = :xml | ||
if (uri = SteamId.steam_group_url(options)) | ||
begin | ||
record = SteamGroup.find_or_initialize_by(options) do |group| | ||
doc = Nokogiri::XML(Net::HTTP.get(uri)) | ||
logger.debug("Getting info for player #{uri.to_s}") | ||
group.groupID = doc.xpath('//memberList/groupDetails/groupID64').text.to_i | ||
group.groupName = doc.xpath('//memberList/groupDetails/groupName').text | ||
group.summary = doc.xpath('//memberList/groupDetails/summary').text | ||
group.avatarIcon = doc.xpath('//memberList/groupDetails/avatarIcon').text | ||
group.avatarMedium = doc.xpath('//memberList/groupDetails/avatarMedium').text | ||
group.avatarFull = doc.xpath('//memberList/groupDetails/avatarFull').text | ||
group.memberCount = doc.xpath('//memberList/memberCount').text | ||
end | ||
record.save | ||
rescue | ||
logger.warn("Failed to get group profile for #{options.to_s}") | ||
end | ||
|
||
end | ||
sleep 5 if self.queue_name != :urgent | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class Option < ApplicationRecord | ||
self.table_name = 'hlstats_Options' # MySQL table name | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class OptionChoise < ApplicationRecord | ||
self.table_name = 'hlstats_Option_Choises' # MySQL table name | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
class SteamGroup < ApplicationRecord | ||
def self.try_find_by(options = {}) | ||
group = SteamGroup.find_by(options) | ||
return group if group | ||
GetGroupSteamInfoJob.perform_later(options) | ||
return nil | ||
end | ||
|
||
def self.sitegroup | ||
self.try_find_by(groupURL: Option.find_by!(keyname: 'steamgroup').value) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<% if (group = SteamGroup.sitegroup) %> | ||
<ul class="nav navbar-nav"> | ||
<li> | ||
<a class="navbar-brand" style="padding-right: 5px;" href="/"><%= group.groupName %></a> | ||
</li> | ||
<li style="border-right: 1px solid #999"> | ||
<a style="margin: 0px; padding: 0px" href="<%= SteamId.steam_group_url(group) %>"> | ||
<img style="padding-right: 12px; padding-bottom: 5px; padding-top: 5px; padding-left: 0px; margin-left: 5px" class="navbar-brand" src="<%= group.avatarMedium %>"/> | ||
</a> | ||
</li> | ||
</ul> | ||
<% else %> | ||
<ul class="nav navbar-nav"> | ||
<li> | ||
<a class="navbar-brand" href="<%= players_path %>">Ayanami</a> | ||
</li> | ||
</ul> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<% if (group = SteamGroup.sitegroup) %> | ||
<ul class="nav navbar-nav navbar-right"> | ||
<li style="border-left: 1px solid #999"> | ||
<a style="margin: 0px; padding: 0px" href="<%= SteamId.steam_group_url(group) %>"> | ||
<img style="padding: 8px; margin-top: 0px; margin-bot: 0px; margin-left: 5px" class="navbar-brand" src="<%= asset_path('misc/steamgroup.png') %>"/> | ||
</a> | ||
</li> | ||
</ul> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddOptionSteamGroup < ActiveRecord::Migration[5.0] | ||
def change | ||
Option.create(keyname: 'steamgroup', value: 'reijii-dm', opttype: 2) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class CreateSteamGroups < ActiveRecord::Migration[5.0] | ||
def change | ||
create_table :steam_groups do |t| | ||
t.integer :groupID, index: true, limit: 8, null: false, unique: true | ||
t.string :groupName, index: true | ||
t.string :groupURL, index: true | ||
t.string :summary, limit: 2048 | ||
t.string :avatarIcon | ||
t.string :avatarMedium | ||
t.string :avatarFull | ||
t.string :memberCount, index: true | ||
t.timestamps | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html | ||
|
||
# This model initially had no columns defined. If you add columns to the | ||
# model remove the '{}' from the fixture names and add the columns immediately | ||
# below each fixture, per the syntax in the comments below | ||
# | ||
one: {} | ||
# column: value | ||
# | ||
two: {} | ||
# column: value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html | ||
|
||
# This model initially had no columns defined. If you add columns to the | ||
# model remove the '{}' from the fixture names and add the columns immediately | ||
# below each fixture, per the syntax in the comments below | ||
# | ||
one: {} | ||
# column: value | ||
# | ||
two: {} | ||
# column: value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html | ||
|
||
# This model initially had no columns defined. If you add columns to the | ||
# model remove the '{}' from the fixture names and add the columns immediately | ||
# below each fixture, per the syntax in the comments below | ||
# | ||
one: {} | ||
# column: value | ||
# | ||
two: {} | ||
# column: value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require 'test_helper' | ||
|
||
class GetGroupSteamInfoJobTest < ActiveJob::TestCase | ||
# test "the truth" do | ||
# assert true | ||
# end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require 'test_helper' | ||
|
||
class OptionChoiseTest < ActiveSupport::TestCase | ||
# test "the truth" do | ||
# assert true | ||
# end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require 'test_helper' | ||
|
||
class OptionTest < ActiveSupport::TestCase | ||
# test "the truth" do | ||
# assert true | ||
# end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require 'test_helper' | ||
|
||
class SteamGroupTest < ActiveSupport::TestCase | ||
# test "the truth" do | ||
# assert true | ||
# end | ||
end |