Skip to content

Commit

Permalink
refactor: clean up word counts
Browse files Browse the repository at this point in the history
- Remove unnecessary imports
- Add meaningful cumulative word count hover label
  • Loading branch information
cblanken committed Oct 28, 2024
1 parent f34e00b commit 9f0f419
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions stats/charts/word_counts.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
from django.db.models import Q, Sum, Func
import plotly.graph_objects as go
from plotly.graph_objects import Figure
import plotly.express as px
import numpy as np
from stats.models import Chapter, Book
from stats.models import Chapter
from .config import DEFAULT_LAYOUT

chapter_data = (
Expand All @@ -13,14 +11,6 @@
)


def longest_chapter() -> Chapter:
chapter_data.order_by("-word_count")[0]


def longest_interlude() -> Chapter:
chapter_data.filter(is_interlude=True).order_by("-word_count")[0]


def word_count_per_chapter() -> Figure:
"""Word counts per chapter"""
chapter_wc_fig = px.scatter(
Expand Down Expand Up @@ -72,7 +62,7 @@ def word_count_cumulative() -> Figure:
y="cumsum",
labels=dict(
post_date="Post Date",
word_count="Total Word Count",
cumsum="Total Word Count",
),
)

Expand Down Expand Up @@ -120,7 +110,6 @@ def word_count_authors_note() -> Figure:


def word_count_by_book() -> Figure:
# Word counts grouped by book
book_wc_data = (
Chapter.objects.filter(~Q(book__title__contains="Unreleased"))
.values(
Expand Down

0 comments on commit 9f0f419

Please sign in to comment.