feat: add ffxiv-eureka.com import function
This commit is contained in:
parent
a28484d0e0
commit
e2c99cbc6a
9 changed files with 131 additions and 1 deletions
|
@ -12,6 +12,52 @@ class InstanceController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def create_from_fe
|
||||
info = create_from_fe_params
|
||||
# Make sure we have the correct string
|
||||
if info.start_with?("NMs on cooldown:")
|
||||
str = info.sub("NMs on cooldown:", "").strip
|
||||
split = str.split(" → ")
|
||||
ts = Time.now.utc
|
||||
zone = nil
|
||||
results = split.map do |s|
|
||||
# Grab the name and time until it can be repopped
|
||||
name, time = s.split("(")
|
||||
name = name.strip
|
||||
time = time.gsub(/\D/, "") # remove anything but digits
|
||||
|
||||
# Try and guess the zone based on names
|
||||
if zone.nil?
|
||||
if APP_DATA[:anemos][:nms].any? { |nm| nm[:nick] == name }
|
||||
zone = "anemos"
|
||||
elsif APP_DATA[:pagos][:nms].any? { |nm| nm[:nick] == name }
|
||||
zone = "pagos"
|
||||
elsif APP_DATA[:pyros][:nms].any? { |nm| nm[:nick] == name }
|
||||
zone = "pyros"
|
||||
elsif APP_DATA[:hydatos][:nms].any? { |nm| nm[:nick] == name }
|
||||
zone = "hydatos"
|
||||
end
|
||||
end
|
||||
|
||||
{
|
||||
name: APP_DATA[zone.to_sym][:nms].find { |nm| nm[:nick] == name }[:name].parameterize,
|
||||
created_at: ts - (120.minutes - time.to_i.minutes)
|
||||
}
|
||||
end
|
||||
|
||||
public_id = Nanoid.generate(size: 6)
|
||||
name = Spicy::Proton.pair(" ")
|
||||
password = Nanoid.generate(size: 4, alphabet: "0123456789")
|
||||
instance = Instance.new(zone: zone, public_id: public_id, name: name, password: password)
|
||||
if instance.save
|
||||
Pop.insert_all(results.map { |r| { instance_id: instance.id, **r } })
|
||||
@id = instance.public_id
|
||||
@password = instance.password
|
||||
render "set_password"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@instance = Instance.includes(:pops, :fairies).find_by(public_id: show_instance_params)
|
||||
if @instance
|
||||
|
@ -61,6 +107,10 @@ class InstanceController < ApplicationController
|
|||
params.expect(:zone)
|
||||
end
|
||||
|
||||
def create_from_fe_params
|
||||
params.expect(:info)
|
||||
end
|
||||
|
||||
def show_instance_params
|
||||
params.expect(:public_id)
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<div id="nm-list">
|
||||
<% APP_DATA[instance.zone.to_sym][:nms].each do |nm| %>
|
||||
<% is_popped = instance.pops.filter { |pop| (Time.current - 120.minutes) <= pop.created_at }.any? { |pop| pop.name == nm[:name].parameterize } %>
|
||||
<% is_popped = instance.pops.filter { |pop| (Time.now.utc - 120.minutes) <= pop.created_at }.any? { |pop| pop.name == nm[:name].parameterize } %>
|
||||
<section class="<%= class_names(popped: is_popped, missing_reqs: has_missing_reqs?(nm, forecast)) %>">
|
||||
<div>
|
||||
<img src="<%= "/#{nm[:element]}.png" %>" alt="<%= nm[:element] %>" width="30" />
|
||||
|
|
|
@ -40,3 +40,17 @@
|
|||
</button>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<h3>Import from ffxiv-eureka.com</h3>
|
||||
|
||||
<p>
|
||||
Paste the text from the "killed NMs" button
|
||||
<img src="/the_button.png" title="this one" alt="the button" />
|
||||
in here, and we'll create an identical tracker for you.
|
||||
</p>
|
||||
|
||||
<%= form_with url: new_from_fe_path do |f| %>
|
||||
<%= f.text_field :info, placeholder: "Paste here!" %>
|
||||
<%= f.submit "Create" %>
|
||||
<% end %>
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ Rails.application.routes.draw do
|
|||
get "/up" => "rails/health#show", as: :rails_health_check
|
||||
|
||||
post "/new", to: "instance#create", as: :new_instance
|
||||
post "/new_from_fe", to: "instance#create_from_fe", as: :new_from_fe
|
||||
post "/pop", to: "instance#pop", as: :pop_in_instance
|
||||
post "/reset", to: "instance#reset", as: :reset_in_instance
|
||||
post "/auth", to: "instance#authenticate", as: :authenticate_to_instance
|
||||
|
|
|
@ -42,6 +42,7 @@ fairies = [
|
|||
|
||||
[[nms]]
|
||||
name = "Sabotender Corrido"
|
||||
nick = "Sabo"
|
||||
level = 1
|
||||
element = "wind"
|
||||
x = 14
|
||||
|
@ -53,6 +54,7 @@ level = 6
|
|||
|
||||
[[nms]]
|
||||
name = "The Lord of Anemos"
|
||||
nick = "Lord"
|
||||
level = 2
|
||||
element = "water"
|
||||
x = 30
|
||||
|
@ -65,6 +67,7 @@ level = 7
|
|||
|
||||
[[nms]]
|
||||
name = "Teles"
|
||||
nick = "Teles"
|
||||
level = 3
|
||||
element = "wind"
|
||||
x = 26
|
||||
|
@ -76,6 +79,7 @@ level = 8
|
|||
|
||||
[[nms]]
|
||||
name = "The Emperor of Anemos"
|
||||
nick = "Emperor"
|
||||
level = 4
|
||||
element = "wind"
|
||||
x = 17
|
||||
|
@ -88,6 +92,7 @@ level = 9
|
|||
|
||||
[[nms]]
|
||||
name = "Callisto"
|
||||
nick = "Callisto"
|
||||
level = 5
|
||||
element = "earth"
|
||||
x = 26
|
||||
|
@ -99,6 +104,7 @@ level = 10
|
|||
|
||||
[[nms]]
|
||||
name = "Number"
|
||||
nick = "Number"
|
||||
level = 6
|
||||
element = "lightning"
|
||||
x = 24
|
||||
|
@ -110,6 +116,7 @@ level = 11
|
|||
|
||||
[[nms]]
|
||||
name = "Jahannam"
|
||||
nick = "Jaha"
|
||||
level = 7
|
||||
element = "wind"
|
||||
x = 18
|
||||
|
@ -122,6 +129,7 @@ weather = "gales"
|
|||
|
||||
[[nms]]
|
||||
name = "Amemet"
|
||||
nick = "Amemet"
|
||||
level = 8
|
||||
element = "fire"
|
||||
x = 15
|
||||
|
@ -133,6 +141,7 @@ level = 13
|
|||
|
||||
[[nms]]
|
||||
name = "Caym"
|
||||
nick = "Caym"
|
||||
level = 9
|
||||
element = "ice"
|
||||
x = 14
|
||||
|
@ -144,6 +153,7 @@ level = 14
|
|||
|
||||
[[nms]]
|
||||
name = "Bombadeel"
|
||||
nick = "Bomba"
|
||||
level = 10
|
||||
element = "earth"
|
||||
x = 28
|
||||
|
@ -156,6 +166,7 @@ night_only = true
|
|||
|
||||
[[nms]]
|
||||
name = "Serket"
|
||||
nick = "Serket"
|
||||
level = 11
|
||||
element = "earth"
|
||||
x = 25
|
||||
|
@ -168,6 +179,7 @@ level = 16
|
|||
|
||||
[[nms]]
|
||||
name = "Judgmental Julika"
|
||||
nick = "Julika"
|
||||
level = 12
|
||||
element = "ice"
|
||||
x = 22
|
||||
|
@ -179,6 +191,7 @@ level = 17
|
|||
|
||||
[[nms]]
|
||||
name = "The White Rider"
|
||||
nick = "Rider"
|
||||
level = 13
|
||||
element = "lightning"
|
||||
x = 20
|
||||
|
@ -191,6 +204,7 @@ night_only = true
|
|||
|
||||
[[nms]]
|
||||
name = "Polyphemus"
|
||||
nick = "Poly"
|
||||
level = 14
|
||||
element = "ice"
|
||||
x = 26
|
||||
|
@ -202,6 +216,7 @@ level = 19
|
|||
|
||||
[[nms]]
|
||||
name = "Simurgh's Strider"
|
||||
nick = "Strider"
|
||||
level = 15
|
||||
element = "wind"
|
||||
x = 29
|
||||
|
@ -214,6 +229,7 @@ level = 20
|
|||
|
||||
[[nms]]
|
||||
name = "King Hazmat"
|
||||
nick = "Hazmat"
|
||||
level = 16
|
||||
element = "fire"
|
||||
x = 35
|
||||
|
@ -225,6 +241,7 @@ level = 21
|
|||
|
||||
[[nms]]
|
||||
name = "Fafnir"
|
||||
nick = "Fafnir"
|
||||
level = 17
|
||||
element = "fire"
|
||||
x = 36
|
||||
|
@ -238,6 +255,7 @@ night_only = true
|
|||
|
||||
[[nms]]
|
||||
name = "Amarok"
|
||||
nick = "Amarok"
|
||||
level = 18
|
||||
element = "ice"
|
||||
x = 8
|
||||
|
@ -249,6 +267,7 @@ level = 23
|
|||
|
||||
[[nms]]
|
||||
name = "Lamashtu"
|
||||
nick = "Lamashtu"
|
||||
level = 19
|
||||
element = "wind"
|
||||
x = 8
|
||||
|
@ -261,6 +280,7 @@ night_only = true
|
|||
|
||||
[[nms]]
|
||||
name = "Pazuzu"
|
||||
nick = "Paz"
|
||||
level = 20
|
||||
element = "wind"
|
||||
x = 7
|
||||
|
|
|
@ -36,6 +36,7 @@ fairies = [
|
|||
|
||||
[[nms]]
|
||||
name = "Khalamari"
|
||||
nick = "Khalamari"
|
||||
level = 50
|
||||
element = "water"
|
||||
x = 11
|
||||
|
@ -47,6 +48,7 @@ level = 55
|
|||
|
||||
[[nms]]
|
||||
name = "Stegodon"
|
||||
nick = "Stegodon"
|
||||
level = 51
|
||||
element = "earth"
|
||||
x = 9
|
||||
|
@ -58,6 +60,7 @@ level = 56
|
|||
|
||||
[[nms]]
|
||||
name = "Molech"
|
||||
nick = "Molech"
|
||||
level = 52
|
||||
element = "ice"
|
||||
x = 7
|
||||
|
@ -70,6 +73,7 @@ level = 57
|
|||
|
||||
[[nms]]
|
||||
name = "Piasa"
|
||||
nick = "Piasa"
|
||||
level = 53
|
||||
element = "wind"
|
||||
x = 7
|
||||
|
@ -81,6 +85,7 @@ level = 58
|
|||
|
||||
[[nms]]
|
||||
name = "Frostmane"
|
||||
nick = "Frostmane"
|
||||
level = 54
|
||||
element = "fire"
|
||||
x = 8
|
||||
|
@ -92,6 +97,7 @@ level = 59
|
|||
|
||||
[[nms]]
|
||||
name = "Daphne"
|
||||
nick = "Daphne"
|
||||
level = 55
|
||||
element = "water"
|
||||
x = 25
|
||||
|
@ -103,6 +109,7 @@ level = 60
|
|||
|
||||
[[nms]]
|
||||
name = "King Goldemar"
|
||||
nick = "Golde"
|
||||
level = 56
|
||||
element = "lightning"
|
||||
x = 28
|
||||
|
@ -116,6 +123,7 @@ night_only = true
|
|||
|
||||
[[nms]]
|
||||
name = "Leuke"
|
||||
nick = "Leuke"
|
||||
level = 57
|
||||
element = "earth"
|
||||
x = 37
|
||||
|
@ -127,6 +135,7 @@ level = 62
|
|||
|
||||
[[nms]]
|
||||
name = "Barong"
|
||||
nick = "Barong"
|
||||
level = 58
|
||||
element = "fire"
|
||||
x = 32
|
||||
|
@ -138,6 +147,7 @@ level = 63
|
|||
|
||||
[[nms]]
|
||||
name = "Ceto"
|
||||
nick = "Ceto"
|
||||
level = 59
|
||||
element = "water"
|
||||
x = 36
|
||||
|
@ -150,6 +160,7 @@ level = 64
|
|||
|
||||
[[nms]]
|
||||
name = "Provenance Watcher"
|
||||
nick = "PW"
|
||||
level = 60
|
||||
element = "fire"
|
||||
x = 32
|
||||
|
|
|
@ -48,6 +48,7 @@ fairies = [
|
|||
|
||||
[[nms]]
|
||||
name = "The Snow Queen"
|
||||
nick = "Queen"
|
||||
level = 20
|
||||
element = "ice"
|
||||
x = 21
|
||||
|
@ -60,6 +61,7 @@ level = 25
|
|||
|
||||
[[nms]]
|
||||
name = "Taxim"
|
||||
nick = "Taxim"
|
||||
level = 21
|
||||
element = "earth"
|
||||
x = 25
|
||||
|
@ -72,6 +74,7 @@ night_only = true
|
|||
|
||||
[[nms]]
|
||||
name = "Ash Dragon"
|
||||
nick = "Dragon"
|
||||
level = 22
|
||||
element = "fire"
|
||||
x = 29
|
||||
|
@ -83,6 +86,7 @@ level = 27
|
|||
|
||||
[[nms]]
|
||||
name = "Glavoid"
|
||||
nick = "Glavoid"
|
||||
level = 23
|
||||
element = "earth"
|
||||
x = 32
|
||||
|
@ -94,6 +98,7 @@ level = 28
|
|||
|
||||
[[nms]]
|
||||
name = "Anapos"
|
||||
nick = "Anapos"
|
||||
level = 24
|
||||
element = "water"
|
||||
x = 34
|
||||
|
@ -106,6 +111,7 @@ weather = "fog"
|
|||
|
||||
[[nms]]
|
||||
name = "Hakutaku"
|
||||
nick = "Haku"
|
||||
level = 25
|
||||
element = "fire"
|
||||
x = 29
|
||||
|
@ -118,6 +124,7 @@ level = 30
|
|||
|
||||
[[nms]]
|
||||
name = "King Igloo"
|
||||
nick = "Igloo"
|
||||
level = 26
|
||||
element = "ice"
|
||||
x = 17
|
||||
|
@ -129,6 +136,7 @@ level = 31
|
|||
|
||||
[[nms]]
|
||||
name = "Asag"
|
||||
nick = "Asag"
|
||||
level = 27
|
||||
element = "lightning"
|
||||
x = 10
|
||||
|
@ -140,6 +148,7 @@ level = 32
|
|||
|
||||
[[nms]]
|
||||
name = "Surabhi"
|
||||
nick = "Surabhi"
|
||||
level = 28
|
||||
element = "earth"
|
||||
x = 10
|
||||
|
@ -151,6 +160,7 @@ level = 33
|
|||
|
||||
[[nms]]
|
||||
name = "King Arthro"
|
||||
nick = "Arthro"
|
||||
level = 29
|
||||
element = "water"
|
||||
x = 8
|
||||
|
@ -164,6 +174,7 @@ level = 34
|
|||
|
||||
[[nms]]
|
||||
name = "Mindertaur/Eldertaur"
|
||||
nick = "Brothers"
|
||||
level = 30
|
||||
element = "earth"
|
||||
x = 13
|
||||
|
@ -175,6 +186,7 @@ level = 35
|
|||
|
||||
[[nms]]
|
||||
name = "Holy Cow"
|
||||
nick = "Holy Cow"
|
||||
level = 31
|
||||
element = "water"
|
||||
x = 26
|
||||
|
@ -186,6 +198,7 @@ level = 36
|
|||
|
||||
[[nms]]
|
||||
name = "Hadhayosh"
|
||||
nick = "Behe"
|
||||
level = 32
|
||||
element = "lightning"
|
||||
x = 30
|
||||
|
@ -199,6 +212,7 @@ level = 37
|
|||
|
||||
[[nms]]
|
||||
name = "Horus"
|
||||
nick = "Horus"
|
||||
level = 33
|
||||
element = "fire"
|
||||
x = 25
|
||||
|
@ -211,6 +225,7 @@ level = 38
|
|||
|
||||
[[nms]]
|
||||
name = "Arch Angra Mainyu"
|
||||
nick = "Mainyu"
|
||||
level = 34
|
||||
element = "wind"
|
||||
x = 24
|
||||
|
@ -222,6 +237,7 @@ level = 39
|
|||
|
||||
[[nms]]
|
||||
name = "Copycat Cassie"
|
||||
nick = "Cassie"
|
||||
level = 35
|
||||
element = "ice"
|
||||
x = 22
|
||||
|
@ -235,6 +251,7 @@ level = 40
|
|||
|
||||
[[nms]]
|
||||
name = "Louhi"
|
||||
nick = "Louhi"
|
||||
level = 35
|
||||
element = "ice"
|
||||
x = 36
|
||||
|
|
|
@ -26,6 +26,7 @@ fairies = [
|
|||
|
||||
[[nms]]
|
||||
name = "Leucosia"
|
||||
nick = "Leucosia"
|
||||
level = 35
|
||||
element = "water"
|
||||
x = 27
|
||||
|
@ -38,6 +39,7 @@ night_only = true
|
|||
|
||||
[[nms]]
|
||||
name = "Flauros"
|
||||
nick = "Flauros"
|
||||
level = 36
|
||||
element = "lightning"
|
||||
x = 29
|
||||
|
@ -50,6 +52,7 @@ weather = "thunder"
|
|||
|
||||
[[nms]]
|
||||
name = "The Sophist"
|
||||
nick = "Sophist"
|
||||
level = 37
|
||||
element = "wind"
|
||||
x = 31
|
||||
|
@ -61,6 +64,7 @@ level = 42
|
|||
|
||||
[[nms]]
|
||||
name = "Graffiacane"
|
||||
nick = "Doll"
|
||||
level = 38
|
||||
element = "ice"
|
||||
x = 23
|
||||
|
@ -73,6 +77,7 @@ level = 43
|
|||
|
||||
[[nms]]
|
||||
name = "Askalaphos"
|
||||
nick = "Owl"
|
||||
level = 39
|
||||
element = "wind"
|
||||
x = 19
|
||||
|
@ -85,6 +90,7 @@ level = 44
|
|||
|
||||
[[nms]]
|
||||
name = "Grand Duke Batym"
|
||||
nick = "Batym"
|
||||
level = 40
|
||||
element = "earth"
|
||||
x = 18
|
||||
|
@ -97,6 +103,7 @@ night_only = true
|
|||
|
||||
[[nms]]
|
||||
name = "Aetolus"
|
||||
nick = "Aetolus"
|
||||
level = 41
|
||||
element = "lightning"
|
||||
x = 10
|
||||
|
@ -108,6 +115,7 @@ level = 46
|
|||
|
||||
[[nms]]
|
||||
name = "Lesath"
|
||||
nick = "Lesath"
|
||||
level = 42
|
||||
element = "fire"
|
||||
x = 13
|
||||
|
@ -119,6 +127,7 @@ level = 47
|
|||
|
||||
[[nms]]
|
||||
name = "Eldthurs"
|
||||
nick = "Eldthurs"
|
||||
level = 43
|
||||
element = "fire"
|
||||
x = 13
|
||||
|
@ -130,6 +139,7 @@ level = 48
|
|||
|
||||
[[nms]]
|
||||
name = "Iris"
|
||||
nick = "Iris"
|
||||
level = 44
|
||||
element = "water"
|
||||
x = 21
|
||||
|
@ -141,6 +151,7 @@ level = 49
|
|||
|
||||
[[nms]]
|
||||
name = "Lamebrix Strikebocks"
|
||||
nick = "Lamebrix"
|
||||
level = 45
|
||||
element = "earth"
|
||||
x = 21
|
||||
|
@ -153,6 +164,7 @@ level = 50
|
|||
|
||||
[[nms]]
|
||||
name = "Dux"
|
||||
nick = "Dux"
|
||||
level = 46
|
||||
element = "lightning"
|
||||
x = 27
|
||||
|
@ -165,6 +177,7 @@ level = 51
|
|||
|
||||
[[nms]]
|
||||
name = "Lumber Jack"
|
||||
nick = "Jack"
|
||||
level = 47
|
||||
element = "earth"
|
||||
x = 29
|
||||
|
@ -177,6 +190,7 @@ level = 52
|
|||
|
||||
[[nms]]
|
||||
name = "Glaukopis"
|
||||
nick = "Glaukopis"
|
||||
level = 48
|
||||
element = "fire"
|
||||
x = 31
|
||||
|
@ -188,6 +202,7 @@ level = 53
|
|||
|
||||
[[nms]]
|
||||
name = "Ying-Yang"
|
||||
nick = "YY"
|
||||
level = 49
|
||||
element = "water"
|
||||
x = 11
|
||||
|
@ -200,6 +215,7 @@ level = 54
|
|||
|
||||
[[nms]]
|
||||
name = "Skoll"
|
||||
nick = "Skoll"
|
||||
level = 50
|
||||
element = "ice"
|
||||
x = 23
|
||||
|
@ -213,6 +229,7 @@ level = 55
|
|||
|
||||
[[nms]]
|
||||
name = "Penthesilea"
|
||||
nick = "Penny"
|
||||
level = 50
|
||||
element = "fire"
|
||||
x = 35
|
||||
|
|
BIN
public/the_button.png
Normal file
BIN
public/the_button.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 628 B |
Loading…
Add table
Reference in a new issue