小编spy*_*don的帖子

为每位客户选择首次购买

我们正试图在类似于下表的表中为每个客户选择第一次购买:

transaction_no  customer_id  operator_id  purchase_date
20503           1            5            2012-08-24
20504           1            7            2013-10-15
20505           2            5            2013-09-05
20506           3            7            2010-09-06
20507           3            7            2012-07-30
Run Code Online (Sandbox Code Playgroud)

我们尝试实现的查询的预期结果是:

transaction_no  customer_id  operator_id  first_occurence
20503           1            5            2012-08-24
20505           2            5            2013-09-05
20506           3            7            2010-09-06
Run Code Online (Sandbox Code Playgroud)

我们得到的最接近的是以下查询:

SELECT customer_id, MIN(purchase_date) As first_occurence
FROM Sales_Transactions_Header
GROUP BY customer_id;
Run Code Online (Sandbox Code Playgroud)

结果如下:

customer_id  first_occurence
1            2012-08-24
2            2013-09-05
3            2010-09-06
Run Code Online (Sandbox Code Playgroud)

但是当我们选择剩下的所需字段时,我们显然必须将它们添加到GROUP BY子句中,这将使MIN的结果不同.我们也试图自己加入,但没有取得任何进展.

如何在不使聚合函数混淆的情况下获得其余的相关值?

sql sql-server sql-server-2005

7
推荐指数
2
解决办法
2万
查看次数

带音频播放器的 Flutter Bloc

几乎花了一天的时间来思考如何做到这一点,我需要你的帮助。

我创建了一个应用程序,该应用程序的状态为audioplayers和 using的实例flutter_bloc

问题:

  1. 状态播放器播放,但小部件MusicPlayer不会使用以下命令重建小部件BlocBuilder
  2. 我还尝试获取currentPositionduration正在播放的音乐并使用包LinearPercentIndicator中的内容显示它linear_percent_indicator,但似乎找不到解决方案,因为重建不起作用。
  3. 我缺少什么?

这是我到目前为止所拥有的:

集团

class AudioPlayerBloc extends Bloc<AudioPlayerEvents, MusicPlayerState> {
  @override
  MusicPlayerState get initialState => MusicPlayerState(
        player: AudioPlayer(),
        episode: Episode(),
      );

  @override
  Stream<MusicPlayerState> mapEventToState(AudioPlayerEvents event) async* {
    if (event is InitializePlayer) {
      this.currentState.episode = event.episode;
      this.dispatch(PlayPlayer());
      yield this.currentState;
    }

    if (event is PlayPlayer) {
      this.play(this.currentState.episode.source);
    }

    if (event is PlayRemote) {
      this.currentState.player.stop();

      this.currentState.player.play(event.remoteURL);
      yield this.currentState;
    }

    if (event is ShowPlayer) …
Run Code Online (Sandbox Code Playgroud)

dart flutter flutter-audioplayers

6
推荐指数
1
解决办法
2915
查看次数

Flutter TabBar 标签之间的边距/填充

我有 3 TabBars,我想将标签放置在类别的左侧。

TabBar想要的:

在此输入图像描述

我的TabBar

在此输入图像描述

我的代码:

       // BOTTOM
      bottom: PreferredSize(
        preferredSize: const Size.fromHeight(kToolbarHeight),
        child: Align(
          alignment: Alignment.centerLeft,
          child: Container(
            width: MediaQuery.of(context).size.width / 1.1,
            child: TabBar(
              labelPadding: EdgeInsets.all(0),
              labelColor: Colors.white,
              labelStyle: poppins.copyWith(
                fontSize: 15,
                fontWeight: bold,
              ),
              unselectedLabelColor: Color(0xff585861),
              indicatorColor: Colors.white,
              indicatorSize: TabBarIndicatorSize.label,

              // TABS
              tabs: [
                Tab(
                  text: 'Following',
                ),
                Tab(
                  text: 'Trending',
                ),
                Tab(
                  text: 'Search',
                ),
              ],
            ),
          ),
        ),
      ),
Run Code Online (Sandbox Code Playgroud)

dart flutter

6
推荐指数
1
解决办法
8375
查看次数

Azure DevOps 中的合并列车

是否有可能以某种方式在 Azure DevOps 中实现合并列车,类似于GitLab 所做的?或者按照GitHub中的说法合并队列?

合并火车示例

三个合并请求(A、B 和 C)按顺序添加到合并序列中,这将创建三个并行运行的合并结果管道:

The first pipeline runs on the changes from A combined with the target branch.
The second pipeline runs on the changes from A and B combined with the target branch.
The third pipeline runs on the changes from A, B, and C combined with the target branch.
Run Code Online (Sandbox Code Playgroud)

azure azure-devops azure-pipelines

6
推荐指数
1
解决办法
351
查看次数

无法将惰性格式的递归JSON类型视为隐式值

我正在使用Spray构建REST API.我的一个JSON数据类型是递归的:

case class Container(id: String,
                 name: String,
                 read_only: Boolean,
                 containers: List[Container],
                 content: List[Content])

object PeriusJsonProtocol extends DefaultJsonProtocol {
  implicit val contentFormat = jsonFormat8(Content)
  implicit val containerFormat: JsonFormat[Container] = lazyFormat(jsonFormat5(Container))
}
Run Code Online (Sandbox Code Playgroud)

在HttpService中完成路由时,我收到以下错误:

Error:(49, 18) could not find implicit value for parameter um: spray.httpx.unmarshalling.FromRequestUnmarshaller[Container]
        entity(as[Container]) { container =>
                 ^

Error:(49, 18) not enough arguments for method as: (implicit um: spray.httpx.unmarshalling.FromRequestUnmarshaller[Container])spray.httpx.unmarshalling.FromRequestUnmarshaller[Container].
Unspecified value parameter um.
        entity(as[Container]) { container =>
                 ^
Run Code Online (Sandbox Code Playgroud)

HttpService看起来像这样:

import akka.actor.Actor
import spray.routing._
import spray.httpx.SprayJsonSupport._

import PeriusJsonProtocol._

class RestServiceActor extends …
Run Code Online (Sandbox Code Playgroud)

json scala spray spray-json spray-routing

5
推荐指数
1
解决办法
456
查看次数

如何检查用户是否已使用 Google Sign in 和 Firebase Auth 登录以检索他们的数据?

我有一个用 Flutter 制作的简单游戏,我可以登录用户,但我不知道如何检查用户是否已登录以及如何获取用户的数据。

对于登录,我使用这种方法,登录用户后,我可以获取他的数据:

Future<String> signInWithGoogle() async{

    print("INICIALIZANDO LOGIN COM GOOGLE...");

    googleSignInAccount = await googleSignIn.signIn();
    googleSignInAuthentication = await googleSignInAccount.authentication;

    final AuthCredential credential = GoogleAuthProvider.getCredential(
        accessToken: googleSignInAuthentication.accessToken,
        idToken: googleSignInAuthentication.idToken,

    );

    AuthResult authResult = await _auth.signInWithCredential(credential);

    user = authResult.user;

    assert(!user.isAnonymous);
    assert(await user.getIdToken() != null);

    currentUser = await _auth.currentUser();
    assert(user.uid == currentUser.uid);

    uid = user.uid;
    name = user.displayName;
    email = user.email;
    imageUrl = user.photoUrl;

    print(uid);
    print(email);
    print(name);
    print(imageUrl);

    return 'signInWithGoogle succeded: $user';

  }
Run Code Online (Sandbox Code Playgroud)

对于 signOut 这个:

  void signOutGoogle() async{

    print("DESLOGOU!");
  await googleSignIn.signOut();

  }
Run Code Online (Sandbox Code Playgroud)

firebase-authentication google-signin flutter

5
推荐指数
1
解决办法
6884
查看次数

dependency_overrides 用于具有路径依赖的依赖

在 Flame 中,我们有一个包含 Flame 的 monorepo 及其桥接包,并且所有桥接包都将 Flame 作为路径依赖项(不是在发布时)。似乎不可能同时依赖于我们的主分支和主分支上的桥接库,我在文件中有这样的内容pubspec.yaml

\n
dependencies:\n  flutter:\n    sdk: flutter\n  flame:\n    git:\n      url: git@github.com:flame-engine/flame.git\n      path: packages/flame\n      ref: main\n  flame_fire_atlas:\n    git:\n      url: git@github.com:flame-engine/flame.git\n      path: packages/flame_fire_atlas\n      ref: main\n\ndependency_overrides:\n  flame:\n    git:\n      url: git@github.com:flame-engine/flame.git\n      path: packages/flame\n      ref: main\n
Run Code Online (Sandbox Code Playgroud)\n

做时pub get我得到:

\n
Error on line 15, column 11: Invalid description in the "flame_fire_atlas" pubspec on the "flame" dependency: "../flame" is a relative path, but this isn\'t a local pubspec.\n   \xe2\x95\xb7\n15 \xe2\x94\x82     path: ../flame\n   \xe2\x94\x82           ^^^^^^^^\n   \xe2\x95\xb5\npub …
Run Code Online (Sandbox Code Playgroud)

dart flutter flame

5
推荐指数
1
解决办法
3022
查看次数

Flutter 音频播放器返回错误的播放时间?

我正在使用 audioplayers: 1.1.0插件从 url 播放音频。玩得很好。但在player.onPositionChanged特定秒数之后,它会重新启动,计时器从 0 开始。这样我的滑块又从 0 开始。

  player.onPositionChanged.listen((newPosition) {
      prints(newPosition);
  });
Run Code Online (Sandbox Code Playgroud)

输出:

0:00:00.000000
0:00:00.002000
0:00:00.203000
0:00:00.405000
0:00:00.607000
0:00:00.810000
0:00:01.013000
0:00:01.215000
0:00:02.027000
0:00:02.232000
0:00:03.863000
0:00:04.882000
0:00:00.236000  // after some seconds again returns from 0
0:00:00.438000
0:00:00.641000
0:00:01.052000
0:00:01.662000
0:00:01.864000
Run Code Online (Sandbox Code Playgroud)

当这个函数再次从 0 返回时,Slider 也会重新启动,如下所示

在此输入图像描述

这是整个代码

音频播放器:1.1.0

import 'package:flutter/material.dart';
import 'package:audioplayers/audioplayers.dart';
import 'dart:async';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData( …
Run Code Online (Sandbox Code Playgroud)

audio dart flutter flutter-audioplayers

5
推荐指数
0
解决办法
550
查看次数

SBT 在内存耗尽时被杀死

我试图在具有 800MB RAM 的 Docker 容器中运行我的 scala 应用程序,( docker run -m=800m mindlevel) 但它在编译完成之前就被杀死了。

[info] Compiling 10 Scala sources to /root/mindlevel-backend/target/scala-2.12/classes...
[info] 'compiler-interface' not yet compiled for Scala 2.12.1. Compiling...
[info]   Compilation completed in 8.631 s
/usr/local/sbt/bin/sbt-launch-lib.bash: line 58:    57 Killed                  "$@"
Run Code Online (Sandbox Code Playgroud)

我尝试通过以下方式限制 SBT 堆:

CMD ["sbt", "-mem", "700", "run"]
Run Code Online (Sandbox Code Playgroud)

但它仍然在同一个地方被杀死。对 docker 容器没有任何限制,它运行良好。当在 EC2 微型实例(1GB RAM)中运行它时,它也会崩溃,无论是否有 SBT 和 Docker 的限制。

我缺少一些限制吗?

scala sbt docker

3
推荐指数
1
解决办法
2190
查看次数

下载 Google Drive 直接链接时如何显示正确的进度?

我有一个来自 Google Drive 的直接链接,我的应用程序将下载并显示百分比,它可以正确下载任何其他链接,但只有使用 Google Drive 直接链接,它才会显示一个很大的负数。

“Baixando”在葡萄牙语中的意思是“下载”。

应用程序屏幕

  await dio.download(
    widget.document['url'],
    path,
    onReceiveProgress: (received, total){

      setState(() {
        progress = "Baixando..."+((received / total) * 100).toStringAsFixed(0) + "%";
      });

  });
Run Code Online (Sandbox Code Playgroud)

例如,使用此 Google Drive 直接链接 (pdf):https : //drive.google.com/uc?export=download&id=1N8D8lx1HlW0X99wovGEQxZRUtewN6-J2

更新:“接收”以字节为单位获取文件的大小,“总计”我只得到值:-1,尝试下载 Google Drive 直接链接时它不会改变。

dart flutter

2
推荐指数
1
解决办法
4211
查看次数

AudioPlayers 无法在 iOS 上运行 | 颤振插件

我正在创建一个 Flutter 插件。目前,代码:

  1. 将字符串合成为音频文件
  2. 获取文件的路径
  3. 使用音频播放器播放音频文件

当我在 Android 中运行该应用程序时,它完美运行。然而,当我在 iOS 上运行它时,它却没有(假设涉及权限/限制)

await flutterTts
        .synthesizeToFile(
            "This is my first audio synthesizer in Flutter", audioFileName)
        .then((success) => {
              if (success == 1)
                {
                  print('Successfully synthesized!!'),

                  // Gets the path to the generated file depending on the platform
                  pathFile =
                      Platform.isAndroid ? pathToFileAndroid : pathToFileIos,
                  pathFile
                      .then((pathToAudioFile) => {
                            print('Path to file: ' + pathToAudioFile),
                            // Speakers/earpiece
                            // int result = await player.earpieceOrSpeakersToggle();
                            // Sets the path to the file
                            audioPlayer.setUrl(pathToAudioFile),
                            audioPlayer.setVolume(1.0), …
Run Code Online (Sandbox Code Playgroud)

audio file ios flutter flutter-audioplayers

2
推荐指数
1
解决办法
5570
查看次数

java中的GUI"转到上一个/下一个"选项?

有没有办法选择上一个消息对话框或下一个消息对话框?我有一个程序,在完成所有输入和数学计算后,会出现一个消息对话框,其中包含"人员1"的信息,然后按下确定,出现"人员2"的信息.如果可以选择能够在不同的对话框之间导航,那将是很好的.这是打印消息的程序的一部分.

for (i = 0; i < NumEmployees; i++)    
{
    JOptionPane.showMessageDialog(null, 
            "Employee: " + names[i] + "\n" + 
            "ID: " + data[i][0] + "\n" + 
            "Hours worked: " + (data[i][1] + data[i][2]) + "\n" + 
            "Overtime: " + data[i][2] + "hours" + "\n" + 
            "Amount earned: " + payment[i]);    
}
Run Code Online (Sandbox Code Playgroud)

java swing dialog show joptionpane

1
推荐指数
1
解决办法
892
查看次数