Skip to content

Commit 7730b9d

Browse files
Merge pull request #1271 from NASA-IMPACT/dev
Staging deployment - Fix Celery schedule and DocumentType filter
2 parents 1d5324d + febc437 commit 7730b9d

File tree

9 files changed

+70
-27
lines changed

9 files changed

+70
-27
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,14 @@ For each PR made, an entry should be added to this changelog. It should contain
137137
- Description: The feedback form API was throwing CORS errors and to rectify that, we need to add the apt https link for sde-lrm.
138138
- Changes:
139139
- Added `https://sde-lrm.nasa-impact.net` to `CORS_ALLOWED_ORIGINS` in the base settings.
140+
141+
- 1252-document-type-filter-not-working-in-delta-urls-page
142+
- Description: Fixed document type filtering functionality in the "Document Type Patterns" tab in Delta URLs page.
143+
- Changes:
144+
- Added a new event listener to the Document Type Patterns dropdown to trigger the filtering of the table results based on the selected value.
145+
146+
- 1251-column-sorting-issue-curated-urls-count-sorts-by-delta-urls-count
147+
- Description: Fixed incorrect sorting behavior in Collections table where sorting by Curated URLs column was not working as expected.
148+
- Changes:
149+
- Added `data-order` attribute to URL count columns for proper numeric sorting
150+
- Updated SearchPane comparisons to use `@data-order` values instead of string-based loose equality checks to ensure correct numeric filtering

config/celery.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import os
33

44
from celery import Celery
5-
from celery.schedules import crontab
65

76
# Set the default Django settings module
87
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.local")
@@ -14,11 +13,3 @@
1413

1514
# Load task modules from all registered Django app configs
1615
app.autodiscover_tasks()
17-
18-
app.conf.beat_schedule = {
19-
"process-inference-queue": {
20-
"task": "inference.tasks.process_inference_job_queue",
21-
# Only run between 6pm and 7am
22-
"schedule": crontab(minute="*/5", hour="18-23,0-6"),
23-
},
24-
}

inference/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
default_app_config = "inference.apps.InferenceConfig"

inference/apps.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ class InferenceConfig(AppConfig):
55
default_auto_field = "django.db.models.BigAutoField"
66
name = "inference"
77
verbose_name = "Inference"
8+
9+
def ready(self):
10+
import inference.signals # noqa F401

inference/signals.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from django.db.models.signals import post_migrate
2+
from django.dispatch import receiver
3+
4+
5+
@receiver(post_migrate)
6+
def create_periodic_tasks(sender, **kwargs):
7+
if sender.name == "inference":
8+
from django_celery_beat.models import CrontabSchedule, PeriodicTask
9+
10+
# Create schedule for every 5 minutes between 6pm-7am
11+
crontab, _ = CrontabSchedule.objects.get_or_create(
12+
minute="*/5",
13+
hour="18-23,0-6",
14+
day_of_week="*",
15+
day_of_month="*",
16+
month_of_year="*",
17+
)
18+
19+
# Create the periodic task if it doesn't exist
20+
PeriodicTask.objects.get_or_create(
21+
crontab=crontab,
22+
name="Process inference queue (6pm-7am)",
23+
task="inference.tasks.process_inference_job_queue",
24+
)

inference/tests/test_batch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def mock_url_large(self):
3636
"""Returns a mock URL object with large text content"""
3737
url = Mock()
3838
url.id = 2
39-
url.scraped_text = "X" * 10010 # Exceeds default max size
39+
url.scraped_text = "X" * 12000 # Exceeds default max size
4040
url.scraped_title = "Large Content Page"
4141
url.url = "https://example.com/large-page"
4242
return url
@@ -191,7 +191,7 @@ def test_iter_url_batches_mix_normal_and_oversized(self, processor):
191191
# Normal URL
192192
url1 = Mock(id=1, scraped_text="X" * 2000, scraped_title="Title 1", url="https://example.com/1")
193193
# Oversized URL
194-
url2 = Mock(id=2, scraped_text="X" * 11000, scraped_title="Title 2", url="https://example.com/2")
194+
url2 = Mock(id=2, scraped_text="X" * 15000, scraped_title="Title 2", url="https://example.com/2")
195195
# Another normal URL
196196
url3 = Mock(id=3, scraped_text="X" * 3000, scraped_title="Title 3", url="https://example.com/3")
197197

sde_indexing_helper/static/js/collection_list.js

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -138,43 +138,47 @@ let table = $("#collection_table").DataTable({
138138
{
139139
label: "0 URLs",
140140
value: function (rowData, rowIdx) {
141-
return $(rowData[COLUMNS.DELTA_URLS]).text() == 0;
141+
return parseInt(rowData[COLUMNS.DELTA_URLS]['@data-order']) === 0;
142142
},
143143
},
144144
{
145145
label: "1 solo URL",
146146
value: function (rowData, rowIdx) {
147-
return $(rowData[COLUMNS.DELTA_URLS]).text() == 1;
147+
return parseInt(rowData[COLUMNS.DELTA_URLS]['@data-order']) === 1;
148148
},
149149
},
150150
{
151151
label: "1 to 100 URLs",
152152
value: function (rowData, rowIdx) {
153-
return $(rowData[COLUMNS.DELTA_URLS]).text() <= 100 && $(rowData[COLUMNS.DELTA_URLS]).text() > 1;
153+
const value = parseInt(rowData[COLUMNS.DELTA_URLS]['@data-order']);
154+
return value > 1 && value <= 100;
154155
},
155156
},
156157
{
157158
label: "100 to 1,000 URLs",
158159
value: function (rowData, rowIdx) {
159-
return $(rowData[COLUMNS.DELTA_URLS]).text() <= 1000 && $(rowData[COLUMNS.DELTA_URLS]).text() > 100;
160+
const value = parseInt(rowData[COLUMNS.DELTA_URLS]['@data-order']);
161+
return value > 100 && value <= 1000;
160162
},
161163
},
162164
{
163165
label: "1,000 to 10,000 URLs",
164166
value: function (rowData, rowIdx) {
165-
return $(rowData[COLUMNS.DELTA_URLS]).text() <= 10000 && $(rowData[COLUMNS.DELTA_URLS]).text() > 1000;
167+
const value = parseInt(rowData[COLUMNS.DELTA_URLS]['@data-order']);
168+
return value > 1000 && value <= 10000;
166169
},
167170
},
168171
{
169172
label: "10,000 to 100,000 URLs",
170173
value: function (rowData, rowIdx) {
171-
return $(rowData[COLUMNS.DELTA_URLS]).text() <= 100000 && $(rowData[COLUMNS.DELTA_URLS]).text() > 10000;
174+
const value = parseInt(rowData[COLUMNS.DELTA_URLS]['@data-order']);
175+
return value > 10000 && value <= 100000;
172176
},
173177
},
174178
{
175179
label: "Over 100,000 URLs",
176180
value: function (rowData, rowIdx) {
177-
return $(rowData[COLUMNS.DELTA_URLS]).text() > 100000;
181+
return parseInt(rowData[COLUMNS.DELTA_URLS]['@data-order']) > 100000;
178182
},
179183
},
180184
],
@@ -189,43 +193,47 @@ let table = $("#collection_table").DataTable({
189193
{
190194
label: "0 URLs",
191195
value: function (rowData, rowIdx) {
192-
return $(rowData[COLUMNS.CURATED_URLS]).text() == 0;
196+
return parseInt(rowData[COLUMNS.CURATED_URLS]['@data-order']) === 0;
193197
},
194198
},
195199
{
196200
label: "1 solo URL",
197201
value: function (rowData, rowIdx) {
198-
return $(rowData[COLUMNS.CURATED_URLS]).text() == 1;
202+
return parseInt(rowData[COLUMNS.CURATED_URLS]['@data-order']) === 1;
199203
},
200204
},
201205
{
202206
label: "1 to 100 URLs",
203207
value: function (rowData, rowIdx) {
204-
return $(rowData[COLUMNS.CURATED_URLS]).text() <= 100 && $(rowData[COLUMNS.CURATED_URLS]).text() > 1;
208+
const value = parseInt(rowData[COLUMNS.CURATED_URLS]['@data-order']);
209+
return value > 1 && value <= 100;
205210
},
206211
},
207212
{
208213
label: "100 to 1,000 URLs",
209214
value: function (rowData, rowIdx) {
210-
return $(rowData[COLUMNS.CURATED_URLS]).text() <= 1000 && $(rowData[COLUMNS.CURATED_URLS]).text() > 100;
215+
const value = parseInt(rowData[COLUMNS.CURATED_URLS]['@data-order']);
216+
return value > 100 && value <= 1000;
211217
},
212218
},
213219
{
214220
label: "1,000 to 10,000 URLs",
215221
value: function (rowData, rowIdx) {
216-
return $(rowData[COLUMNS.CURATED_URLS]).text() <= 10000 && $(rowData[COLUMNS.CURATED_URLS]).text() > 1000;
222+
const value = parseInt(rowData[COLUMNS.CURATED_URLS]['@data-order']);
223+
return value > 1000 && value <= 10000;
217224
},
218225
},
219226
{
220227
label: "10,000 to 100,000 URLs",
221228
value: function (rowData, rowIdx) {
222-
return $(rowData[COLUMNS.CURATED_URLS]).text() <= 100000 && $(rowData[COLUMNS.CURATED_URLS]).text() > 10000;
229+
const value = parseInt(rowData[COLUMNS.CURATED_URLS]['@data-order']);
230+
return value > 10000 && value <= 100000;
223231
},
224232
},
225233
{
226234
label: "Over 100,000 URLs",
227235
value: function (rowData, rowIdx) {
228-
return $(rowData[COLUMNS.CURATED_URLS]).text() > 100000;
236+
return parseInt(rowData[COLUMNS.CURATED_URLS]['@data-order']) > 100000;
229237
},
230238
},
231239
],

sde_indexing_helper/static/js/delta_url_list.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,11 @@ function initializeDataTable() {
881881
$("#deltaDocTypeMatchPatternFilter").on("beforeinput", function (val) {
882882
document_type_patterns_table.columns(0).search(this.value).draw();
883883
});
884+
885+
$("#document-type-patterns-dropdown-2").on("change", function () {
886+
document_type_patterns_table.columns(2).search(this.value).draw();
887+
});
888+
884889
}
885890

886891
var division_patterns_table = $("#division_patterns_table").DataTable({

sde_indexing_helper/templates/sde_collections/collection_list.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,14 @@ <h2 class="title">Welcome back!</h2>
151151
<td class="whiteText noBorder">{{ collection.get_division_display }}</td>
152152

153153
<!-- Delta URLs Column - Shows count and links if >= 0 -->
154-
<td class="noBorder centerAlign">
154+
<td class="noBorder centerAlign" data-order="{{ collection.num_delta_urls }}">
155155
<a href=" {% if collection.num_delta_urls >= 0 %} {% url 'sde_collections:delta_urls' collection.pk %} {% endif %} "
156156
class="btn btn-sm {% if collection.num_delta_urls >= 0 %}btn-primary {% else %}disabled{% endif %}candidateCount"
157157
role="button">{{ collection.num_delta_urls|intcomma }}</a>
158158
</td>
159159

160160
<!-- Curated URLs Column - Shows count and links if >= 0 -->
161-
<td class="noBorder centerAlign">
161+
<td class="noBorder centerAlign" data-order="{{ collection.num_curated_urls }}">
162162
<a href=" {% if collection.num_curated_urls >= 0 %} {% url 'sde_collections:delta_urls' collection.pk %} {% endif %} "
163163
class="btn btn-sm {% if collection.num_curated_urls >= 0 %}btn-primary {% else %}disabled{% endif %}candidateCount"
164164
role="button">{{ collection.num_curated_urls|intcomma }}</a>

0 commit comments

Comments
 (0)