From 6c54f1f7c84787bf61595de5ca54143bcdf55eed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois-Xavier=20Thomas?= Date: Sat, 11 Jan 2020 21:17:52 +0100 Subject: [PATCH] Internal help: Refactor detailed db/index stats --- .../controller/InternalHelpController.java | 72 +++++++++++-------- .../player/i18n/ResourceBundle_en.properties | 16 ++--- .../main/webapp/WEB-INF/jsp/internalhelp.jsp | 43 +++++++---- 3 files changed, 79 insertions(+), 52 deletions(-) diff --git a/airsonic-main/src/main/java/org/airsonic/player/controller/InternalHelpController.java b/airsonic-main/src/main/java/org/airsonic/player/controller/InternalHelpController.java index 5a6c3dd2..0bf9dcb4 100644 --- a/airsonic-main/src/main/java/org/airsonic/player/controller/InternalHelpController.java +++ b/airsonic-main/src/main/java/org/airsonic/player/controller/InternalHelpController.java @@ -68,6 +68,36 @@ public class InternalHelpController { private static final int LOG_LINES_TO_SHOW = 50; + public class IndexStatistics { + private String name; + private int count; + private int deletedCount; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getCount() { + return count; + } + + public void setCount(int count) { + this.count = count; + } + + public int getDeletedCount() { + return deletedCount; + } + + public void setDeletedCount(int deletedCount) { + this.deletedCount = deletedCount; + } + } + public class FileStatistics { private String name; private String path; @@ -225,36 +255,20 @@ public class InternalHelpController { } private void gatherIndexInfo(Map map) { - try (IndexReader reader = indexManager.getSearcher(IndexType.SONG).getIndexReader()) { - map.put("indexSongCount", reader.numDocs()); - map.put("indexSongDeletedCount", reader.numDeletedDocs()); - } catch (IOException e) { - LOG.debug("Unable to gather information", e); - } - try (IndexReader reader = indexManager.getSearcher(IndexType.ALBUM).getIndexReader()) { - map.put("indexAlbumCount", reader.numDocs()); - map.put("indexAlbumDeletedCount", reader.numDeletedDocs()); - } catch (IOException e) { - LOG.debug("Unable to gather information", e); - } - try (IndexReader reader = indexManager.getSearcher(IndexType.ARTIST).getIndexReader()) { - map.put("indexArtistCount", reader.numDocs()); - map.put("indexArtistDeletedCount", reader.numDeletedDocs()); - } catch (IOException e) { - LOG.debug("Unable to gather information", e); - } - try (IndexReader reader = indexManager.getSearcher(IndexType.ALBUM_ID3).getIndexReader()) { - map.put("indexAlbumId3Count", reader.numDocs()); - map.put("indexAlbumId3DeletedCount", reader.numDeletedDocs()); - } catch (IOException e) { - LOG.debug("Unable to gather information", e); - } - try (IndexReader reader = indexManager.getSearcher(IndexType.ARTIST_ID3).getIndexReader()) { - map.put("indexArtistId3Count", reader.numDocs()); - map.put("indexArtistId3DeletedCount", reader.numDeletedDocs()); - } catch (IOException e) { - LOG.debug("Unable to gather information", e); + SortedMap indexStats = new TreeMap<>(); + for (IndexType indexType : IndexType.values()) { + try (IndexReader reader = indexManager.getSearcher(indexType).getIndexReader()) { + IndexStatistics stat = new IndexStatistics(); + stat.setName(indexType.name()); + stat.setCount(reader.numDocs()); + stat.setDeletedCount(reader.numDeletedDocs()); + indexStats.put(indexType.name(), stat); + } catch (IOException e) { + LOG.debug("Unable to gather information about {} index", indexType.name(), e); + } } + map.put("indexStatistics", indexStats); + try (Analyzer analyzer = analyzerFactory.getAnalyzer()) { map.put("indexLuceneVersion", analyzer.getVersion().toString()); } catch (IOException e) { diff --git a/airsonic-main/src/main/resources/org/airsonic/player/i18n/ResourceBundle_en.properties b/airsonic-main/src/main/resources/org/airsonic/player/i18n/ResourceBundle_en.properties index 093d5f45..2269c80e 100644 --- a/airsonic-main/src/main/resources/org/airsonic/player/i18n/ResourceBundle_en.properties +++ b/airsonic-main/src/main/resources/org/airsonic/player/i18n/ResourceBundle_en.properties @@ -263,11 +263,13 @@ upload.failed=Uploading failed with the following error:
"{0}" upload.unzipped=Unzipped {0} internalhelp.title=About {0} Internals -internalhelp.details=Internal details +internalhelp.details=Internal Details internalhelp.statistics=Statistics internalhelp.database=Database +internalhelp.databasedetails=Database Details internalhelp.databaseconsistency=Database Consistency internalhelp.index=Search Index +internalhelp.indexdetails=Search Index Details internalhelp.filesystem=Filesystem internalhelp.transcoding=Transcoding internalhelp.musicfolders=Music Folders @@ -287,22 +289,18 @@ internalhelp.lastscandate=Last scan date internalhelp.totaldurationseconds=Total duration (s) internalhelp.totalsizebytes=Total size (bytes) internalhelp.luceneversion=Lucene version -internalhelp.albumcount=Album count internalhelp.artistcount=Artist count internalhelp.songcount=Song count +internalhelp.indexcount=Index "{0}" count +internalhelp.indexdeletedcount=Index "{0}" deleted count internalhelp.musiccount=Music file count internalhelp.podcastcount=Podcast count internalhelp.directorycount=Directory count -internalhelp.artistid3count=Artist (ID3) count -internalhelp.albumid3count=Album (ID3) count -internalhelp.songdeletedcount=Deleted song count +internalhelp.albumcount=Album count internalhelp.musicdeletedcount=Deleted music file count internalhelp.podcastdeletedcount=Deleted podcast count internalhelp.directorydeletedcount=Deleted directory count internalhelp.albumdeletedcount=Deleted album count -internalhelp.artistdeletedcount=Deleted artist count -internalhelp.artistid3deletedcount=Deleted artist (ID3) count -internalhelp.albumid3deletedcount=Deleted album (ID3) count internalhelp.distinctalbumcount=Distinct album count internalhelp.distinctartistcount=Distinct artist count internalhelp.distinctalbumartistcount=Distinct album artist count @@ -314,7 +312,7 @@ internalhelp.dbdirectorysize=Size of the internal database directory internalhelp.dblogsize=Size of the internal database log internalhelp.dblogsize.ok=The size of the database log file (db/airsonic.log) appears healthy. internalhelp.dblogsize.warn=The size of the database log file (db/airsonic.log) is large (greater than 256M). Run a scan to clean it up. -internalhelp.tablecount={0} row count +internalhelp.tablecount=Table "{0}" count internalhelp.mediafilesinnonpresentmusicfoldercount=Nubmer of media files in non-present music folders internalhelp.mediafilesinnonpresentmusicfoldercount.ok=All media files in the database have a valid music folder. internalhelp.mediafilesinnonpresentmusicfoldercount.warn=The media file database contains files whose music folder is no longer present. Examples are below. diff --git a/airsonic-main/src/main/webapp/WEB-INF/jsp/internalhelp.jsp b/airsonic-main/src/main/webapp/WEB-INF/jsp/internalhelp.jsp index 36929506..e8cbc344 100644 --- a/airsonic-main/src/main/webapp/WEB-INF/jsp/internalhelp.jsp +++ b/airsonic-main/src/main/webapp/WEB-INF/jsp/internalhelp.jsp @@ -71,16 +71,6 @@ - - - - - - - - - -
${model.indexLuceneVersion}
${model.indexSongDeletedCount}
${model.indexAlbumDeletedCount}
${model.indexArtistDeletedCount}
${model.indexAlbumId3DeletedCount}
${model.indexArtistId3DeletedCount}
${model.indexSongCount}
${model.indexAlbumCount}
${model.indexArtistCount}
${model.indexAlbumId3Count}
${model.indexArtistId3Count}

@@ -138,10 +128,6 @@ ${model.dbMediaFileDistinctAlbumCount} ${model.dbMediaFileDistinctArtistCount} ${model.dbMediaFileDistinctAlbumArtistCount} - - - ${tableCount.value} -

@@ -345,6 +331,35 @@

+

+ + +

+ + + + + + + + +
${stat.value.deletedCount}
${stat.value.count}
+ +

+ +

+ + +

+ + + + + +
${tableCount.value}
+ +

+