Commit Graph

1165 Commits

Author SHA1 Message Date
William Chargin 9319780f38
test: fix `example-github-load` snaphshot test (#1441)
Summary:
Generated with `./scripts/update_snapshots.sh`. This fixes failures
introduced in #1431.

Test Plan:
Running `yarn test --full` now passes. Inspecting the diff shows that
this only includes a compat version number change, which is appropriate.

wchargin-branch: fix-1431-failures
2019-11-11 13:46:51 -08:00
William Chargin c07a3fe208
deps: upgrade `prettier@1.19.1` (#1439)
Summary:
Most changes due to <https://github.com/prettier/prettier/pull/6694>.

Generated with `yarn add prettier@1.19.1 && yarn prettify`.

Test Plan:
Running `yarn test` suffices.

wchargin-branch: prettier-v1.19.1
2019-11-11 12:47:26 -08:00
Robin van Boven 64834c6874 Remove Discourse admin API key and user. (#1431)
This removes all usage of and reference to the admin API key and username. Instead relying on anonymous access of the Discourse API.

This enables anyone to deploy an instance with discourse support, and is much safer, since the admin API key isn't used for this purpose anymore. Once merged I would encourage revoking any admin API keys used in the past.

The only notable remaining reference of the discourse username is in the project file.
Which goes from 0.3.0 to 0.3.1 in a backwards-compatible way here, simply ignoring the username if present. For #1426 I'm expecting a 0.4.0 version, so this is to prevent having to change project files twice.

Test plan: updated the snapshots to their latest anonymous versions. Ran yarn test and anonymous discourse loading from CLI numerous times.
2019-11-07 17:34:00 -08:00
William Chargin ada9140663
Upgrade Flow to v0.111.0 (#1436)
Summary:
The Flow team fixed a lot of bugs related to object spreading recently.
Some of these enable us to simplify our code (`generateGraphqlFlowTypes`
and `mirror`). Some find new genuine errors. Others require suppressions
in place of a larger change.

Test Plan:
Running `yarn flow` now passes.

wchargin-branch: upgrade-flow-v0.111.0
2019-11-01 19:55:07 -07:00
Dandelion Mané d47e6e28c0
legacy UI defaults to showing all users (#1430)
This is basically a backport of #1371 to the legacy UI.

Test plan: Manual inspection verifies it's doing the right thing. `yarn
test` passes.

Part of https://discourse.sourcecred.io/t/fixup-legacy-explorer/316
2019-10-28 23:55:53 -06:00
Dandelion Mané dfc7ee8524
Show all plugins' types in legacy ui (#1429)
This commit upgrades the legacy explorer to now properly include types
from all loaded plugins, rather than just the GitHub plugin. This makes
the legacy UI much more usable for inspecting SourceCred's own
(multi-plugin) cred.

Test plan: Manual inspection of the frontend. `yarn test` passes.

Part of https://discourse.sourcecred.io/t/fixup-legacy-explorer/316
2019-10-28 23:51:33 -06:00
Dandelion Mané 3754cafb7d
legacy app state includes TimelineCred (#1428)
By keeping the TimelineCred in state instead of the Graph, we can access
the plugin information (and potentially other config) from TimelineCred.
Note that the legacy app does still use old-style cred calculation (no
time weighting).

Test plan: `yarn test`. It's just a refactor.

Part of https://discourse.sourcecred.io/t/fixup-legacy-explorer/316
2019-10-28 23:49:11 -06:00
Dandelion Mané d896f73329
Discourse plugin now properly detects mentions (#1424)
As suggested in #1420, heretofore the Discourse plugin wasn't actually
picking up mentions. The issue is that the (thoroughly tested) mention
detection logic assumed that mention urls took the form
`$SERVERURL/u/$USERNAME`, but actually they are encoded as a relative link,
as in `/u/$USERNAME`. As such, the logic was internally consistent but
never detected any actual mentions!

It's a good case study in the need for integration tests and not just
unit tests. I've updaded the code so we do have a proper integration
test: references.test.js validates that a topic reference, post
reference, and user mention are all properly detected in the real output
from a Discoures topic.

Test plan: `yarn test` passes; inspect updated snapshots and tests.

Fixes #1420.
2019-10-25 15:01:39 -06:00
Dandelion Mané 4e0d884283
discourse: factor out snapshotTestUtil (#1423)
I want to have the reference tests depend on real snapshotted data.
Therefore, I'm factoring out the utilities for interacting with the
snapshot data out of fetch.test.js and into snapshotTestUtil.js

Test plan: `yarn test` still passes.
2019-10-25 14:58:36 -06:00
Dandelion Mané eed115a995
Add to (and update) Discourse snapshots (#1422)
I made a new [test post][1] which has references. The Discourse
snapshots now include it, so we can give a realistic test of reference
and mention detection.

This will allow us to verify whether #1420 is affecting us, and fix it
if so.

Test plan: Commit was generated by running the snapshot updater. Other
snapshots have been updated and look OK. `yarn test` passes.

[1]: https://sourcecred-test.discourse.group/t/a-post-with-references/21
2019-10-24 11:28:16 -06:00
greenkeeper[bot] c560f508b1 Update flow-bin to the latest version 🚀 (#1421)
* chore(package): update flow-bin to version 0.110.0

* chore(package): update lockfile yarn.lock
2019-10-22 12:05:50 -06:00
William Chargin 01bdb2e94a
mirror: remove unused helper functions (#1351)
Summary:
The functions `isSqlSafe` and `_nontransactionallyFindUnusedTableName`
are unused, because we no longer need to dynamically generate SQL, and
all operations are clearly safe by construction.

Test Plan:
That `yarn flow` passes suffices.

wchargin-branch: mirror-prune-helpers
2019-10-19 18:14:40 -07:00
William Chargin b0b911cec4
mirror: use fixed temp table for transitive deps (#1350)
Summary:
The Mirror module extraction code calculates the set of transitive
dependencies and stores these results in a temporary table to avoid
unnecessary marshalling between JavaScript and C. We originally chose
the temporary table name dynamically, guaranteeing that it was unused.
However, this is unnecessary:

  - The temporary table namespace is unique to each database connection,
    so we need only consider possible conflicts in the same connection.
  - A `Mirror` instance exercises exclusive ownership of its database
    connection, per its constructor docs, so we need only consider
    conflicts within this module.
  - Temporary tables are only used in the `extract` method, so we need
    only consider conflicts in this method.
  - The `extract` method makes no open calls nor recursive calls, and
    does not yield control back to the event loop, so only one stack
    frame can be in `extract` at any time.
  - The `extract` method itself only creates the temporary table once.

Thus, the temporary table creation is safe. Furthermore, the failure
mode is simply that we raise an exception and fail cleanly; there is no
risk of data loss or corruption.

This patch replaces the dynamically generated table name with a fixed
name. On top of the work in #1313, this removes the last instance of SQL
queries that are not compile-time constant expressions.

Test Plan:
Running `yarn unit -f graphql/mirror` suffices.

wchargin-branch: mirror-fixed-temp-table
2019-10-19 18:12:59 -07:00
William Chargin ebdd20b576
mirror: clean up references to “EAV” primitives (#1349)
Summary:
The migration is complete; only EAV primitives remain, so they shall be
called simply “primitives”. See #1313 and adjacent commits for context.

Test Plan:
Running `git grep -iw eav` no longer returns any results.

wchargin-branch: mirror-eav-prune-names
2019-10-19 18:09:24 -07:00
William Chargin dbf22cdcfc
mirror: remove primitives test multiplexing logic (#1348)
Summary:
This logic now abstracts over only one implementation, and is no longer
needed.

Test Plan:
That `yarn unit -f graphql/mirror` passes is sufficient.

wchargin-branch: mirror-eav-prune-test-mux
2019-10-19 18:06:20 -07:00
William Chargin 0f52fb4c26
mirror: remove legacy tables (#1347)
Summary:
This data is now stored in EAV `primitives` table; see issue #1313 and
adjacent commits for details.

We simultaneously lift the restriction that GraphQL type and field names
be SQL-safe identifiers, as it’s no longer necessary.

Test Plan:
Some test cases queried the legacy primitives tables to check properties
about the database state. These queries have of course been removed;
note that each such removed query was already accompanied by an
equivalent query against the EAV `primitives` table.

Note that `yarn test --full` still passes, and that when manually
loading `sourcecred/example-github` the cache no longer has any of the
legacy tables.

wchargin-branch: mirror-eav-prune-tables
2019-10-19 18:02:22 -07:00
William Chargin 003efdffa7
mirror: remove legacy non-EAV `extract` (#1346)
Test Plan:
Existing tests suffice, retaining full coverage.

wchargin-branch: mirror-eav-prune-extract
2019-10-19 17:58:17 -07:00
William Chargin f577ae7c1e
identity: forbid underscores in GitHub logins (#1414)
Summary:
GitHub logins may not have underscores, because underscores are not
valid characters in DNS labels. We already have a good-enough regular
expression for validating GitHub usernames; this commit updates the
alias parser to use that.

Discourse usernames are more permissive than what is listed here, but we
leave that unchanged for now.

Test Plan:
Unit tests updated.

wchargin-branch: alias-no-underscore
2019-10-19 09:10:38 -07:00
William Chargin 28b25c2910
identity: require aliases to be anchored (#1413)
Summary:
All the documentation and tests seem to be assuming that aliases must be
anchored: `github/torvalds`, but not `some github/torvalds stuff`.
JavaScript regular expressions aren’t anchored by default; this commit
adds explicit anchoring and adds tests.

Test Plan:
Unit tests added.

wchargin-branch: alias-anchor
2019-10-19 09:06:09 -07:00
Dandelion Mané b2943390dc
add discourse references to the graph (#1410)
This commit modifies `discourse/createGraph` so that it finds all of the
same-server Discourse references in Discourse posts, and creates
appropriately typed references edges in response.

The unit tests have been updated with cases for both references that
should exist, and references that shouldn't (e.g. post index out of
bounds, or a reference to the wrong server).

Test plan: `yarn test --full` along with snapshot update.

This is progress towards [Discourse reference and mention detection][1].

[1]: https://discourse.sourcecred.io/t/discourse-reference-mention-detection/270
2019-10-18 10:56:53 -06:00
Robin van Boven e043347526 Support dashes in alias usernames. (#1412) 2019-10-17 13:21:39 -06:00
Dandelion Mané 78c34b5a36
Parse Discourse references from hyperlinks (#1405)
The `discourse/references` module now has a `linksToReferences` method
which extracts the parsed Discourse references from an array of
hyperlinks. The method is tested.

Test plan: Unit tests added; `yarn test` passes.

This is progress towards [Discourse reference and mention detection][1].

[1]: https://discourse.sourcecred.io/t/discourse-reference-mention-detection/270
2019-10-16 18:39:46 -06:00
greenkeeper[bot] f725f7c47a Update dotenv to the latest version 🚀 (#1411)
* chore(package): update dotenv to version 8.2.0

* chore(package): update lockfile yarn.lock
2019-10-16 16:32:49 -07:00
Robin van Boven 00cc8b2a54 Expand the blacklist, found new type inconsistencies (#1407)
- Bots being Users as a commit author
- Orgs being Users on a reaction

Repositories affected, check represents tested after patch:
- [x] prettier/prettier
- [x] lovell/sharp
- [x] facebook/jest
- [x] babel/babel-eslint
- [x] recharts/recharts
- [x] webpack-contrib/css-loader
- [x] yannickcr/eslint-plugin-react
- [x] vuejs/vuex
- [x] chimurai/http-proxy-middleware
- [x] sass/node-sass
- [x] lodash/lodash
- [x] vuejs/vue
- [x] reacttraining/react-router
- [x] axios/axios
- [x] webpack/webpack-dev-middleware
- [x] eslint/eslint
- [x] webpack/webpack
- [x] webpack/webpack-cli
- [x] sinonjs/sinon
- [x] neutrinojs/webpack-chain
- [x] webpack/webpack-dev-server

Found as part of https://github.com/teamopen-dev/sourcecred-stack-lookup

Test after this patch: pending, it's a lot of data after the cache invalidated 😅
2019-10-15 08:37:24 -07:00
William Chargin 0380088af2
mirror: update implementation notes for EAV tables (#1345)
Summary:
The notes used to focus on the legacy implementation with a minor note
about the EAV implementation; this change flips that relationship.

Test Plan:
None.

wchargin-branch: mirror-eav-impl-notes
2019-10-12 11:36:16 -07:00
William Chargin 809fd23def
mirror: read from EAV tables by default (#1344)
Summary:
This flips the switch for all production `Mirror` reads to use the
single `primitives` EAV table as their source of truth, rather than the
legacy type-specific primitives tables. For context and design
discussion, see issue #1313 and commits adjacent to this one.

Test Plan:
All relevant code paths are already tested (see test plans of commits
adjacent to this one). Running `yarn test --full` passes.

wchargin-branch: mirror-eav-flip
2019-10-12 11:28:55 -07:00
William Chargin e5a77488de
mirror: add EAV reading to `extract`, behind flag (#1343)
Summary:
This completes the end-to-end EAV mode pipeline, but does not yet set it
as default or use it in production.

A note about indentation: we take care to avoid reindenting the entire
block of `extract` test cases, which is over 900 lines long. As to the
implementation code, reindenting the legacy type-specific primitives
branch is not easily avoidable, but when we remove that branch we won’t
have to reindent the EAV mode branch: we can replace its `if` block with
two scope blocks (which is the right thing to do, anyway).

Test Plan:
We reuse existing tests, which suffice for full coverage in both
implementation branches. Note that these tests cover the case of object
types with no primitive fields (the `Feline` and `Socket` types), which
are more likely to fail in a broken EAV implementation than in a broken
type-specific primitives implementation due to deletion anomalies.

To check that all relevant calls to `mirror.extract(…)` have been
properly replaced with `extract(mirror, …)`, run

    yarn coverage -f graphql/mirror -t 'EAV primitives'

and note that the “else” path of the `if (fullOptions.useEavPrimitives)`
branch is not taken; then, run

    yarn coverage -f graphql/mirror -t 'legacy type-specific primitives'

and note that the “if” path of the same branch is not taken.

To check that the table hiding logic is working, invert the branch that
checks `if (fullOptions.useEavPrimitives)`, and note that every test
case using the table hiding logic fails (except for some of the error
handling test cases, which do not actually need to read primitive data).

Finally, `yarn test --full` passes after flipping the `useEavPrimitives`
default to `true`.

wchargin-branch: mirror-eav-extract
2019-10-12 11:23:35 -07:00
Dandelion Mané e1a73ac368
refactor discourse createGraph (#1409)
This is a minor refactor to re-organize the createGraph function in the
Discourse plugin to use a class under the hood. Using a hidden class
makes sense because there is a fair bit of shared state that's needed
while creating the graph.

The proximate cause for this refactor is tha adding reference edges will
bloat the `addPost` section of the function, which was already a little
too complex. Simply shoving in more complexity would make it unweidy. So
I opted for this minor refactor. It's internal-only (no public APIs are
changed).

Test plan: `yarn test` passes. As noted, refactor is internal-only.

This is progress towards [Discourse reference and mention detection][1].

[1]: https://discourse.sourcecred.io/t/discourse-reference-mention-detection/270
2019-10-11 13:46:49 -06:00
Dandelion Mané d4804a7a68
Add edge types for Discourse references (#1406)
Test plan: It's just a declaration change. `yarn flow` passes.

This is progress towards [Discourse reference and mention detection][1].

[1]: https://discourse.sourcecred.io/t/discourse-reference-mention-detection/270
2019-10-11 13:46:35 -06:00
Dandelion Mané eb008f40cc
discourse: factor out address module (#1404)
This will make it possible to depend on addresses in the reference
module.

Test plan: `yarn test` passes.

This is progress towards [Discourse reference and mention detection][1].

[1]: https://discourse.sourcecred.io/t/discourse-reference-mention-detection/270
2019-10-11 13:40:10 -06:00
Dandelion Mané 5e02a2caeb
Add logic for plucking hyperlinks from cooked html (#1403)
This commit adds a `parseLinks` method to a new module,
`plugins/discourse/references`. `parseLinks` allows us to extract the
hyperlinks from `<a>` tags in "cooked" html.

I added `htmlparser2` as a dependency to parse the html. There were a
lot of options to choose from; I chose htmlparser2 because it has a lot
of usage, reasonable performance, and suits our needs. We use this
dependency in a lightweight and local way, so we can always change it
later if needed.

One thing which was a bit odd: I wasn't able to import it using
`import`, and needed a `require` statement instead.

Test plan: Unit tests added; `yarn test` passes.

This is progress towards [Discourse reference and mention detection][1].

[1]: https://discourse.sourcecred.io/t/discourse-reference-mention-detection/270
2019-10-11 13:36:31 -06:00
Dandelion Mané f82c1bfbbe
Add post contents to the Discourse mirror (#1402)
This modifies the Discourse fetcher and mirror so that we now keep post
contents around, thus enabling future reference detection (and other
things). The post contents are stored and provided as retrieved from the
API, which is in "cooked" HTML form.

Test plan: Unit tests and snapshots updated. Observe that the snapshots
now include Discourse post contents.

This is progress towards [Discourse reference and mention detection][1].

[1]: https://discourse.sourcecred.io/t/discourse-reference-mention-detection/270
2019-10-11 13:31:01 -06:00
greenkeeper[bot] 65edd01dcf Update eslint-plugin-react to the latest version 🚀 (#1400)
* chore(package): update eslint-plugin-react to version 7.16.0

* chore(package): update lockfile yarn.lock
2019-10-04 09:22:12 -06:00
greenkeeper[bot] 74e7508f11 chore(package): update dependencies (#1394) 2019-10-03 12:03:25 -06:00
Dandelion Mané 026d3dc705
Upgrade flow to v109 (#1395)
We need one tiny change in test code, where Flow (correctly) detects an
error. I've added an error suppression comment because it is truly a
Flow error, but is appropriate as we are testing an error condition.

Test plan: `yarn test`
2019-10-03 10:41:51 -06:00
Dandelion Mané 1ff13b266e
Fix full build after #1391 (#1393)
In #1391, I updated the default alpha, but forgot to regenerate the load
snapshots. This caused a [nightly build failure][1]. This commit fixes
it.

Test plan: `yarn test --full` passes.

[1]: https://circleci.com/gh/sourcecred/sourcecred/2300
2019-09-30 17:37:04 -06:00
Dandelion Mané 64c17f7dba
Change default alpha to 0.2 (#1391)
SourceCred is currently quite sensitive to inadvertent 'tight loops' in
the cred, where (e.g.) one user recieves cred but doesn't have many out
edges, resulting in a feedback loop where that person gets
disproportinate cred. See [1] and [2] for some examples.

Per a [suggestion] from @mzargham, I'm going to bandaid this issue by
increasing the alpha parameter; I've increased it 4x from 0.05 to 0.2.
Subjectively, I think this improves the cred quality.

[1]: https://discourse.sourcecred.io/t/sneak-peek-sourcecred-discourse-plugin/171
[2]: https://discourse.sourcecred.io/t/preliminary-credsperiment-cred/219
[suggestion]: https://discourse.sourcecred.io/t/preliminary-credsperiment-cred/219/16?u=decentralion
2019-09-30 10:49:25 -06:00
Dandelion Mané 6e2af1070f
Expose alpha in TimelineExplorer (#1390)
This commit modifies the TimelineExplorer so that the user can both see
the chosen alpha value, and change it. Alpha has a pretty profound
impact on the final scores, and I want to tweak it for CredSperiment
week two, so this is an important addition.

Test plan: Modify the alpha, re-run cred calculation, and observe that
the scores change. `yarn test` passes.
2019-09-30 10:33:15 -06:00
Dandelion Mané 54ece536d3
Integrate the identity plugin (#1385)
This commit integrates the identity plugin, which was created in #1384.
It does this by adding explicit identity fields to the project
configuration, which are then applied when loading the graph in
`api/load.js`.

The actual integration is quite straightforward.

Test plan: The underlying logic is thoroughly tested; I added one new
test case to verify that it is integrated properly. Since the project
compat has changed, I've updated all the snapshots. Prior to merging
this PR, I will produce one "integration test", using this code to do
identity resolution for a real project (i.e. on the SourceCred instance
itself).
2019-09-20 12:08:27 +02:00
Dandelion Mané 9a9f211901
Add the identity plugin (#1384)
This commit adds the new SourceCred identity plugin. As described in the
README.md file:

This folder contains the Identity plugin. Unlike most other plugins, the
Identity plugin does not add any new contributions to the graph. Instead, it
allows collapsing different user accounts together into a shared 'identity'
node.

To see why this is valuable, imagine that a contributor has an account on both
GitHub and Discourse (potentially with a different username on each service).
We would like to combine these two identities together, so that we can
represent that user's combined cred properly. The Identity plugin enables this.

Specifically, the instance maintainer can provide a (locally unique) username
for the user, along with a list of aliases the user is known by, e.g.
`github/username` and `discourse/other_username`. The aliases are simple string
representations, that are intended to be easy to maintain by hand in a
configuration file. Then, the identity plugin will provide a list of
`NodeContraction`s that can be used by `Graph.contractNodes` to combine the
user identities as described.

The plugin is broken up into a few submoudles:
- `declaration.js` provides the PluginDeclaration. It has a single node
type (the identity node).
- `identity.js` declares the `Identity` type (a username and list of
aliases), allows constructing identity nodes, and does some validation
on the identity username.
- `alias.js` implements the logic for parsing aliases like
"github/decentralion" or "discourse/s_ben" into a node address.
- `nodeContractions.js` provides logic for turning a list of Identities
into a list of NodeContractions, suitable for use in
`Graph.contractNodes`.

The plugin is not yet integrated; that will come in a followon commit.

Test plan: Unit tests added; `yarn test` passes.
2019-09-20 11:50:59 +02:00
Dandelion Mané b86dcf742e
Make the Discourse plugin robust to errors (#1387)
Currently attempting to load the SourceCred discourse instance fails
with foreign key constraint errors.

Basically, we have a few weird situations:
- A post (which corresponds to the 'psuedo-topic' generated by creating
a new category) is picked up, but its topic is not detected, because
Discourse does not list these 'psuedo-topics' in the latest topic
endpoint. Attempting to add the post breaks the foreign key constraint.

- We have several likes which correspond to posts that don't exist.
Possibly they were deleted? I'm not sure.

Right now, the load process fails entirely when it hits these
exceptions, which is bad. It should print a warning instead, and
continue without the offending interactions. This commit effects that
change in behavior.

Test plan:

Before this commit, loading the SourceCred discourse with a clean cache
fails. After building with this commit, loading the SourceCred discourse
with a clean cache workes and prints the following warnings:

```
$ node bin/sourcecred.js discourse https://discourse.sourcecred.io credbot
  GO   load-discourse.sourcecred.io
  GO   discourse
  GO   discourse/topics
 DONE  discourse/topics: 3m 53s
  GO   discourse/posts
Warning: Encountered error 'FOREIGN KEY constraint failed' while adding
post https://discourse.so urcecred.io/t/214/1.
 DONE  discourse/posts: 2m 38s
  GO   discourse/likes
 DONE  discourse/likes: 50s
 DONE  discourse: 7m 21s
  GO   compute-cred
 DONE  compute-cred: 547ms
 DONE  load-discourse.sourcecred.io: 7m 22s
```

Also, unit tests have been added that verify the specific behavior
changes.
2019-09-20 11:21:53 +02:00
Robin van Boven d5d00aae5a Blacklist techtribe org, thumbsup reaction (#1386)
Fixes #1353

Tested manually by creating a docker image including the changes.
Running the dev-preview @passbolt command until completion.
(once hitting the github rate limit, once till #1354 happens)

No more problematic interactions show up during load.
2019-09-20 11:20:14 +02:00
Robin van Boven d6bbc939b2 Add more bots. (#1383)
Fixes #1381
2019-09-19 17:52:20 +02:00
Dandelion Mané 8f46d7d812
Fix bug when selecting "All users" in explorer (#1388)
This fixes a bug introduced in #1371, where selecting a type other than
"All users" and then trying to reselect "All users" would break the UI.

Test plan: Manual inspection; load an instance, try selecting a
different type, and then go back to "All users". It now works as
expected.
2019-09-19 14:01:17 +02:00
Dandelion Mané 007568d3f0
Add `sourcecred discourse` command (#1374)
This adds a new command, `discourse`, which makes it convenient to load
Discourse servers as standalone SourceCred projects.

For example, you could load the official SourceCred discourse via the
following:

```sh
export SOURCECRED_DISCOURSE_KEY=....
yarn backend
node bin/sourcecred.js discourse https://discourse.sourcecred.io credbot
yarn start
```

I've updated the README with instructions for using the plugin.

Test plan: No automated testing because I see this tool as a temporary
placeholder until we get the SourceCred instances setup. I manually
tested the error cases (e.g. providing an invalid server url) as well as
success cases like the one above. I validated that the weights file
argument is being interpreted correctly (i.e. trying to load invalid
weights produces an expected error message, loading valid weights
results in those weights being present in the UI).
2019-09-19 12:32:49 +02:00
Dandelion Mané 1449935651
GitHub plugin: Expose user addresses (#1382)
Allow getting the node address for a user, given the user's login. This
will be needed by the upcoming identity plugin.

If the login in question corresponds to a bot, then a bot address will
be returned. When we make the bot-set configuration (rather than
hardcoded), we'll need to change the signature of this function; I think
that's fine.

Test plan: Unit tests added. (Also, it's really simple.)
2019-09-18 14:50:52 +02:00
Dandelion Mané ac8ac7051f
add `Graph.contractNodes` (#1380)
This commit adds Graph.contractNodes, which allows collapsing certain
nodes in the graph into each other. This will enable the creation of a
SourceCred "identity" plugin, allowing identity resolution between users
different accounts on different services.

Test plan: Thorough unit tests have been added. `yarn test` passes.

Thanks to @wchargin for [review feedback][1] which significantly
improved this API.

[1]: https://github.com/sourcecred/sourcecred/pull/1380#discussion_r324958055
2019-09-18 13:59:49 +02:00
William Chargin ddf07c6714
Replace `PartialTimelineCredParams` with `$Shape` (#1379)
Summary:
Flow provides a utility type for this purpose; there’s no need to
implement, document, and keep it in sync ourselves:
<https://flow.org/en/docs/types/utilities/#toc-shape>

Test Plan:
As written, `yarn flow` passes. Changing the definition of `params` on
line 77 of `load.test.js` to add a key `foo: "wat"` or change the value
of `weights` to `{hmm: "hmm"}` yield appropriate type errors.

wchargin-branch: use-shape
2019-09-16 19:22:35 -07:00
William Chargin 3cb22565e5
mirror: update EAV primitives (#1342)
Summary:
This commit modifies `_updateOwnData` to write to both the old
type-specific primitives tables as well as the new EAV table. This
establishes the invariant that a node with non-null `last_update` will
always have primitive data (if its object type has primitive fields).

Test Plan:
Existing tests expanded. Commenting out each of the `updateEavPrimitive`
calls (independently) causes a test to fail. Note that every test that
queries an internal `primitives_*` table to inspect the database state
has been expanded to make an equivalent query against the `primitives`
table as well.

wchargin-branch: mirror-eav-update
2019-09-14 17:28:09 -07:00
William Chargin 463f3a073a
mirror: initialize EAV primitives at registration (#1341)
Summary:
This establishes the invariant that every object in the `objects` table
has all relevant rows in the `primitives` table, though those rows’
values are never yet set.

Test Plan:
Unit tests updated. Manually loading `sourcecred/example-github` and
running `.dump primitives` generates reasonable-looking output, with
lots of rows, including entries for nested fields and eggs. Verified
that the set of non-`id` columns on `Issue` equals the set of values for
the `fieldname` column of an `Issue` object, and likewise for `Commit`s,
thus covering each kind of field.

wchargin-branch: mirror-eav-init
2019-09-14 17:24:58 -07:00