Skip to content

Commit 4b31526

Browse files
Nolan Alexander Jimenezfacebook-github-bot
authored andcommitted
Codes field added to issue_instance model
Summary: Matching output for IssueResults, codes added as field in issue_instance model and obtained by querying issue table Reviewed By: sinancepel Differential Revision: D22743967 fbshipit-source-id: ff2e7bcf84e059e660c4cb205da09db7fe4fb6fc
1 parent dd04685 commit 4b31526

File tree

4 files changed

+57
-46
lines changed

4 files changed

+57
-46
lines changed

tools/sapp/sapp/frontend/src/App.js

Lines changed: 39 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -17,57 +17,53 @@ const client = new ApolloClient({
1717
function IssueInstances() {
1818
const {loading, error, data} = useQuery(gql`
1919
{
20-
issueInstances {
21-
location
22-
filenameId
23-
filename
24-
callableId
25-
isNewIssue
26-
runId
27-
issueId
28-
messageId
29-
minTraceLengthToSources
30-
minTraceLengthToSinks
31-
minTraceLengthToEntrypoints
32-
rank
33-
callableCount
20+
issueInstances{
21+
edges {
22+
node {
23+
location
24+
filenameId
25+
filename {
26+
contents
27+
}
28+
callableId
29+
isNewIssue
30+
runId
31+
issueId
32+
messageId
33+
minTraceLengthToSources
34+
minTraceLengthToSinks
35+
rank
36+
callableCount
37+
minTraceLengthToEntrypoints
38+
issue {
39+
code
40+
}
41+
}
42+
}
3443
}
3544
}
3645
`);
3746

3847
if (loading) return <p>Loading...</p>;
3948
if (error) return <p>Error :(</p>;
4049

41-
return data.issueInstances.map(
42-
({
43-
location,
44-
filenameId,
45-
filename,
46-
callableId,
47-
isNewIssue,
48-
runId,
49-
issueId,
50-
messageId,
51-
minTraceLengthToSources,
52-
minTraceLengthToSinks,
53-
rank,
54-
callableCount,
55-
minTraceLengthToEntrypoints,
56-
}) => (
50+
return data.issueInstances.edges.map(
51+
({node}) => (
5752
<IssueInstance
58-
location={location}
59-
filenameId={filenameId}
60-
filename={filename}
61-
callableId={callableId}
62-
isNewIssue={isNewIssue}
63-
runId={runId}
64-
issueId={issueId}
65-
messageId={issueId}
66-
minTraceLengthToSources={minTraceLengthToSources}
67-
minTraceLengthToSinks={minTraceLengthToSinks}
68-
rank={rank}
69-
callableCount={callableCount}
70-
minTraceLengthToEntrypoints={minTraceLengthToEntrypoints}
53+
location={node.location}
54+
filenameId={node.filenameId}
55+
filename={node.filename.contents}
56+
code={node.issue.code}
57+
callableId={node.callableId}
58+
isNewIssue={node.isNewIssue}
59+
runId={node.runId}
60+
issueId={node.issueId}
61+
messageId={node.issueId}
62+
minTraceLengthToSources={node.minTraceLengthToSources}
63+
minTraceLengthToSinks={node.minTraceLengthToSinks}
64+
rank={node.rank}
65+
callableCount={node.callableCount}
66+
minTraceLengthToEntrypoints={node.minTraceLengthToEntrypoints}
7167
/>
7268
),
7369
);

tools/sapp/sapp/frontend/src/IssueInstance.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class IssueInstance extends React.Component {
88
<p>Location: {this.props.location}</p>
99
<p>File: {this.props.filename}</p>
1010
<p>Filename Id: {this.props.filenameId}</p>
11+
<p>Code: {this.props.code}</p>
1112
<p>Callable Id: {this.props.callableId}</p>
1213
<p>Callable Count: {this.props.callableCount}</p>
1314
<p>isNewIssue: {this.props.isNewIssue}</p>

tools/sapp/sapp/models.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ def merge(cls, session, items):
337337
)
338338

339339
@classmethod
340-
def generateSQLAlchemyObject(cls):
340+
def generateSQLAlchemyObject(cls) -> Type[SQLAlchemyObjectType]:
341341
class SharedTextType(SQLAlchemyObjectType):
342342
class Meta:
343343
model = cls
@@ -536,7 +536,7 @@ def merge(cls, session, items):
536536
yield i
537537

538538
@classmethod
539-
def generateSQLAlchemyObject(cls):
539+
def generateSQLAlchemyObject(cls) -> Type[SQLAlchemyObjectType]:
540540
class IssueInstanceType(SQLAlchemyObjectType):
541541
class Meta:
542542
model = cls
@@ -658,6 +658,15 @@ def _take(cls, n, iterable):
658658
def merge(cls, session, issues):
659659
return cls._merge_by_key(session, issues, cls.handle)
660660

661+
@classmethod
662+
def generateSQLAlchemyObject(cls) -> Type[SQLAlchemyObjectType]:
663+
class IssueType(SQLAlchemyObjectType):
664+
class Meta:
665+
model = cls
666+
interfaces = (relay.Node,)
667+
668+
return IssueType
669+
661670

662671
class RunStatus(enum.Enum):
663672
# Do NOT reorder the enums. Depending on the type of database, existing

tools/sapp/sapp/schema.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
import graphene
66
from graphene import relay
77

8-
from .models import IssueInstance, SharedText
8+
from .models import Issue, IssueInstance, SharedText
9+
10+
11+
if TYPE_CHECKING:
12+
from graphql.execution.base import ResolveInfo
913

1014

1115
if TYPE_CHECKING:
@@ -14,6 +18,7 @@
1418

1519
SharedTextType = SharedText.generateSQLAlchemyObject()
1620
IssueInstanceType = IssueInstance.generateSQLAlchemyObject()
21+
IssueType = Issue.generateSQLAlchemyObject()
1722

1823

1924
class IssueConnection(relay.Connection):

0 commit comments

Comments
 (0)