Skip to content

Commit c2ab0b3

Browse files
committed
Fix timezone fetch issue #61
Fix timezone fetch issue #61
1 parent e2a170c commit c2ab0b3

File tree

2 files changed

+121
-4
lines changed

2 files changed

+121
-4
lines changed

.github/workflows/publish_fast.yml

+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
name: Publish Release
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
tags:
7+
- v**
8+
branches:
9+
- debug_docker_image
10+
11+
env:
12+
REGISTRY_IMAGE: daya0576/beaverhabits
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
strategy:
18+
matrix:
19+
platform: [linux/amd64, linux/amd64/v3, linux/arm64]
20+
dockerfile: [Dockerfile]
21+
22+
steps:
23+
- name: Prepare
24+
id: prep
25+
run: |
26+
platform=${{ matrix.platform }}
27+
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
28+
29+
- name: Docker meta
30+
id: meta
31+
uses: docker/metadata-action@v5
32+
with:
33+
images: |
34+
${{ env.REGISTRY_IMAGE }}
35+
36+
- name: Checkout code
37+
uses: actions/checkout@v4
38+
39+
- name: Set up QEMU
40+
uses: docker/setup-qemu-action@v3
41+
42+
- name: Set up Docker Buildx
43+
uses: docker/setup-buildx-action@v3
44+
45+
- name: Login to DockerHub
46+
uses: docker/login-action@v3
47+
with:
48+
username: ${{ vars.DOCKER_USERNAME }}
49+
password: ${{ secrets.DOCKERHUB_TOKEN }}
50+
51+
- name: Build and push by digest
52+
id: build
53+
uses: docker/build-push-action@v6
54+
with:
55+
platforms: ${{ matrix.platform }}
56+
file: ${{ matrix.dockerfile }}
57+
labels: ${{ steps.meta.outputs.labels }}
58+
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
59+
cache-from: type=registry,ref=${{ env.REGISTRY_IMAGE }}:buildcache-${{ env.PLATFORM_PAIR }}
60+
cache-to: type=registry,ref=${{ env.REGISTRY_IMAGE }}:buildcache-${{ env.PLATFORM_PAIR }},mode=max
61+
62+
- name: Export digest
63+
run: |
64+
mkdir -p /tmp/digests
65+
digest="${{ steps.build.outputs.digest }}"
66+
touch "/tmp/digests/${digest#sha256:}"
67+
68+
- name: Upload digest
69+
uses: actions/upload-artifact@v4
70+
with:
71+
name: digests-${{ env.PLATFORM_PAIR }}
72+
path: /tmp/digests/*
73+
if-no-files-found: error
74+
retention-days: 1
75+
76+
merge:
77+
runs-on: ubuntu-latest
78+
needs:
79+
- build
80+
steps:
81+
- name: Download digests
82+
uses: actions/download-artifact@v4
83+
with:
84+
path: /tmp/digests
85+
pattern: digests-*
86+
merge-multiple: true
87+
88+
- name: Login to DockerHub
89+
uses: docker/login-action@v3
90+
with:
91+
username: ${{ vars.DOCKER_USERNAME }}
92+
password: ${{ secrets.DOCKERHUB_TOKEN }}
93+
94+
- name: Set up Docker Buildx
95+
uses: docker/setup-buildx-action@v3
96+
97+
- name: Docker meta
98+
id: meta
99+
uses: docker/metadata-action@v5
100+
with:
101+
images: |
102+
${{ env.REGISTRY_IMAGE }}
103+
tags: |
104+
type=ref,event=branch
105+
type=semver,pattern={{version}}
106+
type=semver,pattern={{major}}.{{minor}}
107+
type=sha
108+
109+
- name: Create manifest list and push
110+
working-directory: /tmp/digests
111+
run: |
112+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
113+
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
114+
115+
- name: Inspect image
116+
run: |
117+
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}

beaverhabits/views.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
from beaverhabits.storage import get_user_dict_storage, session_storage
1414
from beaverhabits.storage.dict import DAY_MASK, DictHabitList
1515
from beaverhabits.storage.storage import Habit, HabitList
16-
from beaverhabits.utils import dummy_days, generate_short_hash
16+
from beaverhabits.utils import generate_short_hash
1717

1818
user_storage = get_user_dict_storage()
1919

2020

2121
def dummy_habit_list(days: list[datetime.date]):
22-
pick = lambda: random.randint(0, 3) == 0
22+
pick = lambda: random.randint(0, 5) == 0
2323
items = [
2424
{
2525
"id": generate_short_hash(name),
@@ -89,7 +89,6 @@ async def get_or_create_user_habit_list(
8989
return await get_user_habit_list(user)
9090
except HTTPException:
9191
logger.warning(f"Failed to load habit list for user {user.email}")
92-
pass
9392

9493
logger.info(f"Creating dummy habit list for user {user.email}")
9594
await user_storage.save_user_habit_list(user, dummy_habit_list(days))
@@ -130,7 +129,8 @@ async def login_user(user: User) -> None:
130129
async def register_user(email: str, password: str = "") -> User:
131130
user = await user_create(email=email, password=password)
132131
# Create a dummy habit list for the new users
133-
await get_or_create_user_habit_list(user, await dummy_days(31))
132+
days = [datetime.date.today() - datetime.timedelta(days=i) for i in range(30)]
133+
await get_or_create_user_habit_list(user, days)
134134
return user
135135

136136

0 commit comments

Comments
 (0)