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!: symbol coefficients and configurable scores per group #68

Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
93ccc25
feat: html score is now based per select item
gentlementlegen Jul 23, 2024
baf7746
chore: fixed tests
gentlementlegen Jul 23, 2024
44904a9
chore: fixed tests
gentlementlegen Jul 23, 2024
45489d3
feat: multipliers are based on symbols representing a regex
gentlementlegen Jul 23, 2024
c345948
chore: fixing tests
gentlementlegen Jul 24, 2024
a372bab
chore: fixing tests
gentlementlegen Jul 24, 2024
5046c14
chore: fixing tests
gentlementlegen Jul 24, 2024
39bd186
chore: fixing tests
gentlementlegen Jul 24, 2024
c92d0a5
chore: fixing tests
gentlementlegen Jul 24, 2024
6a4d9f6
chore: fixing tests
gentlementlegen Jul 24, 2024
eca0aa0
chore: fixing tests
gentlementlegen Jul 24, 2024
d170c9f
chore: fixing tests
gentlementlegen Jul 24, 2024
b8c83c0
chore: fixing tests
gentlementlegen Jul 24, 2024
c2e9443
chore: updated README.md
gentlementlegen Jul 24, 2024
44bb136
chore: merge develop
gentlementlegen Jul 26, 2024
6a9361f
chore: default configuration to null
gentlementlegen Jul 26, 2024
23bc825
chore: fixed README.md and infinite division
gentlementlegen Jul 26, 2024
73458ba
chore: updated README.md
gentlementlegen Jul 26, 2024
5ec57f7
chore: changed total count
gentlementlegen Jul 26, 2024
1e5aedb
chore: optional formatting evaluator
gentlementlegen Jul 26, 2024
1e42677
chore: log configuration
gentlementlegen Jul 26, 2024
5717dc3
chore: log configuration
gentlementlegen Jul 26, 2024
8bf00cc
chore: null defaults for configuration
gentlementlegen Jul 26, 2024
7a64286
chore: null defaults for configuration
gentlementlegen Jul 26, 2024
e92faf0
Merge branch 'refs/heads/feat/symbol-coefficient' into fix/undefined-…
gentlementlegen Jul 26, 2024
af63549
chore: changed error message for module configuration
gentlementlegen Jul 26, 2024
c155eed
Merge branch 'development' into feat/symbol-coefficient
gentlementlegen Jul 29, 2024
027af97
chore: fix merge
gentlementlegen Jul 29, 2024
20f123d
chore: removed default configuration merging
gentlementlegen Jul 30, 2024
89237e6
Update src/configuration/incentives.ts
gentlementlegen Jul 30, 2024
20bd994
chore: merged fixes
gentlementlegen Aug 5, 2024
f892bc9
Merge branch 'development' into feat/symbol-coefficient
gentlementlegen Aug 15, 2024
61f8ec0
chore: new schema (WIP)
gentlementlegen Aug 15, 2024
6749a5f
Merge branch 'fix/undefined-configuration' into feat/symbol-coefficient
gentlementlegen Aug 15, 2024
5117a4f
chore: fixed mock for valid configuration
gentlementlegen Aug 15, 2024
90bc3a8
chore: fix tests for split reward
gentlementlegen Aug 15, 2024
c11ebc3
chore: fix tests
gentlementlegen Aug 15, 2024
db0b6ec
chore: added default missing objects in README.md
gentlementlegen Aug 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/configuration/config-reader.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
import program from "../parser/command-line";
import { IncentivesConfiguration, incentivesConfigurationSchema, validateIncentivesConfiguration } from "./incentives";
import { Value } from "@sinclair/typebox/value";
import { merge } from "lodash";
import program from "../parser/command-line";
import { IncentivesConfiguration, incentivesConfigurationSchema, validateIncentivesConfiguration } from "./incentives";

let configuration: IncentivesConfiguration | null = null;

try {
const defaultConf = Value.Create(incentivesConfigurationSchema);
configuration = Value.Decode(incentivesConfigurationSchema, defaultConf);
configuration = Value.Default(incentivesConfigurationSchema, {}) as IncentivesConfiguration;
} catch (e) {
console.error(e);
}

if (program.settings) {
const settings = merge(configuration, JSON.parse(program.settings));
const settings = merge(
configuration,
Value.Default(incentivesConfigurationSchema, JSON.parse(program.settings)) as IncentivesConfiguration
);
if (validateIncentivesConfiguration.test(settings)) {
gentlementlegen marked this conversation as resolved.
Show resolved Hide resolved
configuration = settings;
configuration = Value.Decode(incentivesConfigurationSchema, settings);
} else {
console.warn("Invalid incentives configuration detected, will revert to defaults.");
for (const error of validateIncentivesConfiguration.errors(settings)) {
console.warn(error);
}
}
}

export default configuration as IncentivesConfiguration;
23 changes: 13 additions & 10 deletions src/configuration/data-collection-config.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { Static, Type } from "@sinclair/typebox";

export const dataCollectionConfigurationType = Type.Object({
/**
* The maximum amount of retries on failure.
*/
maxAttempts: Type.Number({ default: 10, minimum: 1 }),
/**
* The delay between each retry, in milliseconds.
*/
delayMs: Type.Number({ default: 10000, minimum: 100 }),
});
export const dataCollectionConfigurationType = Type.Object(
{
/**
* The maximum amount of retries on failure.
*/
maxAttempts: Type.Number({ default: 10, minimum: 1 }),
/**
* The delay between each retry, in milliseconds.
*/
delayMs: Type.Number({ default: 10000, minimum: 100 }),
},
{ default: {} }
);

export type DataCollectionConfiguration = Static<typeof dataCollectionConfigurationType>;
185 changes: 95 additions & 90 deletions src/configuration/formatting-evaluator-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,95 +7,100 @@ const type = Type.Union(
)
);

export const formattingEvaluatorConfigurationType = Type.Object({
/**
* Multipliers applied to different parts of the comment body content
*/
multipliers: Type.Array(
Type.Object({
select: Type.Array(type),
formattingMultiplier: Type.Number(),
wordValue: Type.Number(),
}),
{
default: [
{
select: ["ISSUE_SPECIFICATION"],
formattingMultiplier: 1,
wordValue: 0.1,
},
{
select: ["ISSUE_AUTHOR"],
formattingMultiplier: 1,
wordValue: 0.2,
},
{
select: ["ISSUE_ASSIGNEE"],
formattingMultiplier: 0,
wordValue: 0,
},
{
select: ["ISSUE_COLLABORATOR"],
formattingMultiplier: 1,
wordValue: 0.1,
},
{
select: ["ISSUE_CONTRIBUTOR"],
formattingMultiplier: 0.25,
wordValue: 0.1,
},
{
select: ["PULL_SPECIFICATION"],
formattingMultiplier: 0,
wordValue: 0,
},
{
select: ["PULL_AUTHOR"],
formattingMultiplier: 2,
wordValue: 0.2,
},
{
select: ["PULL_ASSIGNEE"],
formattingMultiplier: 1,
wordValue: 0.1,
},
{
select: ["PULL_COLLABORATOR"],
formattingMultiplier: 1,
wordValue: 0.1,
},
{
select: ["PULL_CONTRIBUTOR"],
formattingMultiplier: 0.25,
wordValue: 0.1,
},
],
}
),
/**
* Attributed score per HTML entity
*/
scores: Type.Record(Type.String(), Type.Number(), {
default: {
br: 0,
code: 1,
p: 1,
em: 0,
img: 0,
strong: 0,
blockquote: 0,
h1: 1,
h2: 1,
h3: 1,
h4: 1,
h5: 1,
h6: 1,
a: 1,
li: 1,
td: 1,
hr: 0,
},
}),
});
const symbolsType = Type.Record(Type.String(), Type.Number(), { minProperties: 1 });

export const formattingEvaluatorConfigurationType = Type.Object(
{
/**
* Multipliers applied to different parts of the comment body content
*/
multipliers: Type.Array(
Type.Object({
select: Type.Array(type),
formattingMultiplier: Type.Number(),
symbols: symbolsType,
/**
* Attributed score per HTML entity
*/
scores: Type.Record(Type.String(), Type.Number(), {
default: {
br: 0,
code: 1,
p: 1,
em: 0,
img: 0,
strong: 0,
blockquote: 0,
h1: 1,
h2: 1,
h3: 1,
h4: 1,
h5: 1,
h6: 1,
a: 1,
li: 1,
td: 1,
hr: 0,
gentlementlegen marked this conversation as resolved.
Show resolved Hide resolved
},
}),
}),
{
default: [
{
select: ["ISSUE_SPECIFICATION"],
formattingMultiplier: 1,
symbols: { "\\b\\w+\\b": 0.1 },
gentlementlegen marked this conversation as resolved.
Show resolved Hide resolved
},
{
select: ["ISSUE_AUTHOR"],
formattingMultiplier: 1,
symbols: { "\\b\\w+\\b": 0.2 },
},
{
select: ["ISSUE_ASSIGNEE"],
formattingMultiplier: 0,
symbols: { "\\b\\w+\\b": 0 },
},
{
select: ["ISSUE_COLLABORATOR"],
formattingMultiplier: 1,
symbols: { "\\b\\w+\\b": 0.1 },
},
{
select: ["ISSUE_CONTRIBUTOR"],
formattingMultiplier: 0.25,
symbols: { "\\b\\w+\\b": 0.1 },
},
{
select: ["PULL_SPECIFICATION"],
formattingMultiplier: 0,
symbols: { "\\b\\w+\\b": 0 },
},
{
select: ["PULL_AUTHOR"],
formattingMultiplier: 2,
symbols: { "\\b\\w+\\b": 0.2 },
},
{
select: ["PULL_ASSIGNEE"],
formattingMultiplier: 1,
symbols: { "\\b\\w+\\b": 0.1 },
},
{
select: ["PULL_COLLABORATOR"],
formattingMultiplier: 1,
symbols: { "\\b\\w+\\b": 0.1 },
},
{
select: ["PULL_CONTRIBUTOR"],
formattingMultiplier: 0.25,
symbols: { "\\b\\w+\\b": 0.1 },
},
],
}
),
},
{ default: {} }
);

export type FormattingEvaluatorConfiguration = Static<typeof formattingEvaluatorConfigurationType>;
23 changes: 13 additions & 10 deletions src/configuration/github-comment-config.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { Static, Type } from "@sinclair/typebox";

export const githubCommentConfigurationType = Type.Object({
/**
* Enables posting to the related GitHub Issue
*/
post: Type.Boolean({ default: true }),
/**
* Enables debug by creating a local html file of the rendered comment
*/
debug: Type.Boolean({ default: false }),
});
export const githubCommentConfigurationType = Type.Object(
{
/**
* Enables posting to the related GitHub Issue
*/
post: Type.Boolean({ default: true }),
/**
* Enables debug by creating a local html file of the rendered comment
*/
debug: Type.Boolean({ default: false }),
},
{ default: {} }
);

export type GithubCommentConfiguration = Static<typeof githubCommentConfigurationType>;
60 changes: 33 additions & 27 deletions src/configuration/incentives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,43 @@ import { githubCommentConfigurationType } from "./github-comment-config";
import { permitGenerationConfigurationType } from "./permit-generation-configuration";
import { userExtractorConfigurationType } from "./user-extractor-config";

export const incentivesConfigurationSchema = T.Object({
/**
* Network ID to run in, default to 100
*/
evmNetworkId: T.Number({ default: 100 }),
/**
* The encrypted key to use for permit generation
*/
evmPrivateEncrypted: T.String(),
/**
* Reward token for ERC20 permits, default WXDAI for gnosis chain
*/
erc20RewardToken: T.String({ default: "0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d" }),
incentives: T.Object({
export const incentivesConfigurationSchema = T.Object(
{
/**
* Optionally specify a file to write the results in
* Network ID to run in, default to 100
*/
file: T.Optional(T.String()),
evmNetworkId: T.Number({ default: 100 }),
/**
* If set to true, the plugin runs even if the price label is missing, and will evaluate comments.
* The encrypted key to use for permit generation
*/
requirePriceLabel: T.Boolean({ default: true }),
contentEvaluator: T.Optional(T.Union([contentEvaluatorConfigurationType, T.Null()])),
userExtractor: T.Optional(T.Union([userExtractorConfigurationType, T.Null()])),
dataPurge: T.Optional(T.Union([dataPurgeConfigurationType, T.Null()])),
formattingEvaluator: T.Optional(T.Union([formattingEvaluatorConfigurationType, T.Null()])),
permitGeneration: T.Optional(T.Union([permitGenerationConfigurationType, T.Null()])),
githubComment: T.Optional(T.Union([githubCommentConfigurationType, T.Null()])),
}),
dataCollection: dataCollectionConfigurationType,
});
evmPrivateEncrypted: T.String(),
/**
* Reward token for ERC20 permits, default WXDAI for gnosis chain
*/
erc20RewardToken: T.String({ default: "0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d" }),
incentives: T.Object(
{
/**
* Optionally specify a file to write the results in
*/
file: T.Optional(T.String()),
/**
* If set to true, the plugin runs even if the price label is missing, and will evaluate comments.
gentlementlegen marked this conversation as resolved.
Show resolved Hide resolved
*/
requirePriceLabel: T.Boolean({ default: true }),
contentEvaluator: T.Optional(T.Union([contentEvaluatorConfigurationType, T.Null()])),
userExtractor: T.Optional(T.Union([userExtractorConfigurationType, T.Null()])),
dataPurge: T.Optional(T.Union([dataPurgeConfigurationType, T.Null()])),
formattingEvaluator: formattingEvaluatorConfigurationType,
permitGeneration: T.Optional(T.Union([permitGenerationConfigurationType, T.Null()])),
githubComment: githubCommentConfigurationType,
},
{ default: {} }
),
dataCollection: dataCollectionConfigurationType,
},
{ default: {} }
);

export const validateIncentivesConfiguration = new StandardValidator(incentivesConfigurationSchema);

Expand Down
Loading
Loading