2018-03-08 21:54:29 -06:00
|
|
|
from dateutil.parser import parse as date_parse
|
|
|
|
from metrics import timestamp
|
|
|
|
import requests
|
2022-02-18 10:16:17 +01:00
|
|
|
from urllib.parse import urljoin
|
2019-05-02 20:34:21 +02:00
|
|
|
|
2018-03-08 21:54:29 -06:00
|
|
|
import yaml
|
|
|
|
|
|
|
|
BASEURL = 'http://review.tumbleweed.boombatower.com/data/'
|
|
|
|
|
2022-02-18 17:15:48 +01:00
|
|
|
|
2018-03-08 21:54:29 -06:00
|
|
|
def data_load(name):
|
2024-05-07 17:55:17 +02:00
|
|
|
response = requests.get(urljoin(BASEURL, f'{name}.yaml'))
|
2018-03-08 21:54:29 -06:00
|
|
|
return yaml.safe_load(response.text)
|
|
|
|
|
2022-02-18 17:15:48 +01:00
|
|
|
|
2018-03-08 21:54:29 -06:00
|
|
|
def data_write(client, measurement, points):
|
|
|
|
client.drop_measurement(measurement)
|
|
|
|
client.write_points(points, 's')
|
|
|
|
|
2022-02-18 17:15:48 +01:00
|
|
|
|
2018-03-08 21:54:29 -06:00
|
|
|
def ingest_data(client, name):
|
|
|
|
data = data_load(name)
|
|
|
|
|
2024-05-07 17:55:17 +02:00
|
|
|
measurement = f'release_{name}'
|
|
|
|
map_func = globals()[f'map_{name}']
|
2018-03-08 21:54:29 -06:00
|
|
|
points = []
|
|
|
|
for release, details in data.items():
|
|
|
|
points.append({
|
|
|
|
'measurement': measurement,
|
|
|
|
'fields': map_func(details),
|
|
|
|
'time': timestamp(date_parse(release)),
|
|
|
|
})
|
|
|
|
|
|
|
|
data_write(client, measurement, points)
|
2024-05-07 17:55:17 +02:00
|
|
|
print(f'wrote {len(points)} for {name}')
|
2018-03-08 21:54:29 -06:00
|
|
|
|
2022-02-18 17:15:48 +01:00
|
|
|
|
2018-03-08 21:54:29 -06:00
|
|
|
def map_bug(bugs):
|
|
|
|
return {
|
|
|
|
'bug_count': len(bugs),
|
|
|
|
}
|
|
|
|
|
2022-02-18 17:15:48 +01:00
|
|
|
|
2018-03-08 21:54:29 -06:00
|
|
|
def map_mail(details):
|
|
|
|
return {
|
|
|
|
'reference_count': details['reference_count'],
|
|
|
|
'thread_count': details['thread_count'],
|
|
|
|
}
|
|
|
|
|
2022-02-18 17:15:48 +01:00
|
|
|
|
2018-03-08 21:54:29 -06:00
|
|
|
def map_score(details):
|
|
|
|
return details
|
|
|
|
|
2022-02-18 17:15:48 +01:00
|
|
|
|
2018-03-08 21:54:29 -06:00
|
|
|
def map_snapshot(details):
|
|
|
|
return {
|
|
|
|
'binary_count': details['binary_count'],
|
|
|
|
'binary_unique_count': details['binary_unique_count'],
|
|
|
|
}
|
|
|
|
|
2022-02-18 17:15:48 +01:00
|
|
|
|
2018-03-08 21:54:29 -06:00
|
|
|
def ingest(client):
|
2018-03-09 16:53:43 -06:00
|
|
|
if client._database != 'openSUSE:Factory':
|
|
|
|
print('skipping release ingest for unsupported project')
|
|
|
|
return
|
|
|
|
|
2018-03-08 21:54:29 -06:00
|
|
|
for name in ['bug', 'mail', 'score', 'snapshot']:
|
|
|
|
ingest_data(client, name)
|