Skip to content

consolidated mumukshu report#279

Open
vvshk wants to merge 1 commit intomainfrom
feat/consolidated-mumukshu-report
Open

consolidated mumukshu report#279
vvshk wants to merge 1 commit intomainfrom
feat/consolidated-mumukshu-report

Conversation

@vvshk
Copy link
Copy Markdown
Collaborator

@vvshk vvshk commented Mar 3, 2026

No description provided.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 enhances the administrative capabilities by introducing a new feature to generate a consolidated activity report for any cardholder. It integrates data from multiple operational areas to offer a holistic view of a person's past and upcoming interactions, open requests, and assigned resources, thereby streamlining information access for administrators.

Highlights

  • New API Endpoint for Person Activity: Introduced a new API endpoint, /admin/card/person-activity, to provide a comprehensive activity report for a given card number (mumukshu).
  • Consolidated Data Retrieval: The new endpoint aggregates data from various modules including flat bookings, room bookings, food records, gate entries, maintenance requests, shibir bookings, travel records, utsav bookings, and permanent Wi-Fi codes.
  • Activity Categorization and Timeline: Activities are categorized into 'upcoming' and 'past 30 days' based on their dates, providing a clear timeline of a person's engagements. Open maintenance requests and Wi-Fi codes are also included as separate sections.
  • Code Cleanup: A large block of commented-out code for the createCard function was removed from the controller, improving code readability.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • controllers/admin/cardManagement.controller.js
    • Added a new controller function getPersonActivity to fetch and consolidate various activities for a given card number.
    • Imported numerous Sequelize models (e.g., FlatBooking, RoomBooking, FoodDb, GateRecord, MaintenanceDb, ShibirBookingDb, TravelDb, UtsavBooking, PermanentWifiCodes, ShibirDb, UtsavDb) to support the consolidated report.
    • Included moment library for date manipulation and STATUS_OPEN constant for filtering maintenance requests.
    • Removed a significant commented-out section of the createCard function.
  • routes/admin/cardManagement.routes.js
    • Imported the new getPersonActivity controller function.
    • Registered a new GET route /person-activity under the admin card management routes to expose the new activity report functionality.
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
Copy Markdown
Contributor

@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 new endpoint to generate a consolidated activity report for a person. While the implementation uses Promise.all for parallel database queries, improving performance, there's a security vulnerability: the getPersonActivity function exposes raw database error messages to the client. Additionally, the broad access control granted to multiple administrative roles for this consolidated report may violate the principle of least privilege. There is also a critical bug in the data processing logic that results in an incomplete report, along with performance inefficiencies in fetching historical data. Review includes suggestions to fix the bug, optimize the queries, and improve code clarity.

Comment on lines +481 to +482
if (d > today) upcoming.push(item);
else if (d >= past30) past30Days.push(item);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

critical

The else if condition here incorrectly filters out relevant activities. For instance, a flat or room booking that started over 30 days ago but is still ongoing is fetched from the database but then discarded by this logic because its checkin date is before past30. Since the database queries are designed to fetch all relevant activities (especially with the suggested query optimizations), this secondary filtering is not only redundant but also buggy. All items that are not "upcoming" should be part of past30Days.

      if (d > today) upcoming.push(item);
      else past30Days.push(item);

Comment on lines +392 to +403
ShibirBookingDb.findAll({
where: { cardno },
include: [
{
model: ShibirDb,
attributes: ["start_date", "end_date", "name"],
required: true
}
],
raw: true,
nest: true
}),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The current query fetches all shibir bookings for the user and filters them in the application. This is inefficient if the user has many historical bookings. It's better to filter at the database level by checking the shibir's end date to only retrieve relevant bookings.

      ShibirBookingDb.findAll({
        where: { cardno },
        include: [
          {
            model: ShibirDb,
            attributes: ["start_date", "end_date", "name"],
            required: true,
            where: {
              end_date: { [Op.gte]: past30 },
            },
          },
        ],
        raw: true,
        nest: true,
      }),

Comment on lines +415 to +426
UtsavBooking.findAll({
where: { cardno },
include: [
{
model: UtsavDb,
attributes: ["start_date", "end_date", "name"],
required: true
}
],
raw: true,
nest: true
}),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

Similar to the shibir bookings query, this query fetches all utsav bookings for the user and filters them in the application, which is inefficient. Filtering should be done in the database based on the utsav's end date to avoid fetching unnecessary historical data.

      UtsavBooking.findAll({
        where: { cardno },
        include: [
          {
            model: UtsavDb,
            attributes: ["start_date", "end_date", "name"],
            required: true,
            where: {
              end_date: { [Op.gte]: past30 },
            },
          },
        ],
        raw: true,
        nest: true,
      }),

Comment on lines +509 to +512
return res.status(500).json({
message: "Failed to fetch person activity",
error: error.message
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

security-medium medium

The getPersonActivity function catches errors and returns the raw error.message in the HTTP response. This can expose sensitive information about the database schema, query structure, or internal application logic to an attacker. If a database query fails, the error message might reveal table names, column names, or other internal details that can be used to facilitate further attacks. It is recommended to return a generic error message to the client and log the detailed error internally for debugging purposes.

Comment on lines +344 to +347
[Op.or]: [
{ checkin: { [Op.gte]: past30 } },
{ checkout: { [Op.gte]: past30 } }
]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The Op.or condition here is unnecessarily complex. Assuming a booking's checkout date is always on or after its checkin date, the checkin: { [Op.gte]: past30 } condition is redundant. If checkin is within the last 30 days, checkout must also be. The query can be simplified to just check checkout, which correctly identifies all bookings active during the period and is easier to understand.

          checkout: { [Op.gte]: past30 }

Comment on lines +356 to +359
[Op.or]: [
{ checkin: { [Op.gte]: past30 } },
{ checkout: { [Op.gte]: past30 } }
]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Similar to the flat booking query, this Op.or condition is likely unnecessarily complex. Assuming checkout is always on or after checkin, the query can be simplified to just check checkout: { [Op.gte]: past30 }. This makes the code clearer and achieves the same result of finding all rooms booked during the relevant period.

          checkout: { [Op.gte]: past30 }

Base automatically changed from dev to main April 14, 2026 16:40
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