improve calendar performance

This commit is contained in:
Your Name 2023-04-21 18:27:49 -04:00 committed by Henri Dickson
parent 6ec00af32a
commit 02f90ced15
6 changed files with 30 additions and 7 deletions

View file

@ -330,7 +330,7 @@ def discover(request):
]
episodes = PodcastEpisode.objects.filter(program_id__in=podcast_ids).order_by(
"-pub_date"
)[:10]
)[:5]
gallery_list.insert(
0,
{

View file

@ -36,6 +36,7 @@
var current_date = new Date();
var start_date = new Date();
start_date.setMonth(end_date.getMonth() - 12);
end_year = end_date.getFullYear()
var start_weekday = settings.start_monday === true?1:0;
for (var i = 0; i < 7; i++) {
@ -148,7 +149,7 @@
// Add labels for Months
for (var i = 0; i < month_position.length; i++) {
var item = month_position[i];
var month_name = settings.month_names[item.month_index];
var month_name = item.month_index ? settings.month_names[item.month_index] : end_year;
loop_html += '<text x="' + item.x + '" y="-5" class="month">' + month_name + '</text>';
}
@ -167,7 +168,7 @@
// Fixed size with width= 721 and height = 110
var wire_html =
'<svg width="721" height="110">' +
'<g transform="translate(25, 20)">' +
'<g transform="translate(0, 20)">' +
loop_html +
'</g>' + '"Your browser does not support inline SVG."' +
'</svg>';
@ -231,7 +232,7 @@
day_names: ['M', 'W', 'F', 'S'],
start_monday: true,
always_show_tooltip: false,
stylize_today: true,
stylize_today: false,
final_date: new Date().toISOString().slice(0, 10),
tooltip_style: 'default', // or 'custom'
data: []

View file

@ -560,13 +560,13 @@ $mark-review-padding-wider: 6px 0
.calendar_view
left: -20px
position: relative
// Medium devices (tablets, 768px and up)
@media (max-width: $medium-devices)
.calendar_view
overflow-x: scroll
// Large devices (desktops, 992px and up)
@media (max-width: $large-devices)
.main-section-wrapper

View file

@ -0,0 +1,19 @@
# Generated by Django 3.2.18 on 2023-04-21 22:23
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("journal", "0009_comment_focus_item"),
]
operations = [
migrations.AddIndex(
model_name="shelfmember",
index=models.Index(
fields=["parent_id", "visibility", "created_time"],
name="journal_she_parent__9da946_idx",
),
),
]

View file

@ -547,6 +547,9 @@ class ShelfMember(ListMember):
class Meta:
unique_together = [["owner", "item"]]
indexes = [
models.Index(fields=["parent_id", "visibility", "created_time"]),
]
@cached_property
def mark(self):

View file

@ -36,7 +36,7 @@
<div class="main-section-wrapper sortable">
{% if request.user.is_staff %}
{% if request.user.is_authenticated %}
<div class="entity-sort" id="calendar_grid">
<h5 class="entity-sort__label">书影音日历</h5>
<div class="calendar_view" hx-get="{% url 'journal:user_calendar_data' user.mastodon_username %}" hx-trigger="load" hx-swap="innerHTML">
@ -51,7 +51,7 @@
data: $(evt.detail.elt).text(),
start_monday: false,
always_show_tooltip: false,
month_names: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
month_names: ['2023', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
day_names: ['', '', ''],
colors: {
'default': '#eeeeee', // Default color