Skip to content

Commit

Permalink
Configuring datetime latest case identification
Browse files Browse the repository at this point in the history
  • Loading branch information
Zanger67 committed Jul 26, 2024
1 parent bdbd5d0 commit e134e2b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
17 changes: 11 additions & 6 deletions main.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@
"source": [
"# Categories besides those in lists\n",
"PRIMARY_CATEGORIES = set(['Daily', 'Weekly Premium', 'Contest', 'Favourite'])\n",
"# _OLDEST_DATE = datetime.now()\n",
"_OLDEST_DATE = datetime(2024, 7, 23)"
"_OLDEST_DATE = datetime.now()\n",
"# _OLDEST_DATE = datetime(2024, 7, 23)"
]
},
{
Expand Down Expand Up @@ -279,10 +279,6 @@
" creationDate = datetime.strptime(time.ctime(int(modifiedTimes[0])), '%a %b %d %H:%M:%S %Y')\n",
" modifiedDate = datetime.strptime(time.ctime(int(modifiedTimes[-1])), '%a %b %d %H:%M:%S %Y')\n",
" \n",
" global _OLDEST_DATE\n",
" if creationDate <_OLDEST_DATE:\n",
" _OLDEST_DATE = creationDate.replace(hour=0, minute=0, second=0, microsecond=0)\n",
"\n",
" except ValueError as ve:\n",
" print(f'Error in parsing {path}')\n",
" print(f'{modifiedTimes}')\n",
Expand Down Expand Up @@ -318,14 +314,23 @@
"\n",
" cmd = r\"git log --follow --format=%ct --reverse --\".split()\n",
" output = {}\n",
" \n",
" oldest_date = datetime.now()\n",
"\n",
" with tqdm(total=len(paths)) as pbar :\n",
" # with tqdm(total=len(paths), position=0, leave=True) as pbar :\n",
" for i, path in enumerate(paths) :\n",
" path = join(LEETCODE_PATH_FROM_README, path)\n",
" output[path] = individualCTimeViaGit(cmd + [path])\n",
" \n",
" if output[path][0] < _oldest_date :\n",
" _oldest_date = output[path][0]\n",
" \n",
" pbar.update(1)\n",
"\n",
" global _OLDEST_DATE\n",
" _OLDEST_DATE = _oldest_date\n",
"\n",
" # Usually I'd avoid using global for this but this is a personal project so it should be fine.\n",
" _ALL_GIT_CM_TIMES.update(output)\n",
" print(f'{_ALL_GIT_CM_TIMES = }')\n",
Expand Down
17 changes: 11 additions & 6 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@

# Categories besides those in lists
PRIMARY_CATEGORIES = set(['Daily', 'Weekly Premium', 'Contest', 'Favourite'])
# _OLDEST_DATE = datetime.now()
_OLDEST_DATE = datetime(2024, 7, 23)
_OLDEST_DATE = datetime.now()
# _OLDEST_DATE = datetime(2024, 7, 23)


# In[412]:
Expand All @@ -182,10 +182,6 @@ def individualCTimeViaGit(cmd: List[str]) -> Tuple[datetime, datetime] :
creationDate = datetime.strptime(time.ctime(int(modifiedTimes[0])), '%a %b %d %H:%M:%S %Y')
modifiedDate = datetime.strptime(time.ctime(int(modifiedTimes[-1])), '%a %b %d %H:%M:%S %Y')

global _OLDEST_DATE
if creationDate <_OLDEST_DATE:
_OLDEST_DATE = creationDate.replace(hour=0, minute=0, second=0, microsecond=0)

except ValueError as ve:
print(f'Error in parsing {path}')
print(f'{modifiedTimes}')
Expand Down Expand Up @@ -218,14 +214,23 @@ def getAllCTimesViaGit(paths: List[str]) -> Dict[str, Tuple[datetime, datetime]]

cmd = r"git log --follow --format=%ct --reverse --".split()
output = {}

oldest_date = datetime.now()

with tqdm(total=len(paths)) as pbar :
# with tqdm(total=len(paths), position=0, leave=True) as pbar :
for i, path in enumerate(paths) :
path = join(LEETCODE_PATH_FROM_README, path)
output[path] = individualCTimeViaGit(cmd + [path])

if output[path][0] < _oldest_date :
_oldest_date = output[path][0]

pbar.update(1)

global _OLDEST_DATE
_OLDEST_DATE = _oldest_date

# Usually I'd avoid using global for this but this is a personal project so it should be fine.
_ALL_GIT_CM_TIMES.update(output)
print(f'{_ALL_GIT_CM_TIMES = }')
Expand Down

0 comments on commit e134e2b

Please sign in to comment.