update db retrieval

This commit is contained in:
Luke Pulverenti 2015-10-27 13:26:04 -04:00
parent 6edd92d2a5
commit 455468ef94
4 changed files with 161 additions and 18 deletions

View File

@ -103,7 +103,8 @@ namespace MediaBrowser.Controller.Entities
/// Gets or sets the name. /// Gets or sets the name.
/// </summary> /// </summary>
/// <value>The name.</value> /// <value>The name.</value>
public string Name [IgnoreDataMember]
public virtual string Name
{ {
get get
{ {
@ -122,12 +123,14 @@ namespace MediaBrowser.Controller.Entities
/// Gets or sets the id. /// Gets or sets the id.
/// </summary> /// </summary>
/// <value>The id.</value> /// <value>The id.</value>
[IgnoreDataMember]
public Guid Id { get; set; } public Guid Id { get; set; }
/// <summary> /// <summary>
/// Gets or sets a value indicating whether this instance is hd. /// Gets or sets a value indicating whether this instance is hd.
/// </summary> /// </summary>
/// <value><c>true</c> if this instance is hd; otherwise, <c>false</c>.</value> /// <value><c>true</c> if this instance is hd; otherwise, <c>false</c>.</value>
[IgnoreDataMember]
public bool? IsHD { get; set; } public bool? IsHD { get; set; }
/// <summary> /// <summary>
@ -149,6 +152,7 @@ namespace MediaBrowser.Controller.Entities
/// Gets or sets the path. /// Gets or sets the path.
/// </summary> /// </summary>
/// <value>The path.</value> /// <value>The path.</value>
[IgnoreDataMember]
public virtual string Path { get; set; } public virtual string Path { get; set; }
[IgnoreDataMember] [IgnoreDataMember]
@ -325,12 +329,14 @@ namespace MediaBrowser.Controller.Entities
/// Gets or sets the date created. /// Gets or sets the date created.
/// </summary> /// </summary>
/// <value>The date created.</value> /// <value>The date created.</value>
[IgnoreDataMember]
public DateTime DateCreated { get; set; } public DateTime DateCreated { get; set; }
/// <summary> /// <summary>
/// Gets or sets the date modified. /// Gets or sets the date modified.
/// </summary> /// </summary>
/// <value>The date modified.</value> /// <value>The date modified.</value>
[IgnoreDataMember]
public DateTime DateModified { get; set; } public DateTime DateModified { get; set; }
public DateTime DateLastSaved { get; set; } public DateTime DateLastSaved { get; set; }
@ -407,6 +413,7 @@ namespace MediaBrowser.Controller.Entities
/// Gets or sets the name of the forced sort. /// Gets or sets the name of the forced sort.
/// </summary> /// </summary>
/// <value>The name of the forced sort.</value> /// <value>The name of the forced sort.</value>
[IgnoreDataMember]
public string ForcedSortName public string ForcedSortName
{ {
get { return _forcedSortName; } get { return _forcedSortName; }
@ -493,6 +500,7 @@ namespace MediaBrowser.Controller.Entities
return sortable; return sortable;
} }
[IgnoreDataMember]
public Guid ParentId { get; set; } public Guid ParentId { get; set; }
/// <summary> /// <summary>
@ -559,6 +567,7 @@ namespace MediaBrowser.Controller.Entities
/// When the item first debuted. For movies this could be premiere date, episodes would be first aired /// When the item first debuted. For movies this could be premiere date, episodes would be first aired
/// </summary> /// </summary>
/// <value>The premiere date.</value> /// <value>The premiere date.</value>
[IgnoreDataMember]
public DateTime? PremiereDate { get; set; } public DateTime? PremiereDate { get; set; }
/// <summary> /// <summary>
@ -572,31 +581,35 @@ namespace MediaBrowser.Controller.Entities
/// Gets or sets the display type of the media. /// Gets or sets the display type of the media.
/// </summary> /// </summary>
/// <value>The display type of the media.</value> /// <value>The display type of the media.</value>
[IgnoreDataMember]
public string DisplayMediaType { get; set; } public string DisplayMediaType { get; set; }
/// <summary> /// <summary>
/// Gets or sets the official rating. /// Gets or sets the official rating.
/// </summary> /// </summary>
/// <value>The official rating.</value> /// <value>The official rating.</value>
[IgnoreDataMember]
public string OfficialRating { get; set; } public string OfficialRating { get; set; }
/// <summary> /// <summary>
/// Gets or sets the official rating description. /// Gets or sets the official rating description.
/// </summary> /// </summary>
/// <value>The official rating description.</value> /// <value>The official rating description.</value>
[IgnoreDataMember]
public string OfficialRatingDescription { get; set; } public string OfficialRatingDescription { get; set; }
/// <summary> /// <summary>
/// Gets or sets the custom rating. /// Gets or sets the custom rating.
/// </summary> /// </summary>
/// <value>The custom rating.</value> /// <value>The custom rating.</value>
//[IgnoreDataMember] [IgnoreDataMember]
public string CustomRating { get; set; } public string CustomRating { get; set; }
/// <summary> /// <summary>
/// Gets or sets the overview. /// Gets or sets the overview.
/// </summary> /// </summary>
/// <value>The overview.</value> /// <value>The overview.</value>
[IgnoreDataMember]
public string Overview { get; set; } public string Overview { get; set; }
/// <summary> /// <summary>
@ -609,37 +622,42 @@ namespace MediaBrowser.Controller.Entities
/// Gets or sets the genres. /// Gets or sets the genres.
/// </summary> /// </summary>
/// <value>The genres.</value> /// <value>The genres.</value>
[IgnoreDataMember]
public List<string> Genres { get; set; } public List<string> Genres { get; set; }
/// <summary> /// <summary>
/// Gets or sets the home page URL. /// Gets or sets the home page URL.
/// </summary> /// </summary>
/// <value>The home page URL.</value> /// <value>The home page URL.</value>
[IgnoreDataMember]
public string HomePageUrl { get; set; } public string HomePageUrl { get; set; }
/// <summary> /// <summary>
/// Gets or sets the community rating. /// Gets or sets the community rating.
/// </summary> /// </summary>
/// <value>The community rating.</value> /// <value>The community rating.</value>
//[IgnoreDataMember] [IgnoreDataMember]
public float? CommunityRating { get; set; } public float? CommunityRating { get; set; }
/// <summary> /// <summary>
/// Gets or sets the community rating vote count. /// Gets or sets the community rating vote count.
/// </summary> /// </summary>
/// <value>The community rating vote count.</value> /// <value>The community rating vote count.</value>
[IgnoreDataMember]
public int? VoteCount { get; set; } public int? VoteCount { get; set; }
/// <summary> /// <summary>
/// Gets or sets the run time ticks. /// Gets or sets the run time ticks.
/// </summary> /// </summary>
/// <value>The run time ticks.</value> /// <value>The run time ticks.</value>
[IgnoreDataMember]
public long? RunTimeTicks { get; set; } public long? RunTimeTicks { get; set; }
/// <summary> /// <summary>
/// Gets or sets the production year. /// Gets or sets the production year.
/// </summary> /// </summary>
/// <value>The production year.</value> /// <value>The production year.</value>
[IgnoreDataMember]
public int? ProductionYear { get; set; } public int? ProductionYear { get; set; }
/// <summary> /// <summary>
@ -647,13 +665,14 @@ namespace MediaBrowser.Controller.Entities
/// This could be episode number, album track number, etc. /// This could be episode number, album track number, etc.
/// </summary> /// </summary>
/// <value>The index number.</value> /// <value>The index number.</value>
//[IgnoreDataMember] [IgnoreDataMember]
public int? IndexNumber { get; set; } public int? IndexNumber { get; set; }
/// <summary> /// <summary>
/// For an episode this could be the season number, or for a song this could be the disc number. /// For an episode this could be the season number, or for a song this could be the disc number.
/// </summary> /// </summary>
/// <value>The parent index number.</value> /// <value>The parent index number.</value>
[IgnoreDataMember]
public int? ParentIndexNumber { get; set; } public int? ParentIndexNumber { get; set; }
[IgnoreDataMember] [IgnoreDataMember]
@ -1307,15 +1326,6 @@ namespace MediaBrowser.Controller.Entities
return null; return null;
} }
/// <summary>
/// Adds a person to the item
/// </summary>
/// <param name="person">The person.</param>
/// <exception cref="System.ArgumentNullException"></exception>
public void AddPerson(PersonInfo person)
{
}
/// <summary> /// <summary>
/// Adds a studio to the item /// Adds a studio to the item
/// </summary> /// </summary>

View File

@ -58,6 +58,26 @@ namespace MediaBrowser.Controller.Entities
} }
} }
private string _name;
/// <summary>
/// Gets or sets the name.
/// </summary>
/// <value>The name.</value>
public override string Name
{
get
{
return _name;
}
set
{
_name = value;
// lazy load this again
SortName = null;
}
}
/// <summary> /// <summary>
/// Returns the folder containing the item. /// Returns the folder containing the item.
/// If the item is a folder, it returns the folder itself /// If the item is a folder, it returns the folder itself

View File

@ -76,7 +76,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
private IDbCommand _deleteStreamsCommand; private IDbCommand _deleteStreamsCommand;
private IDbCommand _saveStreamCommand; private IDbCommand _saveStreamCommand;
private const int LatestSchemaVersion = 13; private const int LatestSchemaVersion = 16;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="SqliteItemRepository"/> class. /// Initializes a new instance of the <see cref="SqliteItemRepository"/> class.
@ -198,6 +198,10 @@ namespace MediaBrowser.Server.Implementations.Persistence
_connection.AddColumn(_logger, "TypedBaseItems", "ExternalEtag", "Text"); _connection.AddColumn(_logger, "TypedBaseItems", "ExternalEtag", "Text");
_connection.AddColumn(_logger, "TypedBaseItems", "DateLastRefreshed", "DATETIME"); _connection.AddColumn(_logger, "TypedBaseItems", "DateLastRefreshed", "DATETIME");
_connection.AddColumn(_logger, "TypedBaseItems", "DateLastSaved", "DATETIME");
_connection.AddColumn(_logger, "TypedBaseItems", "IsInMixedFolder", "BIT");
_connection.AddColumn(_logger, "TypedBaseItems", "LockedFields", "Text");
PrepareStatements(); PrepareStatements();
new MediaStreamColumns(_connection, _logger).AddColumns(); new MediaStreamColumns(_connection, _logger).AddColumns();
@ -289,7 +293,24 @@ namespace MediaBrowser.Server.Implementations.Persistence
"PreferredMetadataCountryCode", "PreferredMetadataCountryCode",
"IsHD", "IsHD",
"ExternalEtag", "ExternalEtag",
"DateLastRefreshed" "DateLastRefreshed",
"Name",
"Path",
"PremiereDate",
"Overview",
"ParentIndexNumber",
"ProductionYear",
"OfficialRating",
"OfficialRatingDescription",
"HomePageUrl",
"DisplayMediaType",
"ForcedSortName",
"RunTimeTicks",
"VoteCount",
"DateCreated",
"DateModified",
"guid",
"Genres"
}; };
private readonly string[] _mediaStreamSaveColumns = private readonly string[] _mediaStreamSaveColumns =
@ -377,7 +398,10 @@ namespace MediaBrowser.Server.Implementations.Persistence
"PreferredMetadataCountryCode", "PreferredMetadataCountryCode",
"IsHD", "IsHD",
"ExternalEtag", "ExternalEtag",
"DateLastRefreshed" "DateLastRefreshed",
"DateLastSaved",
"IsInMixedFolder",
"LockedFields"
}; };
_saveItemCommand = _connection.CreateCommand(); _saveItemCommand = _connection.CreateCommand();
_saveItemCommand.CommandText = "replace into TypedBaseItems (" + string.Join(",", saveColumns.ToArray()) + ") values ("; _saveItemCommand.CommandText = "replace into TypedBaseItems (" + string.Join(",", saveColumns.ToArray()) + ") values (";
@ -606,6 +630,10 @@ namespace MediaBrowser.Server.Implementations.Persistence
_saveItemCommand.GetParameter(index++).Value = item.DateLastRefreshed; _saveItemCommand.GetParameter(index++).Value = item.DateLastRefreshed;
} }
_saveItemCommand.GetParameter(index++).Value = item.DateLastSaved;
_saveItemCommand.GetParameter(index++).Value = item.IsInMixedFolder;
_saveItemCommand.GetParameter(index++).Value = string.Join("|", item.LockedFields.Select(i => i.ToString()).ToArray());
_saveItemCommand.Transaction = transaction; _saveItemCommand.Transaction = transaction;
_saveItemCommand.ExecuteNonQuery(); _saveItemCommand.ExecuteNonQuery();
@ -827,6 +855,88 @@ namespace MediaBrowser.Server.Implementations.Persistence
item.DateLastRefreshed = reader.GetDateTime(23).ToUniversalTime(); item.DateLastRefreshed = reader.GetDateTime(23).ToUniversalTime();
} }
if (!reader.IsDBNull(24))
{
item.Name = reader.GetString(24);
}
if (!reader.IsDBNull(25))
{
item.Path = reader.GetString(25);
}
if (!reader.IsDBNull(26))
{
item.PremiereDate = reader.GetDateTime(26).ToUniversalTime();
}
if (!reader.IsDBNull(27))
{
item.Overview = reader.GetString(27);
}
if (!reader.IsDBNull(28))
{
item.ParentIndexNumber = reader.GetInt32(28);
}
if (!reader.IsDBNull(29))
{
item.ProductionYear = reader.GetInt32(29);
}
if (!reader.IsDBNull(30))
{
item.OfficialRating = reader.GetString(30);
}
if (!reader.IsDBNull(31))
{
item.OfficialRating = reader.GetString(31);
}
if (!reader.IsDBNull(32))
{
item.HomePageUrl = reader.GetString(32);
}
if (!reader.IsDBNull(33))
{
item.DisplayMediaType = reader.GetString(33);
}
if (!reader.IsDBNull(34))
{
item.ForcedSortName = reader.GetString(34);
}
if (!reader.IsDBNull(35))
{
item.RunTimeTicks = reader.GetInt64(35);
}
if (!reader.IsDBNull(36))
{
item.VoteCount = reader.GetInt32(36);
}
if (!reader.IsDBNull(37))
{
item.DateCreated = reader.GetDateTime(37).ToUniversalTime();
}
if (!reader.IsDBNull(38))
{
item.DateModified = reader.GetDateTime(38).ToUniversalTime();
}
item.Id = reader.GetGuid(39);
if (!reader.IsDBNull(40))
{
item.Genres = reader.GetString(40).Split('|').Where(i => !string.IsNullOrWhiteSpace(i)).ToList();
}
return item; return item;
} }

View File

@ -144,15 +144,18 @@ namespace MediaBrowser.Server.Implementations.Persistence
{ {
using (var cmd = _connection.CreateCommand()) using (var cmd = _connection.CreateCommand())
{ {
cmd.CommandText = "select data from users"; cmd.CommandText = "select guid,data from users";
using (var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess | CommandBehavior.SingleResult)) using (var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess | CommandBehavior.SingleResult))
{ {
while (reader.Read()) while (reader.Read())
{ {
using (var stream = reader.GetMemoryStream(0)) var id = reader.GetGuid(0);
using (var stream = reader.GetMemoryStream(1))
{ {
var user = _jsonSerializer.DeserializeFromStream<User>(stream); var user = _jsonSerializer.DeserializeFromStream<User>(stream);
user.Id = id;
yield return user; yield return user;
} }
} }