Skip to content

Commit b02bef7

Browse files
authored
Submission dashboard should not show classic submissions in progress (#68)
Filters get_user_submissions_fast to only return NG subs. Adds test for get_user_submissions_fast with both NG and classic subs.
1 parent e95bad0 commit b02bef7

File tree

2 files changed

+95
-3
lines changed

2 files changed

+95
-3
lines changed

core/arxiv/submission/services/classic/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,9 @@ def get_events(submission_id: int) -> List[Event]:
133133
@handle_operational_errors
134134
def get_user_submissions_fast(user_id: int) -> List[Submission]:
135135
"""
136-
Get all active submissions for a user.
136+
Get active NG submissions for a user.
137+
138+
This should not return submissions for which there are no events.
137139
138140
Uses the same approach as :func:`get_submission_fast`.
139141
@@ -151,6 +153,7 @@ def get_user_submissions_fast(user_id: int) -> List[Submission]:
151153
db_submissions = list(
152154
session.query(models.Submission)
153155
.filter(models.Submission.submitter_id == user_id)
156+
.join(DBEvent) # Only get submissions that are also in the event table
154157
.order_by(models.Submission.doc_paper_id.desc())
155158
)
156159
grouped = groupby(db_submissions, key=lambda dbs: dbs.doc_paper_id)

core/arxiv/submission/services/classic/tests/test_get_submission.py

Lines changed: 91 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
SetComments, SetAuthors, Announce, ConfirmAuthorship, ConfirmPolicy, \
1616
SetUploadPackage
1717
from .. import init_app, create_all, drop_all, models, DBEvent, \
18-
get_submission, current_session, get_licenses, exceptions, store_event, \
19-
transaction
18+
get_submission, get_user_submissions_fast, current_session, get_licenses, \
19+
exceptions, store_event, transaction
2020

2121
from .util import in_memory_db
2222

@@ -157,3 +157,92 @@ def test_get_submission_with_hold_and_reclass(self):
157157
self.assertTrue(submission_loaded.is_on_hold,
158158
"Hold status should reflect hold action performed"
159159
" outside the purview of the event model.")
160+
161+
def test_get_submission_list(self):
162+
"""Test that the set of submissions for a user can be retrieved."""
163+
user = User(42, '[email protected]',
164+
endorsements=['astro-ph.GA', 'astro-ph.EP'])
165+
events1 = [
166+
# first submission
167+
CreateSubmission(creator=user),
168+
SetTitle(creator=user, title='Foo title'),
169+
SetAbstract(creator=user, abstract='Indeed' * 20),
170+
SetAuthors(creator=user, authors=[
171+
Author(order=0, forename='Arthur', surname='Dent',
172+
173+
Author(order=1, forename='Ford', surname='Prefect',
174+
175+
]),
176+
SetLicense(creator=user, license_uri='http://creativecommons.org/publicdomain/zero/1.0/',
177+
license_name='Foo zero 1.0'),
178+
SetPrimaryClassification(creator=user, category='astro-ph.GA'),
179+
ConfirmPolicy(creator=user),
180+
SetUploadPackage(creator=user, identifier='1'),
181+
ConfirmContactInformation(creator=user),
182+
FinalizeSubmission(creator=user)
183+
]
184+
events2 = [
185+
# second submission
186+
CreateSubmission(creator=user),
187+
SetTitle(creator=user, title='Bar title'),
188+
SetAbstract(creator=user, abstract='Indubitably' * 20),
189+
SetAuthors(creator=user, authors=[
190+
Author(order=0, forename='Jane', surname='Doe',
191+
192+
Author(order=1, forename='John', surname='Doe',
193+
194+
]),
195+
SetLicense(creator=user, license_uri='http://creativecommons.org/publicdomain/zero/1.0/',
196+
license_name='Foo zero 1.0'),
197+
SetPrimaryClassification(creator=user, category='astro-ph.GA'),
198+
ConfirmPolicy(creator=user),
199+
SetUploadPackage(creator=user, identifier='1'),
200+
ConfirmContactInformation(creator=user),
201+
FinalizeSubmission(creator=user)
202+
]
203+
204+
with in_memory_db():
205+
# User creates and finalizes submission.
206+
with transaction():
207+
before = None
208+
for i, event in enumerate(list(events1)):
209+
event.created = datetime.now(UTC)
210+
after = event.apply(before)
211+
event, after = store_event(event, before, after)
212+
events1[i] = event
213+
before = after
214+
submission1 = after
215+
ident1 = submission1.submission_id
216+
217+
before = None
218+
for i, event in enumerate(list(events2)):
219+
event.created = datetime.now(UTC)
220+
after = event.apply(before)
221+
event, after = store_event(event, before, after)
222+
events2[i] = event
223+
before = after
224+
submission2 = after
225+
ident2 = submission2.submission_id
226+
227+
classic_sub = models.Submission(
228+
type='new',
229+
submitter_id=42)
230+
session = current_session()
231+
session.add(classic_sub)
232+
233+
# Now get the submissions for this user.
234+
submissions = get_user_submissions_fast(42)
235+
submission_loaded1, _ = get_submission(ident1)
236+
submission_loaded2, _ = get_submission(ident2)
237+
238+
self.assertEqual(submission1.metadata.title,
239+
submission_loaded1.metadata.title,
240+
"Event-derived metadata for submission 1 should be preserved.")
241+
self.assertEqual(submission2.metadata.title,
242+
submission_loaded2.metadata.title,
243+
"Event-derived metadata for submission 2 should be preserved.")
244+
245+
self.assertEqual(len(submissions),
246+
2,
247+
"There should be exactly two NG submissions.")
248+

0 commit comments

Comments
 (0)