Skip to content

Commit

Permalink
Include updated and added dates for asset packs (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
Willy-JL authored Sep 28, 2024
1 parent 0e7db8f commit 4e04502
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions indexer/src/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import hashlib
import logging
import pathlib
import subprocess
from pydantic import BaseModel
from github import Github, Repository
from typing import List, ClassVar
Expand Down Expand Up @@ -58,6 +59,8 @@ class PackStats(BaseModel):
passport: List[str] = []
fonts: List[str] = []
folders: List[str] = []
updated: int = 0
added: int = 0


class Pack(BaseModel):
Expand Down Expand Up @@ -296,6 +299,19 @@ def parse(self, packpath: str) -> Pack:
)
pack.stats.anims = len(anims_names)

get_file_date = ["git", "log", "-1", r"--format=%ct"]
targz_file = f"download/{pack.id}.tar.gz"
updated = subprocess.check_output(
[*get_file_date, "--", targz_file],
cwd=pack_set,
)
pack.stats.updated = int(updated)
added = subprocess.check_output(
[*get_file_date, "--diff-filter=A", "--follow", "--", targz_file],
cwd=pack_set,
)
pack.stats.added = int(added)

for file in (pack_set / "download").iterdir():
if file.name.startswith(".") or not file.is_file():
continue
Expand Down

0 comments on commit 4e04502

Please sign in to comment.