Skip to content

Commit

Permalink
feat: add ICPC series preset filter, remove contest.link
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamerblue committed Sep 2, 2023
1 parent aa03c40 commit e15083f
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 35 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# CHANGELOG

## 0.3.3

- Feature: add `filter` option for series preset `RankSeriesRulePresetICPC`
- Change: `contest.link` has been removed. Use `contest.refLinks` to declare all related external links

## 0.3.2

- Feature: add `remarks` field
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Standard Ranklist (srk) is a json format to describe many kinds of ranklists lik

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.

Version: `0.3.2`
Version: `0.3.3`

## Files

Expand Down
9 changes: 7 additions & 2 deletions demo.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type": "general",
"version": "0.3.2",
"version": "0.3.3",
"remarks": "This is a demo ranklist.",
"contributors": [
"bLue <[email protected]> (https://example.com/)"
Expand All @@ -16,7 +16,12 @@
1,
"h"
],
"link": "https://icpc.baylor.edu/scoreboard/"
"refLinks": [
{
"title": "Original Ranklist",
"link": "https://icpc.baylor.edu/scoreboard/"
}
]
},
"problems": [
{
Expand Down
15 changes: 9 additions & 6 deletions demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@ import * as srk from '.';

const ranklist: srk.Ranklist = {
type: 'general',
version: '0.3.2',
version: '0.3.3',
remarks: 'This is a demo ranklist.',
contributors: [
"bLue <[email protected]> (https://example.com/)"
],
contributors: ['bLue <[email protected]> (https://example.com/)'],
contest: {
title: 'ACM ICPC World Finals 2018',
startAt: '2018-04-19T17:00:00+08:00',
duration: [5, 'h'],
frozenDuration: [1, 'h'],
link: 'https://icpc.baylor.edu/scoreboard/',
refLinks: [
{
title: 'Original Ranklist',
link: 'https://icpc.baylor.edu/scoreboard/',
},
],
},
problems: [
{
Expand Down Expand Up @@ -65,7 +68,7 @@ const ranklist: srk.Ranklist = {
},
},
},
}
},
],
rows: [
{
Expand Down
64 changes: 39 additions & 25 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Copyright (c) algoUX. All rights reserved.
***************************************************************************** */

export type Type = 'general';
export type Version = '0.3.2';
export type Version = '0.3.3';

//#region common

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

/**
* i18n string set.
* @example
* { "en-US": 'English', "zh-CN": '中文', fallback: 'English' }
*/
export type I18NStringSet = {
/** The fallback string if renderer cannot determine the language to use. */
fallback: string;
/** The key is the IETF BCP 47 language tag, and the value is the string for this language tag. */
[key: string]: string;
};

/**
* Text (i18n supported).
*/
export type Text = string | I18NStringSet;

/** URL. */
export type Link = string;

Expand All @@ -39,7 +56,7 @@ export type Link = string;
*/
export interface LinkWithTitle {
link: Link;
title: string;
title: Text;
}

/** Base64 string. */
Expand Down Expand Up @@ -100,23 +117,6 @@ export interface Style {
backgroundColor?: ThemeColor;
}

/**
* i18n string set.
* @example
* { "en-US": 'English', "zh-CN": '中文', fallback: 'English' }
*/
export type I18NStringSet = {
/** The fallback string if renderer cannot determine the language to use. */
fallback: string;
/** The key is the IETF BCP 47 language tag, and the value is the string for this language tag. */
[key: string]: string;
};

/**
* Text (i18n supported).
*/
export type Text = string | I18NStringSet;

/**
* Contributor field. The email and url are optional.
* @example
Expand Down Expand Up @@ -298,12 +298,6 @@ export interface Contest {
/** Banner image. */
banner?: Image | ImageWithLink;

/**
* The link to view original contest.
* @defaultValue Ignored by renderer.
*/
link?: Link;

/**
* Reference links of contest.
* @defaultValue Ignored by renderer.
Expand Down Expand Up @@ -436,6 +430,26 @@ export interface RankSeriesRulePresetICPC {
*/
noTied?: boolean;
};

/**
* Use filter to determine users to be included.
* Only if the user matches all filter options, it will be included as denominator.
*/
filter?: {
byUserFields?: {
/**
* The field name of `user` to be filtered.
* @example 'organization'
*/
field: keyof User;

/**
* The field match rule (RegExp constructor string) of `user` to be filtered.
* @example 'SDUT'
*/
rule: string;
}[];
},
};
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@algoux/standard-ranklist",
"version": "0.3.2",
"version": "0.3.3",
"description": "Standard Ranklist",
"types": "index.d.ts",
"scripts": {
Expand Down

0 comments on commit e15083f

Please sign in to comment.