File tree Expand file tree Collapse file tree 6 files changed +76
-52
lines changed Expand file tree Collapse file tree 6 files changed +76
-52
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ WORKDIR /app
4
4
5
5
COPY . .
6
6
7
- RUN yarn install && yarn build
7
+ RUN yarn install && yarn test && yarn build
8
8
9
9
RUN rm -rf /build
10
10
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ export class FirehoseSubscription extends FirehoseSubscriptionBase {
17
17
// use only for debug purposes
18
18
for ( const post of ops . posts . creates ) {
19
19
console . log ( "================== [NEW POST] ==================" )
20
+ console . log ( post . author )
20
21
console . log ( post . record . text )
21
22
console . log ( "================== [END POST] ==================" )
22
23
}
@@ -26,7 +27,7 @@ export class FirehoseSubscription extends FirehoseSubscriptionBase {
26
27
const postsToCreate = ops . posts . creates
27
28
. filter ( ( create ) => {
28
29
// only scala related posts
29
- return isAboutScala ( create . record . text ) ;
30
+ return isAboutScala ( create . author , create . record . text ) ;
30
31
} )
31
32
. map ( ( create ) => {
32
33
// map scala related posts to a db row
Original file line number Diff line number Diff line change
1
+ export const scalaRelatedOrganizationProfiles = [
2
+ "did:plc:mb6e2ashxeswusv7f7hwusp5" , // scala-lang.org https://bsky.social/xrpc/com.atproto.identity.resolveHandle?handle=scala-lang.org
3
+ "did:plc:5nlshbn5adh3fjwzyz7xjpwl" , // Scala Space https://bsky.social/xrpc/com.atproto.identity.resolveHandle?handle=scalaspace.bsky.social
4
+ "did:plc:xs35x5l4ogj3g4eymh6ngcsr" , // Scala Times https://bsky.social/xrpc/com.atproto.identity.resolveHandle?handle=scalatimes.com
5
+ ]
Original file line number Diff line number Diff line change
1
+ const scalalang = [
2
+ "scala" , "scala3" , "dotty"
3
+ ]
4
+
5
+ const typelevel = [
6
+ "cats-effect"
7
+ ]
8
+
9
+ const scalameta = [
10
+ "munit" , "scalameta" , "scalafmt" ,
11
+ // "mdoc"
12
+ ]
13
+
14
+ const softwaremill = [
15
+ "scalar" , "scalarconf"
16
+ ]
17
+
18
+ const sbt = [
19
+ "sbt"
20
+ ]
21
+
22
+ const lihaoi = [
23
+ "os-lib" , "requests-scala"
24
+ ]
25
+
26
+ const lightbend = [
27
+ "akka" , "playframework"
28
+ ]
29
+
30
+ const others = [
31
+ "pekko"
32
+ ]
33
+
34
+ function hashTag ( word : String ) {
35
+ return `#${ word } `
36
+ }
37
+
38
+ export const allHashTags =
39
+ scalalang . concat ( typelevel ,
40
+ scalameta ,
41
+ softwaremill ,
42
+ // sbt, // sbt seems to be a thing in TV in Brasil
43
+ // lihaoi, // apparently people like to discuss hardware mills a lot
44
+ lightbend ,
45
+ others
46
+ ) . map ( w => hashTag ( w ) )
Original file line number Diff line number Diff line change 1
- const scalalang = [
2
- "scala" , "scala3" , "dotty"
3
- ]
1
+ import { allHashTags } from "./hashtags" ;
2
+ import { scalaRelatedOrganizationProfiles } from "./accounts" ;
4
3
5
- const typelevel = [
6
- "cats-effect"
7
- ]
8
-
9
- const scalameta = [
10
- "munit" , "scalameta" , "scalafmt" ,
11
- // "mdoc"
12
- ]
13
-
14
- const softwaremill = [
15
- "scalar" , "scalarconf"
16
- ]
17
-
18
- const sbt = [
19
- "sbt"
20
- ]
21
-
22
- const lihaoi = [
23
- "os-lib" , "requests-scala"
24
- ]
25
-
26
- const lightbend = [
27
- "akka" , "playframework"
28
- ]
29
-
30
- const others = [
31
- "pekko"
32
- ]
33
-
34
- const allHashTags =
35
- scalalang . concat ( typelevel ,
36
- scalameta ,
37
- softwaremill ,
38
- // sbt, // sbt seems to be a thing in TV in Brasil
39
- // lihaoi, // apparently people like to discuss hardware mills a lot
40
- lightbend ,
41
- others
42
- ) . map ( w => hashTag ( w ) )
43
-
44
- function hashTag ( word : String ) {
45
- return `#${ word } `
46
- }
47
-
48
- export function isAboutScala ( text : string ) : boolean {
4
+ function containsRelevantHashtag ( text : string ) : boolean {
49
5
const input = text . toLowerCase ( ) ;
50
6
const textWords = input . split ( / \s + / ) ;
51
7
return allHashTags . map ( v => v . toLowerCase ( ) ) . some ( tag => textWords . includes ( tag ) ) ;
52
8
}
53
9
10
+ function postedByScalaOrgAccount ( author : string ) : boolean {
11
+ return scalaRelatedOrganizationProfiles . includes ( author ) ;
12
+ }
13
+
14
+ export function isAboutScala ( author : string , text : string ) : boolean {
15
+ return postedByScalaOrgAccount ( author ) || containsRelevantHashtag ( text ) ;
16
+ }
17
+
Original file line number Diff line number Diff line change
1
+ import { scalaRelatedOrganizationProfiles } from '../../src/scala/accounts' ;
1
2
import { isAboutScala } from '../../src/scala/index' ;
2
3
4
+ const randomAuthorDid = "did:plc:abcde12345"
5
+
3
6
describe ( 'testing isAboutScala' , ( ) => {
4
7
test ( 'the #Scala hashtag should be picked up' , ( ) => {
5
8
expect (
6
- isAboutScala ( "#Scala" )
9
+ isAboutScala ( randomAuthorDid , "#Scala" )
7
10
) . toBe ( true ) ;
8
11
} ) ;
9
12
test ( 'proper message should be qualified as Scala related' , ( ) => {
10
13
expect (
11
- isAboutScala ( "We've a full house at the #London #Scala OSS Hack night this Wednesday! www.meetup.com/london-scala..." )
14
+ isAboutScala ( randomAuthorDid , "We've a full house at the #London #Scala OSS Hack night this Wednesday! www.meetup.com/london-scala..." )
15
+ ) . toBe ( true ) ;
16
+ } ) ;
17
+ test ( 'post by scala related org account should be qualified as Scala related' , ( ) => {
18
+ expect (
19
+ isAboutScala ( scalaRelatedOrganizationProfiles [ 0 ] , "This one doesn't have a hashtag" )
12
20
) . toBe ( true ) ;
13
21
} ) ;
14
22
test ( 'empty message should not be qualified as Scala' , ( ) => {
15
23
expect (
16
- isAboutScala ( "" )
24
+ isAboutScala ( randomAuthorDid , "" )
17
25
) . toBe ( false ) ;
18
26
} ) ;
19
27
} ) ;
You can’t perform that action at this time.
0 commit comments