Skip to content

Commit

Permalink
refactor: using uuid as category id
Browse files Browse the repository at this point in the history
  • Loading branch information
RanKKI committed May 25, 2023
1 parent cf54353 commit 9c0db39
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
Binary file modified DLC/广东地方法规/db.sqlite3
Binary file not shown.
Binary file modified DLC/重庆地方法规/db.sqlite3
Binary file not shown.
Binary file modified db.sqlite3
Binary file not shown.
6 changes: 3 additions & 3 deletions scripts/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import peewee

from datetime import datetime
from sqlite3 import Cursor

database = peewee.SqliteDatabase(None) # Defer initialization

Expand All @@ -17,7 +18,7 @@ class Meta:


class Category(BaseModel):
id = peewee.IntegerField(primary_key=True)
id = peewee.UUIDField(primary_key=True, default=uuid4)
name = peewee.TextField()
folder = peewee.TextField()
isSubFolder = peewee.BooleanField(default=False)
Expand Down Expand Up @@ -48,7 +49,7 @@ class Law(BaseModel):

tags = peewee.TextField(null=True)

category_id = peewee.ForeignKeyField(Category, backref="laws")
category_id = peewee.UUIDField(null=False)

def __repr__(self) -> str:
return f"<Law {self.name}>"
Expand Down Expand Up @@ -191,7 +192,6 @@ def update_database(self):
def get_law_count(self):
return Law.select().count()


def main():
args = sys.argv[1:]
if len(args) != 2:
Expand Down
8 changes: 7 additions & 1 deletion scripts/release.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#!/bin/bash

force=false
if [ "$1" == "-f" ]; then
force=true
fi

function pack {

out_path="$(pwd)/release"
Expand All @@ -15,7 +20,7 @@ function pack {
_hash=$(git log -n 1 --pretty=format:"%H" -- . ':!scripts' ':!.*' ':!DLC' | awk -F" " '{printf "%s", $1}')
_hash_file="$output_zip.hash"

if [ -f $_hash_file ]; then
if [ -f $_hash_file ] && [ ! $force ] ; then
if [ "$_hash" == "$(cat $_hash_file)" ]; then
echo "No changes detected, skipping..."
return
Expand All @@ -27,6 +32,7 @@ function pack {
echo $_hash > $_hash_file
}

echo "Force: $force"
cd ../
current_path=$(pwd)
pack "." "laws.zip"
Expand Down

0 comments on commit 9c0db39

Please sign in to comment.