Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
91fb2a29
Commit
91fb2a29
authored
Jan 18, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stats: added num_artists, num_albums
Don't recalculate the number of artists and albums each time a client requests statistics. Calculate that once in stats_update().
parent
0d449d8d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
8 deletions
+16
-8
stats.c
src/stats.c
+10
-8
stats.h
src/stats.h
+6
-0
No files found.
src/stats.c
View file @
91fb2a29
...
...
@@ -33,12 +33,6 @@ void stats_global_init(void)
stats
.
start_time
=
time
(
NULL
);
}
void
stats_update
(
void
)
{
stats
.
song_count
=
countSongsIn
(
NULL
);
stats
.
song_duration
=
sumSongTimesIn
(
NULL
);
}
struct
visit_data
{
enum
tag_type
type
;
struct
strset
*
set
;
...
...
@@ -78,6 +72,14 @@ getNumberOfTagItems(enum tag_type type)
return
ret
;
}
void
stats_update
(
void
)
{
stats
.
song_count
=
countSongsIn
(
NULL
);
stats
.
song_duration
=
sumSongTimesIn
(
NULL
);
stats
.
artist_count
=
getNumberOfTagItems
(
TAG_ITEM_ARTIST
);
stats
.
album_count
=
getNumberOfTagItems
(
TAG_ITEM_ALBUM
);
}
int
stats_print
(
struct
client
*
client
)
{
client_printf
(
client
,
...
...
@@ -88,8 +90,8 @@ int stats_print(struct client *client)
"playtime: %li
\n
"
"db_playtime: %li
\n
"
"db_update: %li
\n
"
,
getNumberOfTagItems
(
TAG_ITEM_ARTIST
)
,
getNumberOfTagItems
(
TAG_ITEM_ALBUM
)
,
stats
.
artist_count
,
stats
.
album_count
,
stats
.
song_count
,
time
(
NULL
)
-
stats
.
start_time
,
(
long
)(
getPlayerTotalPlayTime
()
+
0
.
5
),
...
...
src/stats.h
View file @
91fb2a29
...
...
@@ -30,6 +30,12 @@ struct stats {
/** sum of all song durations in the music directory (in
seconds) */
unsigned
long
song_duration
;
/** number of distinct artist names in the music directory */
unsigned
artist_count
;
/** number of distinct album names in the music directory */
unsigned
album_count
;
};
extern
struct
stats
stats
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment