Spaces:
Running
Running
Ron Au
commited on
Commit
•
4ddace2
1
Parent(s):
dc25089
feat(logs): Add semi-accurate saved count to logs
Browse files- app.py +2 -4
- static/js/index.js +6 -2
app.py
CHANGED
@@ -14,9 +14,6 @@ app.mount("/static", StaticFiles(directory="static"), name="static")
|
|
14 |
|
15 |
card_logs = []
|
16 |
|
17 |
-
# card_logs = [
|
18 |
-
# {pulls: 1, datetime: time()}
|
19 |
-
# ]
|
20 |
|
21 |
|
22 |
@app.head('/')
|
@@ -26,9 +23,10 @@ def index() -> FileResponse:
|
|
26 |
|
27 |
|
28 |
@app.get('/new_card')
|
29 |
-
def new_card(pull: int) -> Dict[str, Union[Details, str]]:
|
30 |
card_logs.append({
|
31 |
"pull": pull,
|
|
|
32 |
"datetime": strftime('%Y-%m-%dT%H:%M:%SZ', gmtime())
|
33 |
})
|
34 |
|
|
|
14 |
|
15 |
card_logs = []
|
16 |
|
|
|
|
|
|
|
17 |
|
18 |
|
19 |
@app.head('/')
|
|
|
23 |
|
24 |
|
25 |
@app.get('/new_card')
|
26 |
+
def new_card(pull: int, saved: int) -> Dict[str, Union[Details, str]]:
|
27 |
card_logs.append({
|
28 |
"pull": pull,
|
29 |
+
"saved": saved,
|
30 |
"datetime": strftime('%Y-%m-%dT%H:%M:%SZ', gmtime())
|
31 |
})
|
32 |
|
static/js/index.js
CHANGED
@@ -10,6 +10,7 @@ let useTrainerName = true;
|
|
10 |
let generating = false;
|
11 |
let mousemoveHandlerForPreviousCard;
|
12 |
let pulls = 0;
|
|
|
13 |
|
14 |
const generate = async () => {
|
15 |
if (generating) {
|
@@ -38,8 +39,10 @@ const generate = async () => {
|
|
38 |
await new Promise((resolve) => setTimeout(resolve, 2_000));
|
39 |
|
40 |
pulls += 1;
|
41 |
-
const resolvedCardUrl = new URL(
|
42 |
-
|
|
|
|
|
43 |
const cardResponse = await fetch(resolvedCardUrl);
|
44 |
const card = await cardResponse.json();
|
45 |
|
@@ -113,4 +116,5 @@ document.querySelector('button.save').addEventListener('click', async () => {
|
|
113 |
a.href = await screenshotCard();
|
114 |
a.download = `${updateCardName(trainerName, pokeName, useTrainerName)} - This Pokémon Does Not Exist.png`;
|
115 |
a.click();
|
|
|
116 |
});
|
|
|
10 |
let generating = false;
|
11 |
let mousemoveHandlerForPreviousCard;
|
12 |
let pulls = 0;
|
13 |
+
let saved = 0;
|
14 |
|
15 |
const generate = async () => {
|
16 |
if (generating) {
|
|
|
39 |
await new Promise((resolve) => setTimeout(resolve, 2_000));
|
40 |
|
41 |
pulls += 1;
|
42 |
+
const resolvedCardUrl = new URL(
|
43 |
+
`new_card?pull=${pulls}&saved=${saved}`,
|
44 |
+
document.location.origin + document.location.pathname
|
45 |
+
).href;
|
46 |
const cardResponse = await fetch(resolvedCardUrl);
|
47 |
const card = await cardResponse.json();
|
48 |
|
|
|
116 |
a.href = await screenshotCard();
|
117 |
a.download = `${updateCardName(trainerName, pokeName, useTrainerName)} - This Pokémon Does Not Exist.png`;
|
118 |
a.click();
|
119 |
+
saved += 1;
|
120 |
});
|