Skip to content

Commit

Permalink
Made changes.
Browse files Browse the repository at this point in the history
parent 57aafeb
author bkulawska <kulawska1507@gmail.com> 1652259157 +0200
committer bkulawska <kulawska1507@gmail.com> 1652260859 +0200

Made suggested changes.

Fixed tags adding

[NOJIRA] feat: add github bot (#40)

* feat: add github bot

* fix: github bot run

* fix: another fix approach

* feat: add quotes

* feat: rename and fix indentation

* feat: improve order and fix yml syntax

* fix: excluded labels

* fix: plzkillmeicannotwriteinyaml

* fix: maybeorderchangewillhelp

* fix: dontworryillsquashitanyway

* fix: ifitisjustthisindentihateyaml

* fix: avadakedavra

* fix: maybedots?

Fixed import.

damniwillsquashitiswear
  • Loading branch information
bkulawska committed May 11, 2022
1 parent 57aafeb commit af4a1a1
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .github/auto_assign.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
addAssignees: author
runOnDraft: true
36 changes: 36 additions & 0 deletions .github/labeler.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
config:
- '.github/**/*'
- '.vscode/**/*'
- bode/*
- bode/.hooks/**/*
- cabra/*
- cabra/.hooks/**/*
- any:
- '*'
- '!**/package.json'
- '!**/package-lock.json'
- '!**/poetry.lock'
- '!**/pyproject.toml'

deps:
- '**/package.json'
- '**/package-lock.json'
- '**/poetry.lock'
- '**/pyproject.toml'

bode:
- any:
- bode/**/*
- '!bode/migrations/**/*'

database:
- bode/migrations/**/*

cabra:
- cabra/**/*

test:
- bode/**/test_*.py
- bode/**/*_test.py
- cabra/**/*.spec.*
- cabra/**/*.test.*
25 changes: 25 additions & 0 deletions .github/workflows/auto_fill.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: "Auto Fill"
on:
pull_request:
branches:
- develop
types: [opened, edited, reopened, synchronize]

jobs:
auto-assign:
runs-on: ubuntu-latest
steps:
- uses: kentaro-m/auto-assign-action@v1.2.1
with:
configuration-path: ".github/auto_assign.yaml"

labels:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@v4
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
configuration-path: ".github/labeler.yaml"
2 changes: 2 additions & 0 deletions bode/bode/models/task_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ def is_interchangable_relation(relation):
task = Task.get(task_id)

for key, value in task_data.items():
if key == "tags":
continue
setattr(task, key, value)

db.session.commit()
Expand Down
22 changes: 8 additions & 14 deletions bode/bode/models/task_relations_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,18 @@ def get_related_tasks(task_id):
def map_to_related_task_schema(relation: TaskRelation, task_id):
match relation.type:
case RelationType.Dependent.value:
type = (
DirectedRelationType.Blocks.value
if task_id == relation.first_task_id
else DirectedRelationType.IsBlockedBy.value
)
if task_id == relation.first_task_id:
return DirectedRelationType.Blocks.value
return DirectedRelationType.IsBlockedBy.value
case RelationType.Subtask.value:
type = (
DirectedRelationType.Supertask.value
if task_id == relation.first_task_id
else DirectedRelationType.Subtask.value
)
if task_id == relation.first_task_id:
return DirectedRelationType.Supertask.value
return DirectedRelationType.Subtask.value
case _:
type = DirectedRelationType.Interchangable.value

return type
return DirectedRelationType.Interchangable.value


def get_relation_types(task_id):
filters = [TaskRelation.first_task_id == task_id or TaskRelation.second_task_id == task_id]
relations = TaskRelation.query.filter(*filters).all()
relations = db.session.query(TaskRelation).filter(*filters).all()
return {map_to_related_task_schema(relation, task_id) for relation in relations}
16 changes: 15 additions & 1 deletion bode/bode/resources/tasks/schemas.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
from enum import Enum

from marshmallow import EXCLUDE, fields, validate

from bode.models.task import TaskStatus
from bode.resources.base_schema import BaseSchema
from bode.resources.tags.schemas import TagInputSchema, TagSchema


class DirectedRelationType(Enum):
Blocks = "blocks"
IsBlockedBy = "is_blocked_by"
Subtask = "subtask"
Supertask = "supertask"
Interchangable = "interchangable"

@classmethod
def list(cls):
return [c.value for c in cls]


class TaskInputSchema(BaseSchema):
class Meta:
unknown = EXCLUDE
Expand All @@ -23,4 +37,4 @@ class TaskSchema(BaseSchema):
due_date = fields.DateTime()
status = fields.String()
tags = fields.List(fields.Nested(TagSchema))
relation_types = fields.List(fields.String())
relation_types = fields.List(fields.String(validate=validate.OneOf(DirectedRelationType.list())))

0 comments on commit af4a1a1

Please sign in to comment.