Skip to content

Filtering out sibling ROMs from showing during scans#93

Open
OctoLiam wants to merge 1 commit intorommapp:mainfrom
OctoLiam:main
Open

Filtering out sibling ROMs from showing during scans#93
OctoLiam wants to merge 1 commit intorommapp:mainfrom
OctoLiam:main

Conversation

@OctoLiam
Copy link

Hopefully this will be a start at working towards #91.

  • Updated Models/RomM/Rom/RomMRom.cs to include grabbing the siblings of ROMs and a new class of RomMSibling

  • Updated RomM.cs to utilize the new method for ROM siblings to allow the skipping of ROM siblings when necessary.

    modified: Models/RomM/Rom/RomMRom.cs
    modified: RomM.cs

- Updated RomM.cs to utilize the new method for ROM siblings to allow the skipping of ROM siblings when necessary.

	modified:   Models/RomM/Rom/RomMRom.cs
	modified:   RomM.cs
@gemini-code-assist
Copy link

Summary of Changes

Hello @OctoLiam, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces functionality to intelligently filter out sibling ROMs during game scans. By enhancing the ROM data model to include sibling relationships and implementing new logic, the system can now identify and exclude redundant ROM entries, leading to cleaner and more accurate scan results, addressing the goals of issue #91.

Highlights

  • Data Model Enhancement: The RomMRom class now includes a Siblings property, which is a list of RomMSibling objects, allowing for the association of related ROMs.
  • New Data Structure: A new class, RomMSibling, has been introduced to represent individual sibling ROMs, containing properties like Id, FileName, and IsMainSibling.
  • ROM Filtering Logic: The GetGames method in RomM.cs has been updated to utilize the new sibling information, enabling the filtering of non-main sibling ROMs during scans to prevent duplicates.
Changelog
  • Models/RomM/Rom/RomMRom.cs
    • Added Siblings property to RomMRom class.
    • Introduced RomMSibling class with Id, FileName, and IsMainSibling properties.
  • RomM.cs
    • Implemented logic to process ROM siblings and identify those to be skipped.
    • Filtered the allRoms list to exclude identified sibling ROMs before further processing.
Activity
  • No specific activity has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a mechanism to filter out sibling ROMs during library scans. It adds a Siblings property to the RomMRom model and logic in RomM.cs to process these siblings. The logic correctly identifies sibling groups and filters them based on whether a 'main' sibling is designated. I've provided a suggestion to refactor a part of the filtering logic to improve its clarity and conciseness.

Comment on lines +497 to +513
var mainSiblingId = item.Siblings.FirstOrDefault(s => s.IsMainSibling)?.Id;

if (mainSiblingId.HasValue)
{
foreach (var sibling in item.Siblings.Where(s => !s.IsMainSibling))
{
siblingIdsToSkip.Add(sibling.Id);
}
siblingIdsToSkip.Add(item.Id);
}
else
{
foreach (var sibling in item.Siblings)
{
siblingIdsToSkip.Add(sibling.Id);
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This block of code for determining which sibling ROMs to skip can be simplified for better readability and conciseness. You can determine which ROM ID to keep (either the mainSibling or the current item) and then add all other ROMs from the group to the siblingIdsToSkip set. This also replaces the foreach loops with the more performant UnionWith method on the HashSet.

                            var mainSibling = item.Siblings.FirstOrDefault(s => s.IsMainSibling);
                            var idToKeep = mainSibling?.Id ?? item.Id;

                            groupRomIds.Remove(idToKeep);
                            siblingIdsToSkip.UnionWith(groupRomIds);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant