dev #2

Merged
WorldTeacher merged 2 commits from dev into main 2025-05-23 16:16:11 +01:00
4 changed files with 190 additions and 3 deletions

View File

@@ -0,0 +1,34 @@
name: Bug Report
description: Report a bug in this project
labels:
- kind/bug
- triage
body:
- type: textarea
id: bug
attributes:
label: Describe the bug
description: |
A clear and concise description of what the bug is.
What did you expect to happen? What happened instead?
Include screenshots if applicable.
validations:
required: true
- type: textarea
id: reproduction
attributes:
label: Steps to reproduce
description: |
A clear and concise description of how to reproduce the bug.
Include steps, code snippets, or screenshots if applicable.
validations:
required: true
- type: textarea
id: additional-info
attributes:
label: Additional information
description: |
Add any other context or screenshots about the bug here.

View File

@@ -0,0 +1,23 @@
name: Feature request
description: Suggest an idea for this project
labels:
- kind/feature
- triage
body:
- type: textarea
id: feature
attributes:
label: Describe the feature
description: |
A clear and concise description of what the feature is.
What is the problem it solves? What are you trying to accomplish?
Include screenshots if applicable.
validations:
required: true
- type: textarea
id: additional-info
attributes:
label: Additional information
description: |
Add any other context or screenshots about the feature request here.

View File

@@ -0,0 +1,80 @@
on:
workflow_dispatch:
inputs:
release_notes:
description: Release notes (use \n for newlines)
type: string
required: false
github_release:
description: 'Create Gitea Release'
default: true
type: boolean
bump:
description: 'Bump type'
required: true
default: 'patch'
type: choice
options:
- 'major'
- 'minor'
- 'patch'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@master
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Set up Python
run: uv python install
- name: Set Git identity
run: |
git config user.name "Gitea CI"
git config user.email "ci@git.theprivateserver.de"
- name: Bump version
id: bump
run: |
uv tool install bump-my-version
uv tool run bump-my-version bump ${{ github.event.inputs.bump }}
# echo the version to github env, the version is shown by using uv tool run bump-my-version show current_version
echo "VERSION<<EOF" >> $GITHUB_ENV
echo "$(uv tool run bump-my-version show current_version)" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
- name: Create release notes
run: |
mkdir release_notes
echo -e "${{ inputs.release_notes }}" >> release_notes/release_notes.md
echo "Release notes:"
cat release_notes/release_notes.md
echo ""
- name: Build package
run: uv build
- name: Publish package
env:
USERNAME: ${{ github.repository_owner }}
run: uv publish --publish-url https://git.theprivateserver.de/api/packages/$USERNAME/pypi/ -t ${{ secrets.TOKEN }}
- name: Create release
id: create_release
if: ${{ github.event.inputs.github_release == 'true' }}
uses: softprops/action-gh-release@master
with:
tag_name: ${{ env.VERSION }}
release_name: Release ${{ env.VERSION }}
body_path: release_notes/release_notes.md
draft: false
prerelease: false
make_latest: true
files: |
dist/*
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}

View File

@@ -2,6 +2,12 @@ import sqlite3
from komconfig import KomConfig, CONFIG_PATH
from pathlib import Path
import os
import loguru
log = loguru.logger
log.remove()
log.add("logs/cache.log", level="INFO", rotation="15MB", retention="1 week")
log.add("logs/cli.log", rotation="15MB", retention="1 week") # type:ignore
class KomCache:
@@ -9,7 +15,6 @@ class KomCache:
self.db_path = Path(db_path, "komcache.db")
if "~" in str(self.db_path):
self.db_path = os.path.expanduser(str(self.db_path))
print(f"Database path: {self.db_path}")
self.conn = sqlite3.connect(self.db_path)
self.cursor = self.conn.cursor()
@@ -54,12 +59,16 @@ class KomCache:
args = []
try:
self.cursor.execute(query, args)
return self.cursor.fetchall()[0]
data = self.cursor.fetchall()
if data:
return data
else:
return None
except sqlite3.Error as e:
print(f"Error executing query: {e}")
return []
def insert(self, query, args=None):
def insert(self, query: str, args=None):
if args is None:
args = []
try:
@@ -75,12 +84,53 @@ class KomCache:
args = []
try:
self.cursor.execute(query, args)
log.debug("Query: {}, Args: {}".format(query, args))
self.conn.commit()
return True
except sqlite3.Error as e:
print(f"Error updating data: {e}")
return False
def get_last_update_date(self, series_name: str) -> str:
"""
Get the last update date for a series.
Parameters
----------
series_name : str
The name of the series.
Returns
-------
str
The last update date.
"""
query = "SELECT last_update_date FROM komgrabber WHERE series_name = ?"
result = self.query(query, (series_name,))
if result:
return result[0][0]
return ""
def fetch_one(self, query: str, args=None):
if args is None:
args = []
try:
self.cursor.execute(query, args)
return self.cursor.fetchone()
except sqlite3.Error as e:
print(f"Error fetching one: {e}")
return None
def fetch_all(self, query: str, args=None):
if args is None:
args = []
try:
self.cursor.execute(query, args)
return self.cursor.fetchall()
except sqlite3.Error as e:
print(f"Error fetching one: {e}")
return None
if __name__ == "__main__":
# Example usage