Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: AddDataValidation() and DeleteDataValidation() are concurrency safe, and add some unit test and code optimization. #1828

Merged
merged 6 commits into from
Mar 1, 2024

Conversation

JackMin1314
Copy link
Contributor

PR Details

This pr contains two commits, non-breaking change which fixes an issue and adds a function.

  1. fix: data validation is unsafe when used in concurrent condition#1825
  2. feat: supports batch append data validation to the worksheet and optimse code#1826

Description

  1. For the first commit which open related issue DataValidation is unsafe when used in concurrent condition #1825 and has detail description about this. Use the mutex's method Lock() and Unlock() which is in the *File object.

  2. Optimse code: Extract some code about xlsxDataValidation creation and keep the contents of the AddDataValidation function clean

  3. And a new function named BatchAddDataValidation() to batch append data validation to the worksheet for some typical excel data validation template scenario.

Related Issue

#1825

#1826

Motivation and Context

How Has This Been Tested

There are some test cases already written in test file datavalidation_test.go and two testing functions: TestConcurrentAddDataValidation() for high concurrency and TestBatchAddDataValidation() to batch append data validation.

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@xuri xuri added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Feb 27, 2024
Copy link
Member

@xuri xuri left a comment

Choose a reason for hiding this comment

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

Thanks for your pull request. I've left some comments.

datavalidation.go Outdated Show resolved Hide resolved
datavalidation.go Outdated Show resolved Hide resolved
datavalidation_test.go Outdated Show resolved Hide resolved
datavalidation.go Outdated Show resolved Hide resolved
@JackMin1314 JackMin1314 changed the title Feat batch add data validation Feat: AddDataValidation() and DeleteDataValidation() are concurrency safe, and add some unit test and code optimization. Mar 1, 2024
@xuri xuri added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 1, 2024
Copy link

codecov bot commented Mar 1, 2024

Codecov Report

Attention: Patch coverage is 95.45455% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 99.21%. Comparing base (7b4da39) to head (277df9f).

Files Patch % Lines
adjust.go 75.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1828   +/-   ##
=======================================
  Coverage   99.21%   99.21%           
=======================================
  Files          32       32           
  Lines       23926    23930    +4     
=======================================
+ Hits        23737    23741    +4     
  Misses        101      101           
  Partials       88       88           
Flag Coverage Δ
unittests 99.21% <95.45%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@xuri xuri left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for your contribution.

@xuri xuri merged commit 9d4c2e6 into qax-os:master Mar 1, 2024
34 of 35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
No open projects
Status: Features
Development

Successfully merging this pull request may close these issues.

2 participants