Преглед изворни кода

Store kill entity names in campaigns database.

master
Ben Kurtovic пре 7 година
родитељ
комит
9ade2b55e2
4 измењених фајлова са 52 додато и 24 уклоњено
  1. +27
    -13
      calefaction/modules/campaigns/database.py
  2. +4
    -0
      data/schema_campaigns.sql
  3. +2
    -0
      scripts/cloc
  4. +19
    -11
      templates/campaigns/renderers.mako

+ 27
- 13
calefaction/modules/campaigns/database.py Прегледај датотеку

@@ -98,18 +98,22 @@ class CampaignDB:
except ValueError:
raise RuntimeError("Invalid kill_date=%s for kill_id=%d" % (
kill["killTime"], kill["killID"]))
# ... Ensure IDs are all ints

query = """INSERT OR REPLACE INTO kill (
kill_id, kill_date, kill_system, kill_victim_shipid,
kill_victim_charid, kill_victim_corpid, kill_victim_allianceid,
kill_victim_factionid, kill_value)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"""
kill_victim_charid, kill_victim_charname, kill_victim_corpid,
kill_victim_corpname, kill_victim_allianceid,
kill_victim_alliancename, kill_victim_factionid,
kill_victim_factionname, kill_value)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"""
victim = kill["victim"]
args = (
kill["killID"], kill["killTime"], kill["solarSystemID"],
kill["victim"]["shipTypeID"], kill["victim"]["characterID"],
kill["victim"]["corporationID"], kill["victim"]["allianceID"],
kill["victim"]["factionID"], kill["zkb"]["totalValue"])
int(kill["killID"]), kill["killTime"], int(kill["solarSystemID"]),
int(victim["shipTypeID"]), int(victim["characterID"]),
victim["characterName"], int(victim["corporationID"]),
victim["corporationName"], int(victim["allianceID"]),
victim["allianceName"], int(victim["factionID"]),
victim["factionName"], float(kill["zkb"]["totalValue"]))
with self._conn as conn:
conn.execute(query, args)

@@ -149,8 +153,10 @@ class CampaignDB:
raise ValueError(offset)

query = """SELECT kill_id, kill_date, kill_system, kill_victim_shipid,
kill_victim_charid, kill_victim_corpid, kill_victim_allianceid,
kill_victim_factionid, kill_value
kill_victim_charid, kill_victim_charname, kill_victim_corpid,
kill_victim_corpname, kill_victim_allianceid,
kill_victim_alliancename, kill_victim_factionid,
kill_victim_factionname, kill_value
FROM oper_kill
JOIN kill ON ok_killid = kill_id
WHERE ok_campaign = ? AND ok_operation = ?
@@ -163,7 +169,15 @@ class CampaignDB:
"date": datetime.strptime(row[1], "%Y-%m-%d %H:%M:%S"),
"system": row[2],
"victim": {
"ship_id": row[3], "char_id": row[4], "corp_id": row[5],
"alliance_id": row[6], "faction_id": row[7]},
"value": row[8]
"ship_id": row[3],
"char_id": row[4],
"char_name": row[5],
"corp_id": row[6],
"corp_name": row[7],
"alliance_id": row[8],
"alliance_name": row[9],
"faction_id": row[10],
"faction_name": row[11]
},
"value": row[12]
} for row in res]

+ 4
- 0
data/schema_campaigns.sql Прегледај датотеку

@@ -28,9 +28,13 @@ CREATE TABLE kill (
kill_system INTEGER,
kill_victim_shipid INTEGER,
kill_victim_charid INTEGER,
kill_victim_charname TEXT,
kill_victim_corpid INTEGER,
kill_victim_corpname TEXT,
kill_victim_allianceid INTEGER,
kill_victim_alliancename TEXT,
kill_victim_factionid INTEGER,
kill_victim_factionname TEXT,
kill_value REAL
);



+ 2
- 0
scripts/cloc Прегледај датотеку

@@ -0,0 +1,2 @@
#!/usr/bin/env bash
cloc --vcs=git $@ .

+ 19
- 11
templates/campaigns/renderers.mako Прегледај датотеку

@@ -5,34 +5,42 @@
<% victim = kill["victim"] %>
<tr>
<td class="fluid">
<span>
<a href="https://zkillboard.com/kill/${kill['id']}/">
<abbr title="${kill["date"].strftime("%Y-%m-%d %H:%M")}">${format_utctime_compact(kill["date"]) | h}</abbr><br/>
<abbr title="${"{:,.2f}".format(kill["value"])} ISK">${format_isk_compact(kill["value"]) | h}</abbr>
</span>
</a>
</td>
<td class="fluid extra">
<span>
${kill["system"]} 0.3<br/><!-- ... -->
Region<!-- ... -->
</span>
${kill["system"]} 0.3<br/><!-- ... -->
Region<!-- ... -->
</td>
<td class="icon">
<a href="https://zkillboard.com/kill/${kill['id']}/"><img title="" alt="<!-- ... -->" src="${g.eve.image.inventory(victim["ship_id"], 64)}"/></a>
<a href="https://zkillboard.com/kill/${kill['id']}/">
<img title="Kill ${kill['id']}" alt="Kill ${kill['id']}" src="${g.eve.image.inventory(victim["ship_id"], 64)}"/>
</a>
</td>
<td class="icon extra">
<a href="https://zkillboard.com/character/${victim['char_id']}/"><img title="" alt="<!-- ... -->" src="${g.eve.image.character(victim["char_id"], 128)}"/></a>
<a href="https://zkillboard.com/character/${victim['char_id']}/">
<img title="${victim['char_name']}" alt="${victim['char_name']}" src="${g.eve.image.character(victim["char_id"], 128)}"/>
</a>
</td>
<td class="icon${' extra' if victim["alliance_id"] and victim["faction_id"] else ''}">
<a href="https://zkillboard.com/corporation/${victim['corp_id']}/"><img title="" alt="<!-- ... -->" src="${g.eve.image.corp(victim["corp_id"], 128)}"/></a>
<a href="https://zkillboard.com/corporation/${victim['corp_id']}/">
<img title="${victim['corp_name']}" alt="${victim['corp_name']}" src="${g.eve.image.corp(victim["corp_id"], 128)}"/>
</a>
</td>
<td class="icon${'' if victim["alliance_id"] else ' extra'}">
% if victim["alliance_id"]:
<a href="https://zkillboard.com/alliance/${victim['alliance_id']}/"><img title="" alt="<!-- ... -->" src="${g.eve.image.alliance(victim["alliance_id"], 128)}"/></a>
<a href="https://zkillboard.com/alliance/${victim['alliance_id']}/">
<img title="${victim['alliance_name']}" alt="${victim['alliance_name']}" src="${g.eve.image.alliance(victim["alliance_id"], 128)}"/>
</a>
% endif
</td>
<td class="icon${'' if victim["faction_id"] else ' extra'}">
% if victim["faction_id"]:
<a href="https://zkillboard.com/faction/${victim['faction_id']}/"><img title="" alt="<!-- ... -->" src="${g.eve.image.faction(victim["faction_id"], 128)}"/></a>
<a href="https://zkillboard.com/faction/${victim['faction_id']}/">
<img title="${victim['faction_name']}" alt="${victim['faction_name']}" src="${g.eve.image.faction(victim["faction_id"], 128)}"/>
</a>
% endif
</td>
% if not victim["alliance_id"] and not victim["faction_id"]:


Loading…
Откажи
Сачувај