fixup! Chatty: Replace usernames by Twitch IDs
This commit is contained in:
parent
4aa51045eb
commit
b7b596618a
3 changed files with 14 additions and 5 deletions
|
@ -72,6 +72,7 @@ module Handlers
|
||||||
j.field "name", name
|
j.field "name", name
|
||||||
j.field "id", id
|
j.field "id", id
|
||||||
j.field "url", url
|
j.field "url", url
|
||||||
|
# TODO: En BTTV faltan los users xDD
|
||||||
j.field "users", "xd"
|
j.field "users", "xd"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -87,8 +88,9 @@ module Handlers
|
||||||
images = [item["urls"]["1"], item["urls"]["2"], item["urls"]["4"]]
|
images = [item["urls"]["1"], item["urls"]["2"], item["urls"]["4"]]
|
||||||
j.object do
|
j.object do
|
||||||
j.field "id", item["id"]
|
j.field "id", item["id"]
|
||||||
j.field "name", item["name"]
|
# j.field "name", item["name"]
|
||||||
j.field "title", item["title"]
|
# En FFZ remover "name" y que title sea el nuevo "name"
|
||||||
|
j.field "name", item["title"]
|
||||||
j.field "color", item["color"]
|
j.field "color", item["color"]
|
||||||
j.field "urls" do
|
j.field "urls" do
|
||||||
j.array do
|
j.array do
|
||||||
|
|
|
@ -24,16 +24,23 @@ module Providers::Chatty
|
||||||
next if item["id"] != "chatty"
|
next if item["id"] != "chatty"
|
||||||
|
|
||||||
item["usernames"].as_a.each_with_index do |username, index|
|
item["usernames"].as_a.each_with_index do |username, index|
|
||||||
|
if sql = SQL.query_one? "SELECT * FROM chatty_ids WHERE username = ? LIMIT 1", username.to_s, as: {String, String}
|
||||||
|
item["usernames"].as_a[index] = JSON::Any.new(sql[1])
|
||||||
|
puts "no"
|
||||||
|
wg.done
|
||||||
|
next
|
||||||
|
end
|
||||||
spawn do
|
spawn do
|
||||||
id = JSON::Any.new(Utils::GQL.new.get_user_id(username.to_s))
|
id = JSON::Any.new(Utils::GQL.new.get_user_id(username.to_s))
|
||||||
|
SQL.exec "INSERT OR IGNORE INTO chatty_ids (username, twitch_id) VALUES (?, ?)", username.to_s, id.to_s
|
||||||
item["usernames"].as_a[index] = id
|
item["usernames"].as_a[index] = id
|
||||||
ensure
|
ensure
|
||||||
wg.done
|
wg.done
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# Waits for all the fibers to complete before returning res
|
# Waits for all the fibers to complete before returning res
|
||||||
wg.wait
|
wg.wait
|
||||||
return res
|
return res
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,7 +7,7 @@ module Utils
|
||||||
AND EXISTS (SELECT 1 FROM sqlite_schema WHERE type='table' AND name='seventv_ids');", as: Bool
|
AND EXISTS (SELECT 1 FROM sqlite_schema WHERE type='table' AND name='seventv_ids');", as: Bool
|
||||||
LOGGER.info "Creating sqlite3 database at '#{CONFIG.db}'"
|
LOGGER.info "Creating sqlite3 database at '#{CONFIG.db}'"
|
||||||
begin
|
begin
|
||||||
SQL.exec "CREATE TABLE IF NOT EXISTS seventv_ids (username text UNIQUE, twitch_id text UNIQUE, seventv_id text UNIQUE, )"
|
SQL.exec "CREATE TABLE IF NOT EXISTS seventv_ids (username text UNIQUE, twitch_id text UNIQUE, seventv_id text UNIQUE)"
|
||||||
SQL.exec "CREATE TABLE IF NOT EXISTS chatty_ids (username text UNIQUE, twitch_id text UNIQUE)"
|
SQL.exec "CREATE TABLE IF NOT EXISTS chatty_ids (username text UNIQUE, twitch_id text UNIQUE)"
|
||||||
# SQL.exec "CREATE TABLE IF NOT EXISTS #{CONFIG.ipTableName} (ip text UNIQUE, count integer DEFAULT 0, date integer)"
|
# SQL.exec "CREATE TABLE IF NOT EXISTS #{CONFIG.ipTableName} (ip text UNIQUE, count integer DEFAULT 0, date integer)"
|
||||||
rescue ex
|
rescue ex
|
||||||
|
|
Loading…
Add table
Reference in a new issue