Skip to content

Commit 624e1e7

Browse files
committed
handles param 'assignee_date_mode' (when set to 'skip' the report is much faster)
1 parent 43513af commit 624e1e7

File tree

8 files changed

+73
-26
lines changed

8 files changed

+73
-26
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- handles param 'assignee_date_mode' (when set to 'skip' the report is much faster)
13+
1014
## [1.1.0] - 2024-05-22
1115

1216
### Added

README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,14 @@ java -jar target/dist-github-issue-export-*.jar --gui 0 \
3636

3737
## **parameter help**
3838

39-
| **name** | **required** | **default** | **description** | **since** | **info** |
40-
|---------------|---------------|---------------|---------------|---------------|---------------|
41-
| `gui` | `false` | `true` | If `true` will open the Export GUI. | 0.6.2 | `true` or `1` will both evaluate to `true`. |
42-
| `owner` | `false` | none | Repository owner (ex. 'fugerit-org'). | 0.6.2 | Required in command line mode (gui parameter = 0). |
43-
| `repo` | `false` | none | Repository name (ex. 'github-issue-export'). | 0.6.2 | Required in command line mode (gui parameter = 0). |
44-
| `xls-file` | `false` | none | Path to the .xls file (ex. 'report.xls'). | 0.6.2 | Required in command line mode (gui parameter = 0). |
45-
| `github-token` | `false` | none | Github auth token. | 0.6.2 | Needed for privare repositories or to increase github api usage limits. |
46-
| `lang` | `false` | none | Language code, currently supported : 'en', 'it'. | 0.6.2 | If not set will default to default locale or en. |
47-
| `help` | `false` | none | Print help about the tool. | 0.1.0 | |
39+
| **name** | **required** | **default** | **description** | **since** | **info** |
40+
|----------------------|--------------|-------------|-----------------------------------------------------------|-----------|-------------------------------------------------------------------------|
41+
| `gui` | `false` | `true` | If `true` will open the Export GUI. | 0.6.2 | `true` or `1` will both evaluate to `true`. |
42+
| `owner` | `false` | none | Repository owner (ex. 'fugerit-org'). | 0.6.2 | Required in command line mode (gui parameter = 0). |
43+
| `repo` | `false` | none | Repository name (ex. 'github-issue-export'). | 0.6.2 | Required in command line mode (gui parameter = 0). |
44+
| `xls-file` | `false` | none | Path to the .xls file (ex. 'report.xls'). | 0.6.2 | Required in command line mode (gui parameter = 0). |
45+
| `github-token` | `false` | none | Github auth token. | 0.6.2 | Needed for privare repositories or to increase github api usage limits. |
46+
| `lang` | `false` | none | Language code, currently supported : 'en', 'it'. | 0.6.2 | If not set will default to default locale or en. |
47+
| `assignee_date_mode` | `false` | all | Accepted value are 'all', 'skip', 'cache', 'skip-closed'. | 1.2.0 | When set to skip export is faster. |
48+
| `help` | `false` | none | Print help about the tool. | 0.1.0 | |
4849

src/main/java/org/fugerit/java/github/issue/export/GithubIssueExport.java

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -174,17 +174,19 @@ private static void handleAssigned( List<String> currentLine, Map issue, String
174174
if ( assignee != null ) {
175175
currentLine.add( String.valueOf( assignee.get( "login" ) ) );
176176
String assignDate = null;
177-
boolean activeCache = activeCache( cacheMode);
178-
if ( activeCache ) {
179-
assignDate = info.getCacheEntry( issueId , GithubIssueConfig.FIELD_ASSIGN_DATE );
180-
}
181-
logger.info( "activeCache : {} - issueId:{} , assign date {}", activeCache, issueId, assignDate );
182-
if ( assignDate == null ) {
183-
if ( ARG_STATE_CLOSED.equalsIgnoreCase( state ) && ARG_ASSIGNEE_DATE_MODE_SKIP_CLOSED.equals( cacheMode ) ) {
184-
// just skip
185-
} else {
186-
assignDate = handleAssignedIssue(issue, issueId, activeCache, info);
187-
}
177+
if ( !ARG_ASSIGNEE_DATE_MODE_SKIP.equals( info.getProperty( ARG_ASSIGNEE_DATE_MODE ) ) ) {
178+
boolean activeCache = activeCache( cacheMode);
179+
if ( activeCache ) {
180+
assignDate = info.getCacheEntry( issueId , GithubIssueConfig.FIELD_ASSIGN_DATE );
181+
}
182+
logger.info( "activeCache : {} - issueId:{} , assign date {}", activeCache, issueId, assignDate );
183+
if ( assignDate == null ) {
184+
if ( ARG_STATE_CLOSED.equalsIgnoreCase( state ) && ARG_ASSIGNEE_DATE_MODE_SKIP_CLOSED.equals( cacheMode ) ) {
185+
// just skip
186+
} else {
187+
assignDate = handleAssignedIssue(issue, issueId, activeCache, info);
188+
}
189+
}
188190
}
189191
currentLine.add( FormatHelper.formatDate( assignDate, lang ) );
190192
} else {

src/main/java/org/fugerit/java/github/issue/export/GithubIssueGUI.java

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,14 @@ public class GithubIssueGUI extends JFrame implements WindowListener, ActionList
6868
private JTextField inputXlsPath;
6969
private JTextField inputLocale;
7070

71-
private JComboBox<String> inputStateCombo;
71+
private JComboBox<String> inputStateCombo, inputAssignDateCombo;
7272

7373
private String labelStateOpen;
7474
private String labelStateClosed;
7575
private String labelStateAll;
76+
77+
private String labelAssignDateDefault;
78+
private String labelAssignDateSkip;
7679

7780
private transient ResourceBundle lagelBundle;
7881

@@ -182,6 +185,7 @@ private void initConf() {
182185
this.inputRepoPass = new JPasswordField( savedPass );
183186
this.inputXlsPath = newJTextField( this.config.getProperty( GithubIssueExport.ARG_XLSFILE, defaultInputText ) );
184187
this.inputLocale = newJTextField( defaultLocale );
188+
// input state combo
185189
this.inputStateCombo = new JComboBox<>();
186190
this.labelStateOpen = this.lagelBundle.getString( "label.input.state.open" );
187191
this.labelStateClosed = this.lagelBundle.getString( "label.input.state.closed" );
@@ -199,7 +203,18 @@ private void initConf() {
199203
this.inputStateCombo.setSelectedItem( this.labelStateAll );
200204
}
201205
}
202-
206+
// input assign date handling combo
207+
this.inputAssignDateCombo = new JComboBox<>();
208+
this.labelAssignDateDefault = this.lagelBundle.getString( "label.input.assignDate.default" );
209+
this.labelAssignDateSkip = this.lagelBundle.getString( "label.input.assignDate.skip" );
210+
this.inputAssignDateCombo.addItem( this.labelAssignDateDefault );
211+
this.inputAssignDateCombo.addItem( this.labelAssignDateSkip );
212+
String selectedStateAssignDate = this.config.getProperty( GithubIssueExport.ARG_ASSIGNEE_DATE_MODE );
213+
if ( GithubIssueExport.ARG_ASSIGNEE_DATE_MODE_SKIP.equalsIgnoreCase( selectedStateAssignDate ) ) {
214+
this.inputAssignDateCombo.setSelectedItem( this.labelAssignDateSkip );
215+
} else {
216+
this.inputAssignDateCombo.setSelectedItem( this.labelAssignDateDefault );
217+
}
203218
// buttons
204219
this.buttonSaveConfiguration = new JButton( this.lagelBundle.getString( "button.input.configuration.save" ) );
205220
this.buttonSaveConfiguration.addActionListener( this );
@@ -246,7 +261,7 @@ private void initLayout() {
246261
// add row
247262
JPanel reportPanel2 = new JPanel( new GridLayout( 1 , 2 ) );
248263
newRowPanel( newJLabel( this.lagelBundle.getString( "label.input.output.xls" ) ), this.inputXlsPath, reportPanel2 );
249-
reportPanel2.add( new JLabel( "" ) );
264+
newRowPanel( newJLabel( this.lagelBundle.getString( "label.input.assignDate.label" ) ), this.inputAssignDateCombo, reportPanel2 );
250265
addRow( reportPanel2 , mainPanel );
251266
// add row
252267
addRow( new JLabel( "" ), mainPanel );
@@ -357,6 +372,9 @@ private void performMainAction( Object source ) {
357372
this.config.setProperty( GithubIssueExport.ARG_PROXY_PASS , new String( this.inputProxyPass.getPassword() ) );
358373
this.config.setProperty( GithubIssueExport.ARG_GITHUB_USER , this.inputRepoUser.getText() );
359374
this.config.setProperty( GithubIssueExport.ARG_GITHUB_PASS , new String( this.inputRepoPass.getPassword() ) );
375+
if ( this.inputAssignDateCombo.getSelectedItem() == this.labelAssignDateSkip ) {
376+
this.config.setProperty( GithubIssueExport.ARG_ASSIGNEE_DATE_MODE , GithubIssueExport.ARG_ASSIGNEE_DATE_MODE_SKIP );
377+
}
360378
String selectedState = this.inputStateCombo.getSelectedItem().toString();
361379
if ( selectedState.equalsIgnoreCase( this.labelStateOpen ) ) {
362380
this.config.setProperty( GithubIssueExport.ARG_STATE , GithubIssueExport.ARG_STATE_OPEN );
@@ -365,6 +383,13 @@ private void performMainAction( Object source ) {
365383
} else if ( selectedState.equalsIgnoreCase( this.labelStateAll ) ) {
366384
this.config.setProperty( GithubIssueExport.ARG_STATE , GithubIssueExport.ARG_STATE_ALL );
367385
}
386+
// skip assign date
387+
String selectedStateAssignDateMode = this.inputAssignDateCombo.getSelectedItem().toString();
388+
if ( selectedStateAssignDateMode.equalsIgnoreCase( this.labelAssignDateSkip ) ) {
389+
this.config.setProperty( GithubIssueExport.ARG_ASSIGNEE_DATE_MODE , GithubIssueExport.ARG_ASSIGNEE_DATE_MODE_SKIP );
390+
} else {
391+
this.config.remove( GithubIssueExport.ARG_ASSIGNEE_DATE_MODE );
392+
}
368393
if ( source == this.buttonGenerateReport ) {
369394
if ( StringUtils.isEmpty( this.inputXlsPath.getText() ) ) {
370395
this.outputArea.setText( this.lagelBundle.getString( "label.output.area.generate.validate.noOutputFile" ) );
@@ -390,7 +415,7 @@ private void performMainAction( Object source ) {
390415
String baseText = this.lagelBundle.getString( "label.output.area.configuration.saved" );
391416
this.outputArea.setText( baseText+" "+this.configSavePath.getAbsolutePath() );
392417
} catch (Exception ex) {
393-
logger.warn( "Failed to save configuration "+this.configSavePath, ex );
418+
logger.warn( String.format( "Failed to save configuration %s", this.configSavePath ), ex );
394419
}
395420
this.config.setProperty( GithubIssueExport.ARG_GITHUB_PASS , tempPass1 );
396421
this.config.setProperty( GithubIssueExport.ARG_PROXY_PASS , tempPass2 );

src/main/resources/org/fugerit/java/github/issue/export/config/gui/gui-label_xml.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
<entry key="label.input.state.closed"> Closed </entry>
2727
<entry key="label.input.state.open"> Open </entry>
2828
<entry key="label.input.state.all"> All </entry>
29+
<entry key="label.input.assignDate.label"> Assign date </entry>
30+
<entry key="label.input.assignDate.default"> Default </entry>
31+
<entry key="label.input.assignDate.skip"> Skip </entry>
2932

3033
<entry key="label.input.proxy.title"> Proxy </entry>
3134
<entry key="label.input.proxy.host"> Host </entry>

src/main/resources/tool-config/help.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,7 @@ Example : java -jar target/dist-github-issue-export-*.jar
1818

1919
--lang <arg> Language code, currently supported : 'en', 'it'.
2020

21+
--assignee_date_mode <arg> Accepted value are 'all', 'skip', 'cache', 'skip-closed'. [default:all]
22+
2123
--help <arg> Print help about the tool.
2224

src/main/resources/tool-config/tool-help-config.xml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,16 @@
6060
<since>0.6.2</since>
6161
<info>If not set will default to default locale or en.</info>
6262
</param>
63-
63+
64+
<param>
65+
<id>`assignee_date_mode`</id>
66+
<required>`false`</required>
67+
<defaultValue>all</defaultValue>
68+
<description>Accepted value are 'all', 'skip', 'cache', 'skip-closed'.</description>
69+
<since>1.2.0</since>
70+
<info>When set to skip export is faster.</info>
71+
</param>
72+
6473
<param>
6574
<id>`help`</id>
6675
<required>`false`</required>

src/test/java/test/org/fugerit/java/github/issue/export/TestGithubIssueExportMain.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ public void testGui() {
9393

9494
@Test
9595
public void testGuiLocale() {
96-
String[] args = { ArgUtils.getArgString( GithubIssueExportMain.ARG_GUI_LOCALE ), Locale.ENGLISH.toString() };
96+
String[] args = { ArgUtils.getArgString( GithubIssueExportMain.ARG_GUI_LOCALE ), Locale.ENGLISH.toString(),
97+
ArgUtils.getArgString( GithubIssueExportMain.ARG_GUI_PRESET_ARG_ASSIGNEE_DATE_MODE ), GithubIssueExport.ARG_ASSIGNEE_DATE_MODE_SKIP };
9798
GithubIssueExportMain.main(args);
9899
Assert.assertTrue( true );
99100
}

0 commit comments

Comments
 (0)