Spaces:
Sleeping
Sleeping
rafaldembski
commited on
Update pages/Statistics.py
Browse files- pages/Statistics.py +23 -8
pages/Statistics.py
CHANGED
@@ -128,12 +128,27 @@ def get_iso_alpha3(country_name):
|
|
128 |
except LookupError:
|
129 |
return None
|
130 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
def main(language):
|
132 |
translations = page_translations.get(language, page_translations['Polish'])
|
133 |
|
134 |
st.title(translations['header'])
|
135 |
st.markdown(translations['description'])
|
136 |
|
|
|
|
|
137 |
# Pobieranie danych z plik贸w JSON
|
138 |
try:
|
139 |
stats = get_stats()
|
@@ -147,18 +162,18 @@ def main(language):
|
|
147 |
total_frauds_detected = stats.get("total_frauds_detected", 0)
|
148 |
|
149 |
# Wy艣wietlenie metryk za pomoc膮 funkcji `card()`
|
150 |
-
col1, col2, col3 = st.columns(
|
151 |
with col1:
|
152 |
card(
|
153 |
title=translations['total_analyses'],
|
154 |
text=str(total_analyses),
|
155 |
)
|
156 |
-
with
|
157 |
card(
|
158 |
title=translations['total_frauds_detected'],
|
159 |
text=str(total_frauds_detected),
|
160 |
)
|
161 |
-
with
|
162 |
if total_analyses > 0:
|
163 |
fraud_percentage = (total_frauds_detected / total_analyses) * 100
|
164 |
else:
|
@@ -211,7 +226,7 @@ def main(language):
|
|
211 |
search_query = st.text_input(translations.get('search_placeholder', "Wyszukaj w historii:"), "")
|
212 |
if search_query:
|
213 |
df_filtered = df_filtered[
|
214 |
-
df_filtered.apply(lambda row: row.astype(str).str.contains(search_query, case=False).any(), axis=1)
|
215 |
]
|
216 |
|
217 |
# Wy艣wietlenie tabeli historii analiz
|
@@ -240,18 +255,18 @@ def main(language):
|
|
240 |
|
241 |
# Wy艣wietlenie metryk dla filtrowanej historii
|
242 |
st.markdown("### " + translations['fraud_trend_title'])
|
243 |
-
|
244 |
-
with
|
245 |
card(
|
246 |
title=translations['total_analyses'],
|
247 |
text=str(total_filtered),
|
248 |
)
|
249 |
-
with
|
250 |
card(
|
251 |
title=translations['total_frauds_detected'],
|
252 |
text=str(frauds_filtered),
|
253 |
)
|
254 |
-
with
|
255 |
card(
|
256 |
title=translations['fraud_percentage'],
|
257 |
text=f"{fraud_percentage_filtered:.2f}%",
|
|
|
128 |
except LookupError:
|
129 |
return None
|
130 |
|
131 |
+
def inject_custom_css():
|
132 |
+
st.markdown(
|
133 |
+
"""
|
134 |
+
<style>
|
135 |
+
.stCard {
|
136 |
+
padding: 0.5rem;
|
137 |
+
margin: 0.2rem;
|
138 |
+
}
|
139 |
+
</style>
|
140 |
+
""",
|
141 |
+
unsafe_allow_html=True
|
142 |
+
)
|
143 |
+
|
144 |
def main(language):
|
145 |
translations = page_translations.get(language, page_translations['Polish'])
|
146 |
|
147 |
st.title(translations['header'])
|
148 |
st.markdown(translations['description'])
|
149 |
|
150 |
+
inject_custom_css()
|
151 |
+
|
152 |
# Pobieranie danych z plik贸w JSON
|
153 |
try:
|
154 |
stats = get_stats()
|
|
|
162 |
total_frauds_detected = stats.get("total_frauds_detected", 0)
|
163 |
|
164 |
# Wy艣wietlenie metryk za pomoc膮 funkcji `card()`
|
165 |
+
col1, col2, col3, col4, col5, col6 = st.columns(6)
|
166 |
with col1:
|
167 |
card(
|
168 |
title=translations['total_analyses'],
|
169 |
text=str(total_analyses),
|
170 |
)
|
171 |
+
with col3:
|
172 |
card(
|
173 |
title=translations['total_frauds_detected'],
|
174 |
text=str(total_frauds_detected),
|
175 |
)
|
176 |
+
with col5:
|
177 |
if total_analyses > 0:
|
178 |
fraud_percentage = (total_frauds_detected / total_analyses) * 100
|
179 |
else:
|
|
|
226 |
search_query = st.text_input(translations.get('search_placeholder', "Wyszukaj w historii:"), "")
|
227 |
if search_query:
|
228 |
df_filtered = df_filtered[
|
229 |
+
df_filtered.apply(lambda row: row.astype(str).str.contains(search_query, case=False, regex=False).any(), axis=1)
|
230 |
]
|
231 |
|
232 |
# Wy艣wietlenie tabeli historii analiz
|
|
|
255 |
|
256 |
# Wy艣wietlenie metryk dla filtrowanej historii
|
257 |
st.markdown("### " + translations['fraud_trend_title'])
|
258 |
+
col7, col8, col9, col10, col11, col12 = st.columns(6)
|
259 |
+
with col7:
|
260 |
card(
|
261 |
title=translations['total_analyses'],
|
262 |
text=str(total_filtered),
|
263 |
)
|
264 |
+
with col9:
|
265 |
card(
|
266 |
title=translations['total_frauds_detected'],
|
267 |
text=str(frauds_filtered),
|
268 |
)
|
269 |
+
with col11:
|
270 |
card(
|
271 |
title=translations['fraud_percentage'],
|
272 |
text=f"{fraud_percentage_filtered:.2f}%",
|