-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from polyvariant/track-scala-accounts
Always include posts by Scala related organization accounts
- Loading branch information
Showing
6 changed files
with
76 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export const scalaRelatedOrganizationProfiles = [ | ||
"did:plc:mb6e2ashxeswusv7f7hwusp5", // scala-lang.org https://bsky.social/xrpc/com.atproto.identity.resolveHandle?handle=scala-lang.org | ||
"did:plc:5nlshbn5adh3fjwzyz7xjpwl", // Scala Space https://bsky.social/xrpc/com.atproto.identity.resolveHandle?handle=scalaspace.bsky.social | ||
"did:plc:xs35x5l4ogj3g4eymh6ngcsr", // Scala Times https://bsky.social/xrpc/com.atproto.identity.resolveHandle?handle=scalatimes.com | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
const scalalang = [ | ||
"scala", "scala3", "dotty" | ||
] | ||
|
||
const typelevel = [ | ||
"cats-effect" | ||
] | ||
|
||
const scalameta = [ | ||
"munit", "scalameta", "scalafmt", | ||
// "mdoc" | ||
] | ||
|
||
const softwaremill = [ | ||
"scalar", "scalarconf" | ||
] | ||
|
||
const sbt = [ | ||
"sbt" | ||
] | ||
|
||
const lihaoi = [ | ||
"os-lib", "requests-scala" | ||
] | ||
|
||
const lightbend = [ | ||
"akka", "playframework" | ||
] | ||
|
||
const others = [ | ||
"pekko" | ||
] | ||
|
||
function hashTag(word: String) { | ||
return `#${word}` | ||
} | ||
|
||
export const allHashTags = | ||
scalalang.concat(typelevel, | ||
scalameta, | ||
softwaremill, | ||
// sbt, // sbt seems to be a thing in TV in Brasil | ||
// lihaoi, // apparently people like to discuss hardware mills a lot | ||
lightbend, | ||
others | ||
).map(w => hashTag(w)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,17 @@ | ||
const scalalang = [ | ||
"scala", "scala3", "dotty" | ||
] | ||
import { allHashTags } from "./hashtags"; | ||
import { scalaRelatedOrganizationProfiles } from "./accounts"; | ||
|
||
const typelevel = [ | ||
"cats-effect" | ||
] | ||
|
||
const scalameta = [ | ||
"munit", "scalameta", "scalafmt", | ||
// "mdoc" | ||
] | ||
|
||
const softwaremill = [ | ||
"scalar", "scalarconf" | ||
] | ||
|
||
const sbt = [ | ||
"sbt" | ||
] | ||
|
||
const lihaoi = [ | ||
"os-lib", "requests-scala" | ||
] | ||
|
||
const lightbend = [ | ||
"akka", "playframework" | ||
] | ||
|
||
const others = [ | ||
"pekko" | ||
] | ||
|
||
const allHashTags = | ||
scalalang.concat(typelevel, | ||
scalameta, | ||
softwaremill, | ||
// sbt, // sbt seems to be a thing in TV in Brasil | ||
// lihaoi, // apparently people like to discuss hardware mills a lot | ||
lightbend, | ||
others | ||
).map(w => hashTag(w)) | ||
|
||
function hashTag(word: String) { | ||
return `#${word}` | ||
} | ||
|
||
export function isAboutScala(text: string): boolean { | ||
function containsRelevantHashtag(text: string): boolean { | ||
const input = text.toLowerCase(); | ||
const textWords = input.split(/\s+/); | ||
return allHashTags.map(v => v.toLowerCase()).some(tag => textWords.includes(tag)); | ||
} | ||
|
||
function postedByScalaOrgAccount(author: string): boolean { | ||
return scalaRelatedOrganizationProfiles.includes(author); | ||
} | ||
|
||
export function isAboutScala(author: string, text: string): boolean { | ||
return postedByScalaOrgAccount(author) || containsRelevantHashtag(text); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,27 @@ | ||
import { scalaRelatedOrganizationProfiles } from '../../src/scala/accounts'; | ||
import { isAboutScala } from '../../src/scala/index'; | ||
|
||
const randomAuthorDid = "did:plc:abcde12345" | ||
|
||
describe('testing isAboutScala', () => { | ||
test('the #Scala hashtag should be picked up', () => { | ||
expect( | ||
isAboutScala("#Scala") | ||
isAboutScala(randomAuthorDid, "#Scala") | ||
).toBe(true); | ||
}); | ||
test('proper message should be qualified as Scala related', () => { | ||
expect( | ||
isAboutScala("We've a full house at the #London #Scala OSS Hack night this Wednesday! www.meetup.com/london-scala...") | ||
isAboutScala(randomAuthorDid, "We've a full house at the #London #Scala OSS Hack night this Wednesday! www.meetup.com/london-scala...") | ||
).toBe(true); | ||
}); | ||
test('post by scala related org account should be qualified as Scala related', () => { | ||
expect( | ||
isAboutScala(scalaRelatedOrganizationProfiles[0], "This one doesn't have a hashtag") | ||
).toBe(true); | ||
}); | ||
test('empty message should not be qualified as Scala', () => { | ||
expect( | ||
isAboutScala("") | ||
isAboutScala(randomAuthorDid, "") | ||
).toBe(false); | ||
}); | ||
}); |