Skip to content

Commit ab0b683

Browse files
authored
Merge pull request #43 from goldenrecursion/sc-19726
Sc 19726
2 parents 26b9482 + 34f1ca9 commit ab0b683

File tree

10 files changed

+294
-76
lines changed

10 files changed

+294
-76
lines changed

src/godel/api.py

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from godel.queries.CreateEntity import Operations as CreateEntityOperations
2626
from godel.queries.CreateValidation import Operations as CreateValidationOperations
2727
from godel.queries.CreateStatement import Operations as CreateStatementOperations
28+
from godel.queries.CreateTripleFlag import Operations as CreateTripleFlagOperations
2829

2930
# from godel.queries.CurrentUserBlockchainData import Operations as CurrentUserBlockchainDataOperations
3031
from godel.queries.CurrentUserValidations import (
@@ -705,6 +706,15 @@ def create_statement(
705706
# Validation Submissions
706707

707708
def create_validation(self, triple_id: str, validation_type: str, **kwargs) -> dict:
709+
"""Create verification vote
710+
711+
Args:
712+
triple_id (str): Your triple id
713+
validation_type (str): Verfication type "ACCEPTED", "REJECTED", "SKIPPED"
714+
715+
Returns:
716+
dict: created verification task
717+
"""
708718
x_metrics = json.loads(self.headers.get("X-metrics"))
709719
x_metrics.update({"cv": time.time()})
710720
if x_metrics.get("uv"):
@@ -723,22 +733,29 @@ def create_validation(self, triple_id: str, validation_type: str, **kwargs) -> d
723733
# Create Triple Flag
724734

725735
def create_triple_flag(
726-
self, triple_id: str, flag: str, reason: str, **kwargs
736+
self, create_triple_flag_input: schema.CreateTripleFlagInput, **kwargs
727737
) -> dict:
728-
query = f"""mutation MyMutation {{
729-
createTripleFlag(
730-
input: {{
731-
tripleId: "{triple_id}"
732-
flag: {flag}
733-
reason: "{reason}"
734-
}}
735-
) {{
736-
clientMutationId
737-
}}
738-
}}"""
739-
print(query)
740-
variables = {}
741-
data = self.endpoint(query, variables)
738+
"""Create triple flag given the triple flag inputs consisting of triple_id and your flag
739+
740+
Args:
741+
create_triple_flag_input (schema.CreateTripleFlagInput): Triple flag input
742+
743+
Returns:
744+
dict: created triple flag
745+
"""
746+
# Special case for parsing input
747+
variables = create_triple_flag_input.__to_json_value__()
748+
for p, v in variables.items():
749+
p = self.to_camel_case(p)
750+
if p in variables:
751+
variables[p] = v
752+
753+
params = locals()
754+
params.pop("kwargs")
755+
params.pop("self")
756+
params.update(kwargs)
757+
op = CreateTripleFlagOperations.mutation.create_triple_flag
758+
data = self.endpoint(op, variables)
742759
return data
743760

744761
def add_triple_to_entity(

src/godel/fragments/EntityDetail.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def fragment_entity_detail():
2121
_frag_is_a_nodes = _frag_is_a.nodes()
2222
_frag_is_a_nodes.id()
2323
_frag_is_a_nodes.name()
24-
_frag_statements_by_subject_id = _frag.statements_by_subject_id()
24+
_frag_statements_by_subject_id = _frag.statements_by_subject_id(condition={'validationStatusIn': ('ACCEPTED', 'PENDING')})
2525
_frag_statements_by_subject_id_nodes = _frag_statements_by_subject_id.nodes()
2626
_frag_statements_by_subject_id_nodes.__fragment__(fragment_triple_widget())
2727
return _frag
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import sgqlc.types
2+
import sgqlc.operation
3+
import godel.schema
4+
5+
_schema = godel.schema
6+
_schema_root = _schema.schema
7+
8+
__all__ = ('Operations',)
9+
10+
11+
def mutation_create_triple_flag():
12+
_op = sgqlc.operation.Operation(_schema_root.mutation_type, name='CreateTripleFlag', variables=dict(tripleId=sgqlc.types.Arg(sgqlc.types.non_null(_schema.UUID)), flag=sgqlc.types.Arg(sgqlc.types.non_null(_schema.TripleFlagType))))
13+
_op_create_triple_flag = _op.create_triple_flag(input={'tripleId': sgqlc.types.Variable('tripleId'), 'flag': sgqlc.types.Variable('flag')})
14+
_op_create_triple_flag.client_mutation_id()
15+
return _op
16+
17+
18+
class Mutation:
19+
create_triple_flag = mutation_create_triple_flag()
20+
21+
22+
class Operations:
23+
mutation = Mutation

src/godel/queries/CurrentUserContributions.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,23 @@
99

1010

1111
def query_current_user_contributions():
12-
_op = sgqlc.operation.Operation(_schema_root.query_type, name='CurrentUserContributions', variables=dict(first=sgqlc.types.Arg(_schema.Int, default=20), after=sgqlc.types.Arg(_schema.Cursor, default=None), condition=sgqlc.types.Arg(sgqlc.types.non_null(_schema.TripleCondition))))
12+
_op = sgqlc.operation.Operation(_schema_root.query_type, name='CurrentUserContributions', variables=dict(first=sgqlc.types.Arg(_schema.Int, default=20), after=sgqlc.types.Arg(_schema.Cursor, default=None), condition=sgqlc.types.Arg(sgqlc.types.non_null(_schema.StatementCondition))))
1313
_op_current_user = _op.current_user()
1414
_op_current_user_contributions_stats = _op_current_user.contributions_stats()
1515
_op_current_user_contributions_stats.accuracy()
1616
_op_current_user_contributions_stats.agreed_with_consensus_count()
1717
_op_current_user_contributions_stats.disagreed_with_consensus_count()
1818
_op_current_user_contributions_stats.pending_count()
19-
_op_triples = _op.triples(order_by='DATE_CREATED_DESC', after=sgqlc.types.Variable('after'), first=sgqlc.types.Variable('first'), condition=sgqlc.types.Variable('condition'))
20-
_op_triples.total_count()
21-
_op_triples_page_info = _op_triples.page_info()
22-
_op_triples_page_info.end_cursor()
23-
_op_triples_page_info.has_previous_page()
24-
_op_triples_page_info.has_next_page()
25-
_op_triples_edges = _op_triples.edges()
26-
_op_triples_edges.cursor()
27-
_op_triples_edges_node = _op_triples_edges.node()
28-
_op_triples_edges_node.__fragment__(fragment_triple_widget())
19+
_op_statements = _op.statements(order_by='DATE_CREATED_DESC', after=sgqlc.types.Variable('after'), first=sgqlc.types.Variable('first'), condition=sgqlc.types.Variable('condition'))
20+
_op_statements.total_count()
21+
_op_statements_page_info = _op_statements.page_info()
22+
_op_statements_page_info.end_cursor()
23+
_op_statements_page_info.has_previous_page()
24+
_op_statements_page_info.has_next_page()
25+
_op_statements_edges = _op_statements.edges()
26+
_op_statements_edges.cursor()
27+
_op_statements_edges_node = _op_statements_edges.node()
28+
_op_statements_edges_node.__fragment__(fragment_triple_widget())
2929
return _op
3030

3131

src/godel/queries/EntityContributors.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,3 @@
66
_schema_root = _schema.schema
77

88
__all__ = ('Operations',)
9-
10-
11-
def query_entity_contributors():
12-
_op = sgqlc.operation.Operation(_schema_root.query_type, name='EntityContributors', variables=dict(id=sgqlc.types.Arg(sgqlc.types.non_null(_schema.UUID)), after=sgqlc.types.Arg(_schema.Cursor, default=None)))
13-
_op_entity = _op.entity(id=sgqlc.types.Variable('id'))
14-
_op_entity.id()
15-
_op_entity_nft_requests = _op_entity.nft_requests(first=5, after=sgqlc.types.Variable('after'))
16-
_op_entity_nft_requests_page_info = _op_entity_nft_requests.page_info()
17-
_op_entity_nft_requests_page_info.has_next_page()
18-
_op_entity_nft_requests_page_info.end_cursor()
19-
_op_entity_nft_requests_nodes = _op_entity_nft_requests.nodes()
20-
_op_entity_nft_requests_nodes.user_id()
21-
_op_entity_nft_requests_nodes.ledger_record_amount_sum()
22-
_op_entity_nft_requests_nodes.ownership_percent()
23-
return _op
24-
25-
26-
class Query:
27-
entity_contributors = query_entity_contributors()
28-
29-
30-
class Operations:
31-
query = Query

src/godel/queries/EntityDetail.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ def query_entity_detail():
1414
_op = sgqlc.operation.Operation(_schema_root.query_type, name='EntityDetail', variables=dict(id=sgqlc.types.Arg(sgqlc.types.non_null(_schema.UUID))))
1515
_op_entity = _op.entity(id=sgqlc.types.Variable('id'))
1616
_op_entity.__fragment__(fragment_entity_detail())
17+
_op_entity.is_entity_type()
1718
_op_templates = _op.templates(order_by='RANK_ASC')
1819
_op_templates_nodes = _op_templates.nodes()
1920
_op_templates_nodes.entity_id()

src/godel/queries/EntityType.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import sgqlc.types
2+
import sgqlc.operation
3+
import godel.schema
4+
5+
_schema = godel.schema
6+
_schema_root = _schema.schema
7+
8+
__all__ = ('Operations',)
9+
10+
11+
def query_entity_type():
12+
_op = sgqlc.operation.Operation(_schema_root.query_type, name='EntityType', variables=dict(id=sgqlc.types.Arg(sgqlc.types.non_null(_schema.UUID))))
13+
_op_entity = _op.entity(id=sgqlc.types.Variable('id'))
14+
_op_entity.id()
15+
_op_entity.name()
16+
_op_entity.is_entity_type()
17+
return _op
18+
19+
20+
class Query:
21+
entity_type = query_entity_type()
22+
23+
24+
class Operations:
25+
query = Query

src/godel/queries/LiveView.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,15 @@
1010

1111

1212
def query_live_view():
13-
_op = sgqlc.operation.Operation(_schema_root.query_type, name='LiveView')
14-
_op_triples = _op.triples(first=20, condition={'validationStatus': 'ACCEPTED'}, order_by='DATE_ACCEPTED_DESC')
15-
_op_triples_nodes = _op_triples.nodes()
16-
_op_triples_nodes.__fragment__(fragment_triple_widget())
13+
_op = sgqlc.operation.Operation(_schema_root.query_type, name='LiveView', variables=dict(first=sgqlc.types.Arg(_schema.Int, default=20), after=sgqlc.types.Arg(_schema.Cursor, default=None), condition=sgqlc.types.Arg(_schema.TripleCondition), orderBy=sgqlc.types.Arg(sgqlc.types.list_of(sgqlc.types.non_null(_schema.TriplesOrderBy)), default=('DATE_ACCEPTED_DESC',))))
14+
_op_triples = _op.triples(first=sgqlc.types.Variable('first'), after=sgqlc.types.Variable('after'), condition=sgqlc.types.Variable('condition'), order_by=sgqlc.types.Variable('orderBy'))
15+
_op_triples_page_info = _op_triples.page_info()
16+
_op_triples_page_info.end_cursor()
17+
_op_triples_page_info.has_previous_page()
18+
_op_triples_page_info.has_next_page()
19+
_op_triples_edges = _op_triples.edges()
20+
_op_triples_edges_node = _op_triples_edges.node()
21+
_op_triples_edges_node.__fragment__(fragment_triple_widget())
1722
return _op
1823

1924

0 commit comments

Comments
 (0)