Skip to content

Commit

Permalink
Release 0.3.1 (#4)
Browse files Browse the repository at this point in the history
* [FIX] Skillfarm Overview

* [FIX] Last Update not shown

* [MISC] Changelog

* [FIX] Skill Queue is_active function

* [ADD] Add is_active check on skillfarm api

* [MISC] Update Pre Commit

* [CHANGE] JS progressbar & No Active Skill Training now check via is_active variable

* [ADD] skill exctraction checker
[FIX] wrong progress bar caclculation for filtered skills

* [MISCC] Add missing models

* [ADD] Skill Extraction Checcker

* [ADD] finish skill checker

* [MISC] Update Changelog

* [MISC] Update Readme

* [ADD] Notification Cooldown

* [REMOVE] SkillFarmNotification Model

* [ADD] Notification System
[REMOVE] Notification Model
[ADD] Finished Skill Checker
[ADD] is_cooldown property

* [ADD] Skillfarm Notification Task

* [UPDATE] Update Migration

* [MISC] Update README

* [FIX] Cyclic Import

* [FIX] Empty Queue not be deleted

* [ADD] switch activity settings

* [REMOVE] remove active filter

* [CHANGE] Set default cooldown to 3 days

* [ADD] Acitivty Switcher
[CHANGE] Add Character forces updates

* [FIX] old code delete entry

* [UPDATE] CSS Design
[ADD] Inactive Table

* [UPDATE] More CSS Fixes

* [MISC] Update Changelog

* [FIX] Cyclic Import

* [FIX] Maybe now

* [CHANGE] Update only active characters

* [CHANGE] Ensure that only set `notification_sent` if sent

* [MISC] Update README

* Bump to 0.3.1

---------

Co-authored-by: Geuthur <[email protected]>
  • Loading branch information
Geuthur and Geuthur authored Oct 24, 2024
1 parent bffadf1 commit b724d98
Show file tree
Hide file tree
Showing 22 changed files with 447 additions and 105 deletions.
3 changes: 1 addition & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ repos:
.min(.js|.js.map)|
static/(.*)/libs/
)
#args:
# - --fix
args: [--fix, --color, --max-warnings, '0']

- repo: https://github.com/thibaudcolas/pre-commit-stylelint
rev: v16.10.0
Expand Down
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
# Changelog

## \[0.3.1\] - 2024-10-23

### Added

- Skill Extraction Checker
- FInished Skill Checker
- Notification System
- Activity Switcher
- Inactive Character Table

### Changed

- Skilltraining Bool now handled by geuthuris_active property
- JS ´No Active Training´ function to new is_active property
- Add Character init force update
- CSS Improvments
- Update only active characters

### Fixed

- ChararcterQueue is_active property not working correctly
- Last Update was not implemented to new system
- Skillfarm Overview error
- Missing Models in init
- Empty Queue not be deleted

## \[0.3.0\] - 2024-10-21

### Fixed
Expand Down
24 changes: 14 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,10 @@ ______________________________________________________________________
- Filtered Skill Queue
- Filtered Skills
- Highlight finished Skills
- No Active Training hint
- Filter Skills for each Character
- No Active Training hint

## Upcoming<a name="upcoming"></a>

- Notififcation System
- Notification System
- Enable/Disable Characters

## Installation<a name="installation"></a>

Expand Down Expand Up @@ -72,6 +70,11 @@ CELERYBEAT_SCHEDULE["skillfarm_update_all_skillfarm"] = {
"task": "skillfarm.tasks.update_all_skillfarm",
"schedule": crontab(minute=0, hour="*/1"),
}

CELERYBEAT_SCHEDULE["skillfarm_check_skillfarm_notifications"] = {
"task": "skillfarm.tasks.check_skillfarm_notifications",
"schedule": crontab(minute=0, hour="*/12"),
}
```

### Step 4 - Migration to AA<a name="step4"></a>
Expand All @@ -95,11 +98,12 @@ With the Following IDs you can set up the permissions for the Skillfarm

The Following Settings can be setting up in the `local.py`

- SKILLFARM_APP_NAME: `"YOURNAME"` - Set the name of the APP

- SKILLFARM_LOGGER_USE: `True / False` - Set to use own Logger File

- SKILLFARM_STALE_STATUS: `3` - Set the Stale Status for Skillfarm Character in hours
| Setting Name | Descriptioon | Default |
| --------------------------------- | ------------------------------------------------------ | ------------- |
| `SKILLFARM_APP_NAME` | Set the name of the APP | `"Skillfarm"` |
| `SKILLFARM_LOGGER_USE` | Set to use own Logger File `True/False` | `False` |
| `SKILLFARM_STALE_STATUS` | Set the Stale Status for Skillfarm Character in hours | `3` |
| `SKILLFARM_NOTIFICATION_COOLDOWN` | Number of days to wait before resending a notification | `3` |

If you set up SKILLFARM_LOGGER_USE to `True` you need to add the following code below:

Expand Down
2 changes: 1 addition & 1 deletion skillfarm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from skillfarm.app_settings import SKILLFARM_APP_NAME

__version__ = "0.3.0"
__version__ = "0.3.1"
__title__ = "Skillfarm"

USER_AGENT_TEXT = f"{SKILLFARM_APP_NAME} v{__version__}"
12 changes: 10 additions & 2 deletions skillfarm/api/character/skillfarm.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
)
from skillfarm.hooks import get_extension_logger
from skillfarm.models.characterskill import CharacterSkill
from skillfarm.models.skillfarmaudit import SkillFarmAudit, SkillFarmSetup
from skillfarm.models.skillfarmaudit import SkillFarmAudit
from skillfarm.models.skillfarmsetup import SkillFarmSetup
from skillfarm.models.skillqueue import CharacterSkillqueueEntry

logger = get_extension_logger(__name__)
Expand Down Expand Up @@ -105,6 +106,7 @@ def get_character_skillfarm(request, character_id: int):
).select_related(
"eve_type",
)

skillsqueue_filtered = skillsqueue.filter(character_filters)

def process_skill_queue_entry(entry):
Expand Down Expand Up @@ -147,6 +149,12 @@ def process_skill_queue_entry(entry):
"skillqueuefiltered": skillqueuefiltered_data,
"skillqueue": skillqueue_data,
"skills": skills_data,
"is_active": any(entry.is_active for entry in skillsqueue),
"extraction_ready": (
any(entry.is_exc_ready for entry in skills)
if skillset
else False
),
}
)

Expand All @@ -160,7 +168,7 @@ def process_skill_queue_entry(entry):
tags=self.tags,
)
def get_character_admin(request):
chars_visible = SkillFarmAudit.objects.visible_characters(request.user)
chars_visible = SkillFarmAudit.objects.visible_eve_characters(request.user)

if chars_visible is None:
return 403, "Permission Denied"
Expand Down
2 changes: 1 addition & 1 deletion skillfarm/api/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from allianceauth.eveonline.models import EveCharacter

from skillfarm.hooks import get_extension_logger
from skillfarm.models import SkillFarmAudit
from skillfarm.models.skillfarmaudit import SkillFarmAudit

logger = get_extension_logger(__name__)

Expand Down
2 changes: 2 additions & 0 deletions skillfarm/api/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class SkillFarm(Schema):
skillset: Any
skills: Any
skill_names: Any
is_active: Optional[bool]
extraction_ready: Optional[bool]


class SkillFarmFilter(Schema):
Expand Down
3 changes: 3 additions & 0 deletions skillfarm/app_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,6 @@

# Update Period for Skillfarm in Hours
SKILLFARM_STALE_STATUS = clean_setting("SKILLFARM_STALE_STATUS", 3)

# Set Notification Cooldown in Days
SKILLFARM_NOTIFICATION_COOLDOWN = clean_setting("SKILLFARM_NOTIFICATION_COOLDOWN", 3)
2 changes: 1 addition & 1 deletion skillfarm/managers/characterskill.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from skillfarm.task_helper import NotModifiedError, etag_results

if TYPE_CHECKING:
from skillfarm.models import SkillFarmAudit
from skillfarm.models.skillfarmaudit import SkillFarmAudit

logger = get_extension_logger(__name__)

Expand Down
6 changes: 3 additions & 3 deletions skillfarm/managers/skillqueue.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from skillfarm.task_helper import NotModifiedError, etag_results

if TYPE_CHECKING:
from skillfarm.models import SkillFarmAudit
from skillfarm.models.skillfarmaudit import SkillFarmAudit

from skillfarm.hooks import get_extension_logger

Expand All @@ -21,7 +21,7 @@ def update_or_create_esi(
"""Update or create skills queue for a character from ESI."""
skillqueue = self._fetch_data_from_esi(character, force_refresh=force_refresh)

if not skillqueue:
if skillqueue is None:
return False

entries = []
Expand Down Expand Up @@ -52,7 +52,7 @@ def _fetch_data_from_esi(
) -> list[dict]:
logger.debug("%s: Fetching skill queue from ESI", character)

skillqueue = []
skillqueue = None
token = character.get_token()
try:
skillqueue_data = esi.client.Skills.get_characters_character_id_skillqueue(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Generated by Django 4.2.11 on 2024-10-22 21:21

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("skillfarm", "0001_initial"),
]

operations = [
migrations.AddField(
model_name="skillfarmaudit",
name="last_notification",
field=models.DateTimeField(blank=True, default=None, null=True),
),
migrations.AddField(
model_name="skillfarmaudit",
name="notification_sent",
field=models.BooleanField(default=False),
),
migrations.DeleteModel(
name="SkillFarmNotification",
),
]
1 change: 1 addition & 0 deletions skillfarm/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from .characterskill import CharacterSkill
from .general import General
from .skillfarmaudit import SkillFarmAudit
from .skillfarmsetup import SkillFarmSetup
from .skillqueue import CharacterSkillqueueEntry
21 changes: 21 additions & 0 deletions skillfarm/models/characterskill.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,24 @@ class Meta:

def __str__(self) -> str:
return f"{self.character}-{self.eve_type.name}"

@property
def is_exc_ready(self) -> bool:
"""Check if skill extraction is ready."""
# pylint: disable=import-outside-toplevel
from skillfarm.models.skillfarmsetup import SkillFarmSetup

try:
character = SkillFarmSetup.objects.get(character=self.character)
except SkillFarmSetup.DoesNotExist:
character = None

if character and character.skillset is not None:
skills = CharacterSkill.objects.filter(
character=self.character,
eve_type__name__in=character.skillset,
)
for skill in skills:
if skill.trained_skill_level == 5:
return True
return False
81 changes: 39 additions & 42 deletions skillfarm/models/skillfarmaudit.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ class SkillFarmAudit(models.Model):
)

notification = models.BooleanField(default=False)
notification_sent = models.BooleanField(default=False)
last_notification = models.DateTimeField(null=True, default=None, blank=True)

last_update_skills = models.DateTimeField(null=True, default=None, blank=True)

last_update_skillqueue = models.DateTimeField(null=True, default=None, blank=True)

objects = SkillFarmManager()
Expand Down Expand Up @@ -59,6 +60,30 @@ def get_token(self) -> Token:
return token
return False

def finished_skills(self) -> list[str]:
"""Check if a character has a skill finished from filter."""
# pylint: disable=import-outside-toplevel
from skillfarm.models.characterskill import CharacterSkill
from skillfarm.models.skillfarmsetup import SkillFarmSetup

skill_names = []
try:
character = SkillFarmSetup.objects.get(character=self)
except SkillFarmSetup.DoesNotExist:
character = None

if character and character.skillset is not None:
skills = CharacterSkill.objects.filter(
character=self,
eve_type__name__in=character.skillset,
)

for skill in skills:
if skill.trained_skill_level == 5:
skill_names.append(skill.eve_type.name)
return skill_names

@property
def is_active(self):
time_ref = timezone.now() - datetime.timedelta(
days=app_settings.SKILLFARM_CHAR_MAX_INACTIVE_DAYS
Expand All @@ -77,45 +102,17 @@ def is_active(self):
except Exception: # pylint: disable=broad-exception-caught
return False

@property
def is_cooldown(self) -> bool:
"""Check if a character has a notification cooldown."""
if self.last_notification is None:
return False

class SkillFarmSetup(models.Model):
id = models.AutoField(primary_key=True)

character = models.OneToOneField(
SkillFarmAudit, on_delete=models.CASCADE, related_name="skillfarm_setup"
)

skillset = models.JSONField(default=dict, blank=True, null=True)

def __str__(self):
return f"{self.skillset}'s Skill Setup"

objects = SkillFarmManager()

class Meta:
default_permissions = ()


class SkillFarmNotification(models.Model):
"""Skillfarm Notification model for app"""

id = models.AutoField(primary_key=True)

character = models.OneToOneField(
SkillFarmAudit, on_delete=models.CASCADE, related_name="skillfarm_notification"
)

message = models.TextField()

timestamp = models.DateTimeField(auto_now_add=True)

objects = SkillFarmManager()

def __str__(self):
return f"{self.character.character.character_name}'s Notification"

class Meta:
default_permissions = ()
ordering = ["-timestamp"]
verbose_name = "Skillfarm Notification"
verbose_name_plural = "Skillfarm Notifications"
if self.last_notification < timezone.now() - datetime.timedelta(
days=app_settings.SKILLFARM_NOTIFICATION_COOLDOWN
):
self.last_notification = None
self.notification_sent = False
self.save()
return False
return True
26 changes: 26 additions & 0 deletions skillfarm/models/skillfarmsetup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""Models for Skillfarm."""

from django.db import models

from skillfarm.hooks import get_extension_logger
from skillfarm.managers.skillfarmaudit import SkillFarmManager

logger = get_extension_logger(__name__)


class SkillFarmSetup(models.Model):
id = models.AutoField(primary_key=True)

character = models.OneToOneField(
"SkillFarmAudit", on_delete=models.CASCADE, related_name="skillfarm_setup"
)

skillset = models.JSONField(default=dict, blank=True, null=True)

def __str__(self):
return f"{self.skillset}'s Skill Setup"

objects = SkillFarmManager()

class Meta:
default_permissions = ()
2 changes: 1 addition & 1 deletion skillfarm/models/skillqueue.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ def __str__(self) -> str:
@property
def is_active(self) -> bool:
"""Returns true when this skill is currently being trained"""
return bool(self.finish_date) and self.queue_position == 0
return bool(self.finish_date) and self.finish_date > self.start_date
Loading

0 comments on commit b724d98

Please sign in to comment.