-
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 #3 from hanabix/profile
个人资料页插入速心比变化趋势
- Loading branch information
Showing
18 changed files
with
104 additions
and
33 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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,44 @@ | ||
import scala.concurrent.ExecutionContext.Implicits.global | ||
import scala.scalajs.js | ||
|
||
import org.scalajs.dom.* | ||
|
||
import common.Anchor | ||
import common.Extract | ||
import common.Functional.* | ||
import common.GetElement.query | ||
import common.GetMutationRecord.addedNodes | ||
import common.GetURL.path | ||
import common.Regex.* | ||
import garmin.Pagination | ||
import garmin.SearchResult | ||
import garmin.Service | ||
import plot.Plot | ||
import plot.Scatter | ||
|
||
object OnPageProfile: | ||
def apply()(using a: Anchor[HTMLElement], s: Scatter[SearchResult]): Route = | ||
case (Profile(Seq(_, id: String)), PageContent(e)) => | ||
val p: Pagination = new: | ||
start = 1 | ||
limit = 30 | ||
for | ||
ap <- Service.activitiesByProfile(id, p) | ||
al <- ap.activityList | ||
do | ||
val sr = al.filter(_.activityType.get.typeKey == "running") | ||
if sr.nonEmpty then | ||
val layout = Plot.Layout("近期跑步速心比变化趋势") | ||
val config = Plot.Config().setDisplayModeBar(false) | ||
Plot(a.init(e.before(_), "scatter"), js.Array(sr), layout, config)(using _.scatter) | ||
end apply | ||
|
||
private val Profile = Extract[URL, Seq[js.UndefOr[String]]]: | ||
path |> "/modern/profile/(.+)".capture | ||
|
||
private val PageContent = Extract[Seq[MutationRecord], Element]: | ||
inline def E = Extract[Element, Element]: | ||
query("div[class^=\"PageContent\"]").?? | ||
|
||
_.flatMap(addedNodes[Element]).collectFirst({ case E(e) => e }) | ||
end OnPageProfile |
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,6 @@ | ||
package garmin | ||
|
||
import scala.scalajs.js | ||
|
||
trait ActivitiesByProfile extends js.Object: | ||
var activityList: js.UndefOr[SearchResult] = js.undefined |
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,8 @@ | ||
package garmin | ||
|
||
import scala.scalajs.js | ||
|
||
trait Pagination extends js.Object: | ||
var excludeChildren: js.UndefOr[Boolean] = js.undefined | ||
var start: js.UndefOr[Int | String] = js.undefined | ||
var limit: js.UndefOr[Int | String] = js.undefined |
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
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