Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified data/db.sqlite
Binary file not shown.
27 changes: 27 additions & 0 deletions migrations/20190610040022-add-descriptions-to-users.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
'use strict';

module.exports = {
up: async (queryInterface, Sequelize) => {
try {
await queryInterface.addColumn('users', 'description', {
type: Sequelize.STRING(200)
});
await queryInterface.addColumn('user_changes', 'description', {
type: Sequelize.STRING(200)
});
return Promise.resolve();
} catch (e) {
return Promise.reject(e);
}
},

down: async (queryInterface, Sequelize) => {
try {
await queryInterface.removeColumn('users', 'description'),
await queryInterface.removeColumn('user_changes', 'description')
return Promise.resolve();
} catch (e) {
return Promise.reject(e);
}
}
};
2 changes: 1 addition & 1 deletion public/data/users.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ const style = {
verticalAlign: 'middle',
marginRight: 16,
},
follows: {
fontWeight: '600'
},
action: {
display: 'inline-block',
textTransform: 'none',
Expand All @@ -27,7 +30,7 @@ const style = {
}

const DeveloperCard = ({user, index}) => (
<div className="card hoverable">
<div className="card hoverable" title={user.description}>
<div className="card-content">
<span style={style.cardNumber}>#{index}</span>
<OutboundLink
Expand All @@ -48,8 +51,7 @@ const DeveloperCard = ({user, index}) => (
{user.name || user.login}
</p>
</OutboundLink>
<p className="center-align">Followed by: {user.followers}</p>
<p>{user.description}</p>
<p className="center-align">Followers <span style={ style.follows }>{user.followers}</span> | Following <span style={ style.follows }>{user.following}</span></p>
</div>
<div className="card-action">
<span style={style.fact}>{user.sources} repositories</span>
Expand Down
2 changes: 2 additions & 0 deletions src/server/models/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module.exports = {
originalId: { type: Sequelize.STRING(100), unique: 'usersOriginalIdIndex' },
login: { type: Sequelize.STRING(100), unique: 'usersLoginIndex' },
name: Sequelize.STRING(100),
description: Sequelize.STRING(200),
type: Sequelize.STRING(100),
url: Sequelize.STRING(200),
avatarUrl: Sequelize.STRING(200),
Expand Down Expand Up @@ -43,6 +44,7 @@ module.exports = {
userId: { type: Sequelize.STRING(100), references: { model: 'user', key: 'id' } },
login: { type: Sequelize.STRING(100) },
name: Sequelize.STRING(100),
description: Sequelize.STRING(200),
type: Sequelize.STRING(100),
url: Sequelize.STRING(200),
company: Sequelize.STRING(100),
Expand Down
10 changes: 10 additions & 0 deletions src/server/services/github/queries/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ module.exports = {
id
login
name
status {
emoji
message
}
url: websiteUrl
avatarUrl
company
Expand All @@ -24,6 +28,12 @@ module.exports = {
following {
total: totalCount
}
sources: repositories {
total: totalCount
}
forked: repositories(isFork: true) {
total: totalCount
}
}
}
pageInfo {
Expand Down
2 changes: 1 addition & 1 deletion src/server/services/scraper/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ module.exports = {

return await srv.github.searchUsers(query, after || undefined)
.then((response) => {

// Store users.
const accounts = this.transform(response)
const users = accounts.filter((account) => account.type === 'User')
Expand All @@ -64,6 +63,7 @@ module.exports = {
originalId: node.id,
login: node.login,
name: node.name,
description: node.status ? node.status.message : '',
url: node.url,
type: node.__typename,
avatarUrl: node.avatarUrl,
Expand Down
6 changes: 3 additions & 3 deletions src/server/services/user/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ module.exports = {

if (this.isDifferentUser(original, user)) {
await this.createUserChange(original, user)
const updates = pick(user, ['login', 'name', 'type', 'url', 'avatarUrl', 'company', 'location', 'followers', 'following', 'sources', 'forked', 'collaborations'])
const updates = pick(user, ['login', 'name', 'description', 'type', 'url', 'avatarUrl', 'company', 'location', 'followers', 'following', 'sources', 'forked', 'collaborations'])
return await User.update(updates, { where: { originalId: user.originalId } })
}

Expand All @@ -80,7 +80,7 @@ module.exports = {
* @param {Object} b A user.
*/
isDifferentUser(a, b) {
const fields = ['login', 'name', 'type', 'url', 'company', 'location', 'followers', 'following', 'sources', 'forked', 'collaborations']
const fields = ['login', 'name', 'description', 'type', 'url', 'company', 'location', 'followers', 'following', 'sources', 'forked', 'collaborations']
return (!a || !b) || fields.some((field) => a[field] !== b[field])
},

Expand All @@ -91,7 +91,7 @@ module.exports = {
* @return {Promise}
*/
async createUserChange(original, changed) {
const change = pick(changed, ['login', 'name', 'type', 'url', 'avatarUrl', 'company', 'location'])
const change = pick(changed, ['login', 'name', 'description', 'type', 'url', 'avatarUrl', 'company', 'location'])
change.followers = changed.followers - original.followers
change.following = changed.following - original.following
change.sources = changed.sources - original.sources
Expand Down