-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[4/4] Query for Updates from Nexus, and Fix Miscellaneous Bugs in Dat…
…aStore (#2113) * WIP: Documentation for Update Detection * Added: Additional Edge Cases to Update Logic Docs * Added: Extra case of `Archived in the Middle` * Fixed: Indentation for `file_updates` field. * Finalized 'Updating Mods' doc with simplified Implementation requested. * Fixed: Minor Notes from older Research Doc * Fixed: Added Missing 'Updating Mods' mkdocs sidebar item. * [Working WIP] Added: Initial Implementation of Generic Page Caching System used by Mod Pages * Tech Debt Reduction: Add additional V2 GraphQL Types and Correct Sizes of Existing Types * Added: Missing 'UInt32' types in attribute definitions * Improved: Accuracy of documentation for FileId struct. * Added: Method for constructing UidForMod and UidForFile from GraphQL API Results * Rename: ICanGetUid to ICanGetUidForMod * Added: Tests for UidForModTests and UidForFileTests * Removed: Unused Tests.cs file * Added: Mixin for V1 API Results to ModUpdates Library * Added: Mod Page Metadata now is ready for handling update info with V2 GameId and Friends * Added: Mixin for page metadata. * NexusModsModPageMetadata: Correctly Use uid as 'primary key' * Update: Use GameId from uid field of NexusModsModPageMetadata * Added: Fetch Mod Page Metadata from the DB * Added: Note about field in PageMetadataMixin * Use Uid in NexusModsFileMetadata, and Add Relevant Constructors for UidForFile and UidForMod * Added: Code for running actual update check, and relevant constructs. * V1: Fix field names on ModUpdate structure to align with Nexus V1 API * Added: Remaining Fixups to make the Update Check 'work' * Added: A note regarding adding more tests. * Added: Small note to ModUpdateMixin about choice of field. * Removed: FilesUpdatedAt field, as it is now currently unused. * Improve: Clarify last updated date is in UTC * Updated Note: It's no longer messy, but we still need to upgrade to V2. * Improved: Now also updates mod pages. * Merge interfaces into IModFeedItem * Fix some merge conflicts --------- Co-authored-by: halgari <tbaldridge@gmail.com>
- Loading branch information
Showing
26 changed files
with
511 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/Networking/NexusMods.Networking.ModUpdates/IModFeedItem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using NexusMods.Abstractions.NexusWebApi.Types.V2.Uid; | ||
namespace NexusMods.Networking.ModUpdates; | ||
|
||
/// <summary> | ||
/// Represents an individual item from a 'mod feed'; with the 'mod feed' being | ||
/// the result of an API call that returns one or more mods from the Nexus API. | ||
/// (Either V1 or V2 API) | ||
/// </summary> | ||
public interface IModFeedItem | ||
{ | ||
/// <summary> | ||
/// Returns a unique identifier for the given item, based on the ID format | ||
/// used in the NexusMods V2 API. | ||
/// </summary> | ||
public UidForMod GetModPageId(); | ||
|
||
/// <summary> | ||
/// Retrieves the time the item was last updated. | ||
/// This date is in UTC. | ||
/// </summary> | ||
public DateTime GetLastUpdatedDateUtc(); | ||
} |
40 changes: 40 additions & 0 deletions
40
src/Networking/NexusMods.Networking.ModUpdates/Mixins/ModFeedItemUpdateMixin.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using NexusMods.Abstractions.NexusWebApi.DTOs; | ||
using NexusMods.Abstractions.NexusWebApi.Types.V2; | ||
using NexusMods.Abstractions.NexusWebApi.Types.V2.Uid; | ||
namespace NexusMods.Networking.ModUpdates.Mixins; | ||
|
||
/// <summary> | ||
/// Implements the (V1) mod update API mixin. | ||
/// </summary> | ||
public readonly struct ModFeedItemUpdateMixin : IModFeedItem | ||
{ | ||
private readonly DateTime _lastUpdatedDate; | ||
private readonly GameId _gameId; | ||
private readonly ModId _modId; | ||
|
||
/// <summary/> | ||
private ModFeedItemUpdateMixin(ModUpdate update, GameId gameId) | ||
{ | ||
// Note(sewer): V2 doesn't have 'last file updated' field, so we have to use 'last mod page update' time. | ||
// Well, this whole struct is, will be making that ticket to backend, and replace | ||
// this when V2 gets relevant API. | ||
_lastUpdatedDate = update.LatestModActivityUtc; | ||
_gameId = gameId; | ||
_modId = update.ModId; | ||
} | ||
|
||
/// <summary> | ||
/// Transforms the result of a V1 API call for mod updates into the Mixin. | ||
/// </summary> | ||
public static IEnumerable<ModFeedItemUpdateMixin> FromUpdateResults(IEnumerable<ModUpdate> updates, GameId gameId) => updates.Select(update => new ModFeedItemUpdateMixin(update, gameId)); | ||
|
||
/// <inheritdoc /> | ||
public DateTime GetLastUpdatedDateUtc() => _lastUpdatedDate; | ||
|
||
/// <inheritdoc /> | ||
public UidForMod GetModPageId() => new() | ||
{ | ||
GameId = _gameId, | ||
ModId = _modId, | ||
}; | ||
} |
38 changes: 38 additions & 0 deletions
38
src/Networking/NexusMods.Networking.ModUpdates/Mixins/PageMetadataMixin.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using NexusMods.Abstractions.NexusModsLibrary; | ||
using NexusMods.Abstractions.NexusWebApi.Types.V2.Uid; | ||
using NexusMods.MnemonicDB.Abstractions; | ||
namespace NexusMods.Networking.ModUpdates.Mixins; | ||
|
||
/// <summary> | ||
/// Implements the MnemonicDB mod page mixin based on V2 API Results. | ||
/// </summary> | ||
public struct PageMetadataMixin : IModFeedItem | ||
{ | ||
private readonly NexusModsModPageMetadata.ReadOnly _metadata; | ||
|
||
private PageMetadataMixin(NexusModsModPageMetadata.ReadOnly metadata) => _metadata = metadata; | ||
|
||
/// <inheritodc/> | ||
public UidForMod GetModPageId() => new() | ||
{ | ||
GameId = _metadata.Uid.GameId, | ||
ModId = _metadata.Uid.ModId, | ||
}; | ||
|
||
/// <summary/> | ||
public EntityId GetModPageEntityId() => _metadata.Id; | ||
|
||
/// <inheritodc/> | ||
public DateTime GetLastUpdatedDateUtc() => _metadata.UpdatedAt; // <= TODO: Change this with 'last file updated at' when V2 supports this field. | ||
|
||
/// <summary> | ||
/// Returns the database entries containing page metadata(s) as a mixin. | ||
/// </summary> | ||
public static IEnumerable<PageMetadataMixin> EnumerateDatabaseEntries(IDb db) => NexusModsModPageMetadata.All(db).Select(only => new PageMetadataMixin(only)); | ||
|
||
/// <summary/> | ||
public static implicit operator NexusModsModPageMetadata.ReadOnly(PageMetadataMixin mixin) => mixin._metadata; | ||
|
||
/// <summary/> | ||
public static implicit operator PageMetadataMixin(NexusModsModPageMetadata.ReadOnly metadata) => new(metadata); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.