Compare commits

..

2 Commits

Author SHA1 Message Date
bel
902ab96b2d wip pattern 2024-04-14 15:40:49 -06:00
bel
60017a8d3a a select 2024-04-14 10:22:43 -06:00
4 changed files with 32 additions and 15 deletions

View File

@@ -27,6 +27,7 @@ type Config struct {
LocalTokenizer string
AssetPattern string
DatacenterPattern string
EventNamePattern string
storage Storage
queue Queue
driver Driver
@@ -43,6 +44,7 @@ func newConfigFromEnv(ctx context.Context, getEnv func(string) string) (Config,
OllamaModel: "gemma:2b",
AssetPattern: `(dpg|svc|red)-[a-z0-9-]*`,
DatacenterPattern: `[a-z]{4}[a-z]*-[0-9]`,
EventNamePattern: `(^\[[^\]]*\] *)`,
}
var m map[string]any

View File

@@ -107,9 +107,10 @@ type (
slackAction struct{}
)
func ParseSlack(b []byte, assetPattern, datacenterPattern string) (Message, error) {
func ParseSlack(b []byte, assetPattern, datacenterPattern, eventNamePattern string) (Message, error) {
asset := regexp.MustCompile(assetPattern)
datacenter := regexp.MustCompile(datacenterPattern)
eventName := regexp.MustCompile(eventNamePattern)
s, err := parseSlack(b)
if err != nil {
@@ -134,7 +135,7 @@ func ParseSlack(b []byte, assetPattern, datacenterPattern string) (Message, erro
Source: fmt.Sprintf(`https://renderinc.slack.com/archives/%s/p%s`, s.Event.Channel, strings.ReplaceAll(s.Event.ID, ".", "")),
Channel: s.Event.Channel,
Thread: s.Event.ID,
EventName: strings.Split(s.Event.Attachments[0].Title, ": Firing: ")[1],
EventName: eventNamePattern.FindString(strings.Split(s.Event.Attachments[0].Title, ": Firing: ")[1]),
Event: strings.TrimPrefix(strings.Split(s.Event.Attachments[0].Title, ":")[0], "#"),
Plaintext: s.Event.Attachments[0].Text,
Asset: asset.FindString(s.Event.Attachments[0].Text),

View File

@@ -20,19 +20,20 @@
allMessages.map((message) => {
Object.keys(fieldsToOptions).map((field) => {fieldsToOptions[field][message[field]] = true});
});
Object.keys(fieldsToOptions).map((field) => {fieldsToOptions[field] = Object.keys(fieldsToOptions[field])});
Object.keys(fieldsToOptions).map((field) => {fieldsToOptions[field] = Object.keys(fieldsToOptions[field]); fieldsToOptions[field].sort();});
document.getElementById("form").innerHTML = Object.keys(fieldsToOptions).map((field) => {
}).join("");
console.log(fieldsToOptions);
`
<select name="filter1" multiple>
<option selected>a</option>
<option selected>b</option>
return `
<label for="${field}">${field}</label>
<select name="${field}" multiple ${fieldsToOptions[field].length > 10 ? "size=10" : `size=${fieldsToOptions[field].length}`}>
${fieldsToOptions[field].map((option) => `
<option selected>${option}</option>
`)}
</select>
`
}).join("\n");
}
function drawAll() {
const messages = filterMessages(allMessages)
drawEventVolumeByName(messages)
@@ -40,11 +41,20 @@
drawEventVolumeByHour(messages)
drawEventVolumeByAsset(messages)
}
function filterMessages(messages) {
const filters = document.getElementById("form");
console.log(filters);
return messages.map(() => {
});
}
function drawEventVolumeByName() {}
function drawEventVolumeByWeekday() {}
function drawEventVolumeByHour() {}
function drawEventVolumeByAsset() {}
</script>
<style>
@@ -61,10 +71,14 @@
rows, columns { border: 1px solid red; }
</style>
</head>
<body onload="fillForm()">
<body onload="fillForm(); drawAll();">
<h1>Report</h1>
<columns>
<form id="form" style="width: 10em; flex-shrink: 0;" onchange="drawAll()">
<form style="width: 16em; flex-shrink: 0;" onsubmit="drawAll(); return false;">
<columns>
<button type="submit">Apply</button>
</columns>
<rows id="form"></rows>
</form>
<rows>
<rows>

View File

@@ -16,7 +16,7 @@ func TestReport(t *testing.T) {
w := bytes.NewBuffer(nil)
db := NewRAM()
FillWithTestdata(ctx, db, renderAssetPattern, renderDatacenterPattern)
FillWithTestdata(ctx, db, renderAssetPattern, renderDatacenterPattern, renderEventNamePattern)
s := NewStorage(db)
if err := ReportSince(ctx, w, s, time.Now().Add(-1*time.Hour*24*365*20)); err != nil {