Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
djrandom-py-deleted-112
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This project is pending deletion, and will be deleted on
2025-06-14
. Repository and other project resources are read-only.
Show more breadcrumbs
ale
djrandom-py-deleted-112
Commits
8ac22a69
Commit
8ac22a69
authored
13 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
add method and API to retrieve last uploaded songs
parent
a20f1d85
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
server/djrandom/frontend/api_views.py
+10
-1
10 additions, 1 deletion
server/djrandom/frontend/api_views.py
server/djrandom/model/mp3.py
+5
-0
5 additions, 0 deletions
server/djrandom/model/mp3.py
with
15 additions
and
1 deletion
server/djrandom/frontend/api_views.py
+
10
−
1
View file @
8ac22a69
...
@@ -151,7 +151,16 @@ def more_like_these_json():
...
@@ -151,7 +151,16 @@ def more_like_these_json():
@app.route
(
'
/json/most_played
'
,
methods
=
[
'
GET
'
])
@app.route
(
'
/json/most_played
'
,
methods
=
[
'
GET
'
])
@require_auth
@require_auth
def
most_played_json
():
def
most_played_json
():
n
=
int
(
request
.
args
.
get
(
'
n
'
,
20
))
most_played
=
[{
'
sha1
'
:
sha1
,
'
count
'
:
count
}
most_played
=
[{
'
sha1
'
:
sha1
,
'
count
'
:
count
}
for
sha1
,
count
in
PlayLog
.
most_played
(
20
)]
for
sha1
,
count
in
PlayLog
.
most_played
(
n
)]
return
jsonify
(
results
=
most_played
)
return
jsonify
(
results
=
most_played
)
@app.route
(
'
/json/last_uploaded
'
,
methods
=
[
'
GET
'
])
@require_auth
def
last_uploaded_json
():
n
=
int
(
request
.
args
.
get
(
'
n
'
,
20
))
last_uploaded
=
[
x
.
to_dict
()
for
x
in
MP3
.
last_uploaded
(
n
)]
return
jsonify
(
results
=
last_uploaded
)
This diff is collapsed.
Click to expand it.
server/djrandom/model/mp3.py
+
5
−
0
View file @
8ac22a69
...
@@ -36,6 +36,11 @@ class MP3(Base):
...
@@ -36,6 +36,11 @@ class MP3(Base):
'
size
'
:
self
.
size
,
'
size
'
:
self
.
size
,
'
uploaded_at
'
:
self
.
uploaded_at
}
'
uploaded_at
'
:
self
.
uploaded_at
}
@classmethod
def
last_uploaded
(
cls
,
n
=
10
):
"""
Return the N last uploaded songs.
"""
return
cls
.
query
.
filter_by
(
ready
=
True
).
order_by
(
'
desc uploaded_at
'
).
limit
(
n
)
class
PlayLog
(
Base
):
class
PlayLog
(
Base
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment