Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 2 Release #6

Merged
merged 28 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
c9a9b1b
breaking: Fixed #1
creyD Oct 24, 2024
4a5a777
breaking: Fixed #3
creyD Oct 24, 2024
cfa1da0
fix: pipeline now pushes pre-release versions
creyD Oct 24, 2024
851573d
fix: fixed pipeline tagging
creyD Oct 24, 2024
aa44b9e
fix: fixed pipeline tagging
creyD Oct 24, 2024
8740eaf
fix: fixed pipeline tagging
creyD Oct 24, 2024
983553e
fix: locked tag and publish to master and dev
creyD Oct 24, 2024
f11b8b8
fix: alternative attempt on the fix
creyD Oct 24, 2024
c91e684
fix: fix attempt for the github pipeline
creyD Oct 24, 2024
5f39966
fix: Fixed tag pushing and changelog
creyD Oct 24, 2024
39ae74b
fix: minor changelog adjustment
creyD Oct 24, 2024
c7e205f
fix: fixed naming of pre-release commits
creyD Oct 24, 2024
714178d
fix: fixed naming of pre-release commits
creyD Oct 24, 2024
3f4a0ee
fix: fixed naming of pre-release commits
creyD Oct 24, 2024
d6f79c3
fix: fixed naming of pre-release commits
creyD Oct 24, 2024
d54146e
fix: fixed naming of pre-release commits
creyD Oct 24, 2024
0bf89fe
fix: switched to semantic versioning action
creyD Oct 25, 2024
5903de2
fix: fixed semantic versioning format selector
creyD Oct 25, 2024
8463eef
fix: attempt on fixing the versioning issue
creyD Oct 25, 2024
0bed0e0
fix: attempt on fixing the versioning issue
creyD Oct 25, 2024
c24f893
fix: attempt on fixing the versioning issue
creyD Oct 25, 2024
89351d7
fix: debugging pipeline
creyD Oct 25, 2024
6d5411a
fix: debugging pipeline
creyD Oct 25, 2024
e381992
fix: fixing dev versioning
creyD Oct 25, 2024
378d1d6
fix: adjusting pipeline for prod as well
creyD Oct 25, 2024
b7df0bf
fix: added escape for variable names
creyD Oct 25, 2024
5a32a59
Removed debug statement
creyD Oct 25, 2024
c5b2ab9
fix: Add condition for total greater than zero (#7)
vikynoah Oct 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 22 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ on:
- master
- dev
paths-ignore:
- "**/.github/**"
- "**/.gitignore"
- "**/.vscode/**"
- "**/README.md"
Expand Down Expand Up @@ -46,8 +45,8 @@ jobs:
- run: python test.py

tag_and_publish:
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
if: github.head_ref == 'master' || github.head_ref == 'dev'
needs: test
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
Expand All @@ -57,26 +56,38 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-tags: true
ref: ${{ github.ref }}
ref: ${{ github.head_ref }}
fetch-depth: 0

- name: setup git
run: |
git config --local user.email "[email protected]"
git config --local user.name "creyD"

- name: set version format
id: version_format
run: |
if [[ ${{ github.head_ref }} == 'master' ]]; then
echo "version_format=\${major}.\${minor}.\${patch}" >> $GITHUB_OUTPUT
else
echo "version_format=\${major}.\${minor}.\${patch}rc\${increment}" >> $GITHUB_OUTPUT
fi

- name: Git Version
uses: codacy/git-version@2.8.0
uses: PaulHatch/semantic-version@v5.4.0
id: git_version
with:
minor-identifier: "feat:"
major-identifier: "breaking:"
tag_prefix: ""
major_pattern: "breaking:"
minor_pattern: "feat:"
enable_prerelease_mode: false
version_format: ${{ steps.version_format.outputs.version_format }}

- name: Create Tag
run: git tag ${{ steps.git_version.outputs.version }}

- name: Push tag
run: git push origin ${{ steps.git_version.outputs.version }}
- name: Create & Push Tag
if: github.head_ref == 'master' || github.head_ref == 'dev'
run: |
git tag ${{ steps.git_version.outputs.version }}
git push origin ${{ steps.git_version.outputs.version }}

- name: Set up Python
uses: actions/setup-python@v5
Expand Down
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@

All notable changes to this project will be documented in this file.

## 2.0.0

- Fixed #1 Rename misspelled additonal_data to additional_data on create_obj_from_data
- Fixed #3 Inverse partial flag: bool = False because it was wrong on update_obj_from_data

Notes:

You will need to change calls to `create_obj_from_data` according to #1 (rename additonal_data to additional_data)

You will need to change calls to `update_obj_from_data` according to #3 (if you supplied `partial`, you will need to reverse it: `true` -> `false` and `false` -> `true`)

## 1.3.0

- Addition of pagination proxy and pagination=off functionality (Thanks to @vikbhas)

## 1.2.5

- Bumped dependencies

## 1.2.4

- Enabled newer versions for all dependencies
Expand Down
8 changes: 4 additions & 4 deletions creyPY/fastapi/crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ def get_object_or_404(

# TODO: Add testing
def create_obj_from_data(
data: BaseModel, model: Type[T], db: Session, additonal_data={}, exclude={}
data: BaseModel, model: Type[T], db: Session, additional_data={}, exclude={}
) -> T:
obj = model(**data.model_dump(exclude=exclude) | additonal_data)
obj = model(**data.model_dump(exclude=exclude) | additional_data)
db.add(obj)
db.commit()
db.refresh(obj)
Expand All @@ -38,13 +38,13 @@ def update_obj_from_data(
model: Type[T],
id: UUID | str,
db: Session,
partial: bool = False, # TODO: inverse, because it is currently the wrong way around
partial: bool = True,
ignore_fields=[],
additional_data={},
exclude={},
) -> T:
obj = get_object_or_404(model, id, db)
data_dict = data.model_dump(exclude_unset=not partial, exclude=exclude)
data_dict = data.model_dump(exclude_unset=partial, exclude=exclude)
data_dict.update(additional_data) # merge additional_data into data_dict
for field in data_dict:
if field not in ignore_fields:
Expand Down
5 changes: 2 additions & 3 deletions creyPY/fastapi/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,12 @@ def paginate(
transformer: Optional[SyncItemsTransformer] = None,
additional_data: Optional[AdditionalData] = None,
):

params, raw_params = verify_params(params, "limit-offset", "cursor")
params, _ = verify_params(params, "limit-offset", "cursor")

count_query = create_count_query(query)
total = connection.scalar(count_query)

if paginationFlag is False:
if paginationFlag is False and total > 0:
params = Params(page=1, size=total)

query = create_paginate_query(query, params)
Expand Down