parent
ba8656eb9f
commit
b899f46386
|
@ -1,5 +1,9 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
# 0.20.1
|
||||||
|
|
||||||
|
* Allow filtering by software
|
||||||
|
|
||||||
# 0.20.0
|
# 0.20.0
|
||||||
|
|
||||||
* Added batching for adding/removing/modifying censures
|
* Added batching for adding/removing/modifying censures
|
||||||
|
|
|
@ -12,6 +12,7 @@ class Whitelist(Resource):
|
||||||
get_parser.add_argument("endorsements", required=False, default=0, type=int, help="Limit to this amount of endorsements of more", location="args")
|
get_parser.add_argument("endorsements", required=False, default=0, type=int, help="Limit to this amount of endorsements of more", location="args")
|
||||||
get_parser.add_argument("guarantors", required=False, default=1, type=int, help="Limit to this amount of guarantors of more", location="args")
|
get_parser.add_argument("guarantors", required=False, default=1, type=int, help="Limit to this amount of guarantors of more", location="args")
|
||||||
get_parser.add_argument("tags_csv", required=False, type=str, help="A list of tags to filter.", location="args")
|
get_parser.add_argument("tags_csv", required=False, type=str, help="A list of tags to filter.", location="args")
|
||||||
|
get_parser.add_argument("software_csv", required=False, type=str, help="show only instances running one of this software", location="args")
|
||||||
get_parser.add_argument("page", required=False, type=int, default=1, help="Which page of results to retrieve", location="args")
|
get_parser.add_argument("page", required=False, type=int, default=1, help="Which page of results to retrieve", location="args")
|
||||||
get_parser.add_argument("limit", required=False, type=int, default=100, help="Which page of results to retrieve", location="args")
|
get_parser.add_argument("limit", required=False, type=int, default=100, help="Which page of results to retrieve", location="args")
|
||||||
get_parser.add_argument("csv", required=False, type=bool, help="Set to true to return just the domains as a csv. Mutually exclusive with domains", location="args")
|
get_parser.add_argument("csv", required=False, type=bool, help="Set to true to return just the domains as a csv. Mutually exclusive with domains", location="args")
|
||||||
|
@ -31,11 +32,15 @@ class Whitelist(Resource):
|
||||||
tags = None
|
tags = None
|
||||||
if self.args.tags_csv is not None:
|
if self.args.tags_csv is not None:
|
||||||
tags = [t.strip() for t in self.args.tags_csv.split(',')]
|
tags = [t.strip() for t in self.args.tags_csv.split(',')]
|
||||||
|
software = None
|
||||||
|
if self.args.software_csv is not None:
|
||||||
|
software = [s.strip() for s in self.args.software_csv.split(',')]
|
||||||
instance_details = []
|
instance_details = []
|
||||||
for instance in database.get_all_instances(
|
for instance in database.get_all_instances(
|
||||||
min_endorsements=self.args.endorsements,
|
min_endorsements=self.args.endorsements,
|
||||||
min_guarantors=self.args.guarantors,
|
min_guarantors=self.args.guarantors,
|
||||||
tags=tags,
|
tags=tags,
|
||||||
|
software=software,
|
||||||
page=self.args.page,
|
page=self.args.page,
|
||||||
limit=self.args.limit,
|
limit=self.args.limit,
|
||||||
):
|
):
|
||||||
|
|
|
@ -13,6 +13,7 @@ def get_all_instances(
|
||||||
min_endorsements = 0,
|
min_endorsements = 0,
|
||||||
min_guarantors = 1,
|
min_guarantors = 1,
|
||||||
tags = None,
|
tags = None,
|
||||||
|
software = None,
|
||||||
include_decommissioned = True,
|
include_decommissioned = True,
|
||||||
page=1,
|
page=1,
|
||||||
limit=10,
|
limit=10,
|
||||||
|
@ -41,6 +42,9 @@ def get_all_instances(
|
||||||
# Convert tags to lowercase and filter instances that have any of the tags
|
# Convert tags to lowercase and filter instances that have any of the tags
|
||||||
lower_tags = [tag.lower() for tag in tags]
|
lower_tags = [tag.lower() for tag in tags]
|
||||||
query = query.filter(Instance.tags.any(func.lower(InstanceTag.tag).in_(lower_tags)))
|
query = query.filter(Instance.tags.any(func.lower(InstanceTag.tag).in_(lower_tags)))
|
||||||
|
if software:
|
||||||
|
lower_sw = [sw.lower() for sw in software]
|
||||||
|
query = query.filter(Instance.software.in_(lower_sw))
|
||||||
page -= 1
|
page -= 1
|
||||||
if page < 0:
|
if page < 0:
|
||||||
page = 0
|
page = 0
|
||||||
|
|
|
@ -235,7 +235,7 @@ class InstanceInfo():
|
||||||
if "*" in self.domain:
|
if "*" in self.domain:
|
||||||
self.software = "wildcard"
|
self.software = "wildcard"
|
||||||
else:
|
else:
|
||||||
self.software = self.node_info["software"]["name"]
|
self.software = self.node_info["software"]["name"].lower()
|
||||||
software_map = {
|
software_map = {
|
||||||
"lemmy": self.get_lemmy_info,
|
"lemmy": self.get_lemmy_info,
|
||||||
"mastodon": self.get_mastodon_info,
|
"mastodon": self.get_mastodon_info,
|
||||||
|
|
Loading…
Reference in New Issue