Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
izdwuut committed Feb 21, 2020
2 parents 943c68e + 263e5bd commit fae9e72
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 16 deletions.
5 changes: 3 additions & 2 deletions backend/app/cache/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,9 @@ def scrap_steam_profile(self, comment, reddit_comment):
steam_user.level = None
steam_user.games_count = 0
if not steam_user.id:
logging.info('Steam user already exists. Updating.')
db.session.add(steam_user)
else:
logging.info('Steam user already exists. Updating.')
db.session.commit()
db.session.flush()
if steam_user.id:
Expand All @@ -134,7 +135,7 @@ def scrap_steam_profile(self, comment, reddit_comment):

logging.info('Getting Steam user summary.')
summary = self.steam.get_player_summary(steam_user.steam_id)
if summary is None:
if not summary:
self.commit_not_scrapped_steam_user(steam_user)
return
else:
Expand Down
2 changes: 1 addition & 1 deletion backend/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class RedditConfig:
CLIENT_SECRET = os.environ['GOG_PICKER_REDDIT_CLIENT_SECRET']
USERNAME = os.environ['GOG_PICKER_REDDIT_USERNAME']
PASSWORD = os.environ['GOG_PICKER_REDDIT_PASSWORD']
USER_AGENT = 'python:gog-picker:v0.14.1 (by /u/izdwuut)'
USER_AGENT = 'python:gog-picker:v0.14.2 (by /u/izdwuut)'
NOT_ENTERING = 'not entering'
MIN_KARMA = 300

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app/home/home.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</mat-hint>

</mat-form-field>
<button mat-button mat-stroked-button class="send-button" (click)="send()">SEND</button>
<button mat-button mat-stroked-button class="send-button" (click)="send()">Pick</button>
</div>
<div class="disclaimer">*Only Steam giveaways are supported.</div>
</div>
4 changes: 4 additions & 0 deletions frontend/src/app/home/home.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
width: 100%;
margin: 0
}

.n-input {
margin: 0
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions frontend/src/app/home/home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ export class HomeComponent implements OnInit, OnDestroy {

onNChange(): void {
if (this.n < 1) {
if (!this.n) {
if (this.n === null) {
this.nInputHint = 'Required.'
} else {
this.nInputHint = 'N must be positive.'
this.nInputHint = 'Must be positive.'
}
this.hasNErrors = true
} else {
Expand Down
18 changes: 9 additions & 9 deletions frontend/src/app/thread/thread.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class ThreadComponent implements OnInit, OnDestroy {
if (comment.author.karma < environment.minKarma) {
errors.push('not enough karma')
}
if (comment.steamProfile) {
if (comment.steamProfile && comment.steamProfile.steamId) {
if (comment.steamProfile.existent) {
if (comment.steamProfile.publicProfile) {
if (comment.steamProfile.level < environment.minLevel) {
Expand All @@ -100,8 +100,8 @@ export class ThreadComponent implements OnInit, OnDestroy {
}
}

if(comment.author.age) {
if(!this.isAgeValid(comment.author.age)) {
if (comment.author.age) {
if (!this.isAgeValid(comment.author.age)) {
errors.push('age too low')
}
}
Expand All @@ -118,7 +118,7 @@ export class ThreadComponent implements OnInit, OnDestroy {
if (comment.steamProfile == null) {
return ''
}
if(comment.steamProfile.notScrapped) {
if (comment.steamProfile.notScrapped) {
return ''
}
if (comment.steamProfile.existent) {
Expand Down Expand Up @@ -150,11 +150,11 @@ export class ThreadComponent implements OnInit, OnDestroy {
getWarnings(comment: RedditComment): String[] {
let warnings = Array<String>()
if (!this.canScrapSteamProfile(comment)) {
warnings.push("couldn't scrap comment")
warnings.push("couldn't scrap comment/nonexistent Steam profile")
return warnings
}
if (!comment.steamProfile) {
warnings.push('no Steam profile detected')
if (!comment.steamProfile.steamId) {
warnings.push('no Steam profile detected/nonexistent profile')
}
if (comment.steamProfile && comment.steamProfile.gamesCount >= environment.hoarderNumber) {
warnings.push('potential hoarder (' + comment.steamProfile.gamesCount + ' games)')
Expand All @@ -173,7 +173,7 @@ export class ThreadComponent implements OnInit, OnDestroy {
if (item.checked) {
winners.push(new ResultsComment(item.value, item._elementRef.nativeElement.getAttribute('data-comment-id')))
} else {
if(item._elementRef.nativeElement.getAttribute('data-has-warnings')) {
if (item._elementRef.nativeElement.getAttribute('data-has-warnings')) {
violators.push(new ResultsComment(item.value, item._elementRef.nativeElement.getAttribute('data-comment-id')))
}
}
Expand Down Expand Up @@ -213,7 +213,7 @@ export class ThreadComponent implements OnInit, OnDestroy {
}

getAge(age) {
if(age === null) {
if (age === null) {
return ''
}
let dateFrom = new Date(age)
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<body>
<app-root></app-root>
<footer class="footer">
Gift of Games Picker for Reddit <a href="https://github.com/izdwuut/gog-picker">v0.14.1</a>.
Gift of Games Picker for Reddit <a href="https://github.com/izdwuut/gog-picker">v0.14.2</a>.
Scripted by <a href="https://reddit.com/u/izdwuut">u/izdwuut</a> and <a href="https://github.com/izdwuut/gog-picker/pulls">friends</a> in open source.
Licensed under <a href="https://github.com/izdwuut/gog-picker/blob/dev/LICENSE">MIT Licence</a>
</footer>
Expand Down

0 comments on commit fae9e72

Please sign in to comment.