detailed item reports

Resolves #40
This commit is contained in:
Aaron Kimbre 2022-06-08 23:09:14 -05:00
parent b561bcb60d
commit c1307af49c
3 changed files with 46 additions and 21 deletions

View File

@ -308,7 +308,9 @@ def register_luclient_jinja_helpers(app):
'select component_id from ComponentsRegistry where component_type = 11 and id = ?',
[lot_id],
one=True
)[0]
)
if render_component_id:
render_component_id = render_component_id[0]
rarity = query_cdclient(
'select rarity from ItemComponent where id = ?',

View File

@ -6,7 +6,6 @@ from app import gm_level, scheduler
from sqlalchemy.orm import load_only
import datetime
import xmltodict
import random
reports_blueprint = Blueprint('reports', __name__)
@ -32,7 +31,6 @@ def index():
).filter(
Reports.report_type == "uscore"
).group_by(Reports.date).options(load_only(Reports.date)).all()
return render_template(
'reports/index.html.j2',
reports_items=reports_items,
@ -69,9 +67,13 @@ def items_graph(start, end):
items[key] = get_lot_name(key)
# make it
for key, value in items.items():
if value:
data = []
for entry in entries:
if key in entry.data.keys():
if not isinstance(entry.data[key], int):
data.append(entry.data[key]["item_count"])
else:
data.append(entry.data[key])
else:
data.append(0)
@ -224,6 +226,7 @@ def gen_item_report():
report_data = {}
for char_xml in char_xmls:
name = CharacterInfo.query.filter(CharacterInfo.id == char_xml.id).first().name
try:
character_json = xmltodict.parse(
char_xml.xml_data,
@ -233,9 +236,13 @@ def gen_item_report():
if "i" in inv.keys() and type(inv["i"]) == list and (int(inv["attr_t"]) == 0 or int(inv["attr_t"]) == 1):
for item in inv["i"]:
if item["attr_l"] in report_data:
report_data[item["attr_l"]] = report_data[item["attr_l"]] + int(item["attr_c"])
report_data[item["attr_l"]]["item_count"] = report_data[item["attr_l"]]["item_count"] + int(item["attr_c"])
else:
report_data[item["attr_l"]] = int(item["attr_c"])
report_data[item["attr_l"]] = {"item_count": int(item["attr_c"]), "chars": {}}
if name in report_data[item["attr_l"]]["chars"]:
report_data[item["attr_l"]]["chars"][name] = report_data[item["attr_l"]]["chars"][name] + int(item["attr_c"])
else:
report_data[item["attr_l"]]["chars"][name] = int(item["attr_c"])
except Exception as e:
current_app.logger.error(f"REPORT::ITEMS - ERROR PARSING CHARACTER {char_xml.id}")
current_app.logger.error(f"REPORT::ITEMS - {e}")

View File

@ -20,18 +20,34 @@
<th scope="col">
Count
</th>
<th scope="col">
Breakdown
</th>
<th scope="col">
Rarity
</th>
</thead>
<tbody>
{% for lot, count in data.items() %}
{% for lot, details in data.items() %}
<tr>
<td>
{{ lot|get_lot_name }}
</td>
<td>
{{ count }}
{% if details.chars %}
{{ details.item_count }}
{% else %}
{{ details }}
{% endif %}
</td>
<td>
{% if details.chars %}
{% for char, value in details.chars|dictsort(false, 'value')|reverse %}
{{char}}: {{value}}<br/>
{% endfor %}
{% else %}
Missing
{% endif %}
</td>
<td>
{{ lot|get_lot_rarity }}