OpenCSGs / csghub-server

csghub-server is the backend server for CSGHub which helps user to manage datasets, modes, and also run Model Inference, Finetune and Application Spaces.
https://opencsg.com/models
Apache License 2.0
556 stars 98 forks source link

Add last_updated_at to dataset model #176

Closed pulltheflower closed 4 days ago

pulltheflower commented 4 days ago

MR Summary:

The summary is added by @codegpt.

The Merge Request introduces a new field LastUpdatedAt of type time.Time to the Dataset struct in the dataset model to track the last update time. This field is marked as not null in the database schema and is automatically set to the current time (time.Now()) during dataset creation, update, or when a dataset is created if it does not exist. This enhancement aims to fix an error related to dataset creation by ensuring that the LastUpdatedAt field is always populated with the latest timestamp when a dataset undergoes any form of modification.

Key updates:

  1. Added LastUpdatedAt field to the Dataset struct.
  2. Automatically set LastUpdatedAt to the current time during dataset creation, update, or conditional creation if not existing.
starship-github[bot] commented 4 days ago

Linter Issue Report

During the code review, a list issues were found. These issues could affect the code quality, maintainability, and consistency. Below is the detailed Linter issue report:

builder/store/database/dataset.go ### Lint Issue: undefined: assertAffectedOneRow - **Location**: Line 136, Column 12 - **Code Snippet**: ```go if err := assertAffectedOneRow(res, err); err != nil { slog.Error("create dataset in db failed", slog.String("error", err.Error())) return nil, fmt.Errorf("create dataset in db failed,error:%w", err) } ``` - **Suggestion**: It seems like the function `assertAffectedOneRow` is not defined within the scope of your code. Ensure that you have defined this function or imported the package containing its definition. If it's a custom utility function, verify that it's correctly implemented and accessible in this file. Alternatively, if this function is meant to check the result of a database operation, consider implementing a local function that checks if `res.RowsAffected() == 1` to ensure only one row is affected by the operation. ### Lint Issue: undefined: assertAffectedOneRow - **Location**: Line 217, Column 12 - **Code Snippet**: ```go if err := assertAffectedOneRow(res, err); err != nil { return fmt.Errorf("delete dataset in tx failed,error:%w", err) } ``` - **Suggestion**: Similar to the previous issue, the `assertAffectedOneRow` function is undefined. Ensure the function is correctly defined or imported. For operations where you expect exactly one row to be affected, you can directly use `res.RowsAffected()` to check the number of rows impacted and handle any discrepancies accordingly.

Please make the suggested changes to improve the code quality.

starship-github[bot] commented 4 days ago

Possible Issues And Suggestions:

MR Evaluation:

This feature is still under test, evaluation are given by AI and might be inaccurate.

After evaluation, the code changes in the Merge Request get score: 90.

Analysis for the evaluation score: - The code change may not include corresponding unit tests. - The code change may not include corresponding integration testing.
Tips ### CodeReview Commands (invoked as MR or PR comments) - `@codegpt /review` to trigger an code review. - `@codegpt /evaluate` to trigger code evaluation process. - `@codegpt /describe` to regenerate the summary of the MR. - `@codegpt /secscan` to scan security vulnerabilities for the MR or the Repository. - `@codegpt /help` to get help. ### CodeReview Discussion Chat There are 2 ways to chat with [Starship CodeReview]( https://starship.opencsg.com): - Review comments: Directly reply to a review comment made by StarShip. Example: - `@codegpt How to fix this bug?` - Files and specific lines of code (under the "Files changed" tab): Tag `@codegpt` in a new review comment at the desired location with your query. Examples: - `@codegpt generate unit testing code for this code snippet.` Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the MR/PR comments. ### CodeReview Documentation and Community - Visit our [Documentation](https://opencsg.com/docs/StarShip/codereview/) for detailed information on how to use Starship CodeReview.

About Us:

Visit the OpenCSG StarShip website for the Dashboard and detailed information on CodeReview, CodeGen, and other StarShip modules.

starship-github[bot] commented 4 days ago

The StarShip CodeReviewer was triggered but terminated because it encountered an issue: The MR state is not opened.

Tips ### CodeReview Commands (invoked as MR or PR comments) - `@codegpt /review` to trigger an code review. - `@codegpt /evaluate` to trigger code evaluation process. - `@codegpt /describe` to regenerate the summary of the MR. - `@codegpt /secscan` to scan security vulnerabilities for the MR or the Repository. - `@codegpt /help` to get help. ### CodeReview Discussion Chat There are 2 ways to chat with [Starship CodeReview]( https://starship.opencsg.com): - Review comments: Directly reply to a review comment made by StarShip. Example: - `@codegpt How to fix this bug?` - Files and specific lines of code (under the "Files changed" tab): Tag `@codegpt` in a new review comment at the desired location with your query. Examples: - `@codegpt generate unit testing code for this code snippet.` Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the MR/PR comments. ### CodeReview Documentation and Community - Visit our [Documentation](https://opencsg.com/docs/StarShip/codereview/) for detailed information on how to use Starship CodeReview.