Skip to content

Commit e15083f

Browse files
committed
feat: add ICPC series preset filter, remove contest.link
1 parent aa03c40 commit e15083f

File tree

6 files changed

+62
-35
lines changed

6 files changed

+62
-35
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# CHANGELOG
22

3+
## 0.3.3
4+
5+
- Feature: add `filter` option for series preset `RankSeriesRulePresetICPC`
6+
- Change: `contest.link` has been removed. Use `contest.refLinks` to declare all related external links
7+
38
## 0.3.2
49

510
- Feature: add `remarks` field

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Standard Ranklist (srk) is a json format to describe many kinds of ranklists lik
44

55
With srk, most of programming contest ranklists can be described in a standard format. It's easy to customize display style with different renderers and share everywhere.
66

7-
Version: `0.3.2`
7+
Version: `0.3.3`
88

99
## Files
1010

demo.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"type": "general",
3-
"version": "0.3.2",
3+
"version": "0.3.3",
44
"remarks": "This is a demo ranklist.",
55
"contributors": [
66
"bLue <mail@example.com> (https://example.com/)"
@@ -16,7 +16,12 @@
1616
1,
1717
"h"
1818
],
19-
"link": "https://icpc.baylor.edu/scoreboard/"
19+
"refLinks": [
20+
{
21+
"title": "Original Ranklist",
22+
"link": "https://icpc.baylor.edu/scoreboard/"
23+
}
24+
]
2025
},
2126
"problems": [
2227
{

demo.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,20 @@ import * as srk from '.';
22

33
const ranklist: srk.Ranklist = {
44
type: 'general',
5-
version: '0.3.2',
5+
version: '0.3.3',
66
remarks: 'This is a demo ranklist.',
7-
contributors: [
8-
"bLue <mail@example.com> (https://example.com/)"
9-
],
7+
contributors: ['bLue <mail@example.com> (https://example.com/)'],
108
contest: {
119
title: 'ACM ICPC World Finals 2018',
1210
startAt: '2018-04-19T17:00:00+08:00',
1311
duration: [5, 'h'],
1412
frozenDuration: [1, 'h'],
15-
link: 'https://icpc.baylor.edu/scoreboard/',
13+
refLinks: [
14+
{
15+
title: 'Original Ranklist',
16+
link: 'https://icpc.baylor.edu/scoreboard/',
17+
},
18+
],
1619
},
1720
problems: [
1821
{
@@ -65,7 +68,7 @@ const ranklist: srk.Ranklist = {
6568
},
6669
},
6770
},
68-
}
71+
},
6972
],
7073
rows: [
7174
{

index.d.ts

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Copyright (c) algoUX. All rights reserved.
44
***************************************************************************** */
55

66
export type Type = 'general';
7-
export type Version = '0.3.2';
7+
export type Version = '0.3.3';
88

99
//#region common
1010

@@ -29,6 +29,23 @@ export type TimeUnit = 'ms' | 's' | 'min' | 'h' | 'd';
2929
*/
3030
export type TimeDuration = [number, TimeUnit];
3131

32+
/**
33+
* i18n string set.
34+
* @example
35+
* { "en-US": 'English', "zh-CN": '中文', fallback: 'English' }
36+
*/
37+
export type I18NStringSet = {
38+
/** The fallback string if renderer cannot determine the language to use. */
39+
fallback: string;
40+
/** The key is the IETF BCP 47 language tag, and the value is the string for this language tag. */
41+
[key: string]: string;
42+
};
43+
44+
/**
45+
* Text (i18n supported).
46+
*/
47+
export type Text = string | I18NStringSet;
48+
3249
/** URL. */
3350
export type Link = string;
3451

@@ -39,7 +56,7 @@ export type Link = string;
3956
*/
4057
export interface LinkWithTitle {
4158
link: Link;
42-
title: string;
59+
title: Text;
4360
}
4461

4562
/** Base64 string. */
@@ -100,23 +117,6 @@ export interface Style {
100117
backgroundColor?: ThemeColor;
101118
}
102119

103-
/**
104-
* i18n string set.
105-
* @example
106-
* { "en-US": 'English', "zh-CN": '中文', fallback: 'English' }
107-
*/
108-
export type I18NStringSet = {
109-
/** The fallback string if renderer cannot determine the language to use. */
110-
fallback: string;
111-
/** The key is the IETF BCP 47 language tag, and the value is the string for this language tag. */
112-
[key: string]: string;
113-
};
114-
115-
/**
116-
* Text (i18n supported).
117-
*/
118-
export type Text = string | I18NStringSet;
119-
120120
/**
121121
* Contributor field. The email and url are optional.
122122
* @example
@@ -298,12 +298,6 @@ export interface Contest {
298298
/** Banner image. */
299299
banner?: Image | ImageWithLink;
300300

301-
/**
302-
* The link to view original contest.
303-
* @defaultValue Ignored by renderer.
304-
*/
305-
link?: Link;
306-
307301
/**
308302
* Reference links of contest.
309303
* @defaultValue Ignored by renderer.
@@ -436,6 +430,26 @@ export interface RankSeriesRulePresetICPC {
436430
*/
437431
noTied?: boolean;
438432
};
433+
434+
/**
435+
* Use filter to determine users to be included.
436+
* Only if the user matches all filter options, it will be included as denominator.
437+
*/
438+
filter?: {
439+
byUserFields?: {
440+
/**
441+
* The field name of `user` to be filtered.
442+
* @example 'organization'
443+
*/
444+
field: keyof User;
445+
446+
/**
447+
* The field match rule (RegExp constructor string) of `user` to be filtered.
448+
* @example 'SDUT'
449+
*/
450+
rule: string;
451+
}[];
452+
},
439453
};
440454
}
441455

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@algoux/standard-ranklist",
3-
"version": "0.3.2",
3+
"version": "0.3.3",
44
"description": "Standard Ranklist",
55
"types": "index.d.ts",
66
"scripts": {

0 commit comments

Comments
 (0)